question

sibi.revi_190654 avatar image
sibi.revi_190654 asked ds-steven-matison published

Why can't I connect with cqlsh to node 3 in exercise 14 of the Academy DS201 course?

I have 3 nodes. As per lab instructions the first two nodes have to be brought down. Now in node 3 i am unable to connect to cqlsh. It keeps throwing error. I have tried providing the explicit ip and port as mentioned in an earlier lab. Please let know how to we connect to db from node 3.

academyds201
2 comments
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

bettina.swynnerton avatar image bettina.swynnerton ♦♦ commented ·

What error are you getting?

0 Likes 0 ·
sibi.revi_190654 avatar image sibi.revi_190654 bettina.swynnerton ♦♦ commented ·

Connection error: ('Unable to connect to any servers', {'127.0.0.3': error(111, "Tried connecting to [('127.0.0.3', 9043)]. Last error: Connection refused")})

0 Likes 0 ·
Erick Ramirez avatar image
Erick Ramirez answered

I suspect the problem you're encountering is similar to Why can't I connect to nodes in the DS201 Academy VM with cqlsh or nodetool?.

CQL clients configuration

cqlsh by default connects to CQL port 9042 but because all DSE instances are running in the same VM, they have to be configured to listen to different ports. The nodes in the DS201 VM are configured as follows:

$ for _node in node*; do echo "$_node - `grep ^native_transport_port $_node/resources/cassandra/conf/cassandra.yaml`"; done
node1 - native_transport_port: 9041
node2 - native_transport_port: 9042
node3 - native_transport_port: 9043

However, all the 3 ports are bound to 127.0.0.1:

$ for _node in node*; do echo "$_node - `grep ^native_transport_address $_node/resources/cassandra/conf/cassandra.yaml`"; done
node1 - native_transport_address: localhost
node2 - native_transport_address: localhost
node3 - native_transport_address: localhost

Sample VM

When I check on my copy of the VM, I can confirm that CQL clients (cqlsh is just another client) can only connect on localhost:

$ sudo lsof -nPi | grep LISTEN | grep 904
java      1544 ubuntu  481u  IPv4  19709      0t0  TCP 127.0.0.1:9041 (LISTEN)
java      2135 ubuntu  485u  IPv4  24848      0t0  TCP 127.0.0.1:9042 (LISTEN)
java     18820 ubuntu  480u  IPv4  45516      0t0  TCP 127.0.0.1:9043 (LISTEN)

This means that you won't be able to connect to any IP other than 127.0.0.1.

Solution

In order to connect to node 3, run cqlsh with the following parameters:

$ cqlsh 127.0.0.1 9043

Cheers!

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

ds-steven-matison avatar image
ds-steven-matison answered ds-steven-matison published

In case another user gets into the same situation I just ran into.


Following Exercise 14 step by step, i execute the partition command and see:

ubuntu@ds201-node1:~$ /home/ubuntu/node1/resources/cassandra/bin/nodetool getendpoints killrvideo videos_by_tag 'cassandra'
127.0.0.1
127.0.0.2

I then stop #1 and #2 and try to cqsl to #3. Per document this should be:

where X is the number of the node you are connecting to.
nodeX/bin/cqlsh 127.0.0.X 904X
ubuntu@ds201-node1:~$ /home/ubuntu/node3/resources/cassandra/bin/cqlsh 127.0.0.3 9043
Connection error: ('Unable to connect to any servers', {'127.0.0.3': error(111, "Tried connecting to [('127.0.0.3', 9043)]. Last error: Connection refused")})

Next I try as suggested above 127.0.0.1 w/ 9043 port and still no luck. Then I start investigating the scripts Erick shared and not getting output as above. It turns out that node 3 was not online. I had to start node 3.

ubuntu@ds201-node1:~$ sudo lsof -nPi | grep LISTEN | grep 904
java      9287 ubuntu  598u  IPv4  91894      0t0  TCP 127.0.0.1:9043 (LISTEN)


ubuntu@ds201-node1:~$ /home/ubuntu/node3/resources/cassandra/bin/cqlsh 127.0.0.1 9043
Connected to Test Cluster at 127.0.0.1:9043.
[cqlsh 5.0.1 | Cassandra 4.0.0.2284 | DSE 6.0.0 | CQL spec 3.4.5 | DSE protocol v2]
Use HELP for help.
cqlsh>


I think the excercise PDF needs to be adjusted to:

nodeX/bin/cqlsh 127.0.0.1 904X
Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.