How to start YSQL

So, I’ve taken a docker image of yugabyte and then created four nodes by downloading the files from this github link and doing a docker compose up: GitHub - kyesil/docker_yugabyte: Yugabyte DB multi node playground with docker compose

As described in the link all the heartbeats of the nodes are okay; however I am having trouble running YSQL.

I had a mess around with it and found I can start yugabyte by running in the terminal:

docker run -it yugabytedocker-composemultinode-yb1:latest bin/yugabyted start

which comes back all okay, can also get the status by running:

docker run -it yugabytedocker-composemultinode-yb1:latest bin/yugabyted status

Where yugabytedocker-composemultinode-yb1 is one of the docker images I have.

However, I just don’t know how to run YSQL from the command line? Please can someone help me

I have four containers, the one related to the image I mentioned above is described below:

971c528dfddf yugabytedocker-composemultinode-yb1 “/sbin/tini – /bin/…” 5 days ago Up 7 minutes 6379/tcp, 7100/tcp, 7200/tcp, 9042/tcp, 9100/tcp, 10100/tcp, 11000/tcp, 12000/tcp, 0.0.0.0:5431->5433/tcp, [::]:5431->5433/tcp, 0.0.0.0:7001->7000/tcp, [::]:7001->7000/tcp, 0.0.0.0:9001->9000/tcp, [::]:9001->9000/tcp yb1

In terminal, I try and run YSQL from this container using the command I found from Explore YSQL, the Yugabyte SQL API | YugabyteDB Docs :

docker exec -it yb1 /home/yugabyte/bin/ysqlsh --echo-queries

I get the following error:

ysqlsh: could not connect to server: Connection refused
Is the server running on host “localhost” (::1) and accepting
TCP/IP connections on port 5433?
could not connect to server: Connection refused
Is the server running on host “localhost” (127.0.0.1) and accepting
TCP/IP connections on port 5433?

I’ve got YSQL working with one of the containers by first finding out the IP address of the container using:

sudo docker inspect -f ‘{{range.NetworkSetting.Networks}}{{.IPAddress}}{{end}}’ yb1

then:

docker exec -it yb1 /home/yugabyte/bin/ysqlsh –echo-queries -h (IP address)

Credits to this previous forum topic: Ysqlsh: could not connect to server: Connection refused - General - Yugabyte Community Forum

Feel stupid that it took me so long to figure out!

1 Like