Unable to run cqlsh; Timed out creating connection - cassandra

I am unable to run cqlsh:
$ cqlsh 10.230.34.16 9160
Connection error: ('Unable to connect to any servers', {'10.230.34.16': OperationTimedOut('errors=Timed out creating connection, last_host=None',)})
The rpc service listening on 9160, but still cqlsh is unable to connect to it?
$ netstat -an |grep 9160| grep LISTEN
tcp 0 0 10.230.34.16:9160 0.0.0.0:* LISTEN
Any ideas what I can check?
Am using datastax cassandra 2.1.0

check the cassandra.yaml file on the line with rpc_port : normally by default = 9160
login to the machine hosting cassandra
try cqlsh 127.0.0.1 9160 : should be ok in any case
try cqlsh [IP of host] 9160 : if ok then cassandra reachable from lan, if ko then cassandra is not reachable from lan but only localhost 127.0.0.1

It is a bit old, but in case anybody got into this issue.
Base on this QNA, it seems the driver and the protocol has change.
Try
cqlsh 127.0.0.1 9042
It solved the issue for me.

Related

CQLSH is not executing and Connection Refused

I am unable to execute cqlsh command. I am new to cassandra. I have followed the previous threads. Still unable to execute cqlsh command. Please help me to figure out the issue. Here is the error when I run CQLSH,
[root#Kar bin]# cqlsh
Connection error: ('Unable to connect to any servers',
{'127.0.0.1': error(111,
"Tried connecting to [('127.0.0.1', 9042)].
Last error: Connection refused")})
Thanks,
Karthick
What are the values of your listen_address and broadcast_address?
$ grep _address conf/cassandra.yaml | grep -v "\#"
listen_address: 169.254.93.1
rpc_address: 169.254.93.1
In my case, 169.254.93.1 is the only address that Cassandra will bind on port 9042. Therefore, just running cqlsh (without specifying the IP) only works if they are mapped to the home IP of 127.0.0.1 or localhost.
Therefore, I will need to specify 169.254.93.1 to connect.
$ bin/cqlsh 169.254.93.1 -u flynn -p reindeerFlotilla
Connected to TheGrid at 169.254.93.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
flynn#cqlsh>

CQLSH is not recognized in google cloud datastax cluster nodes

I have deployed a 4 node datastax cluster in GCP. I can ssh into each of the VM nodes but cqlsh is not recognized.Can you please help me to understand where I am going wrong
error:
Connection error: ('Unable to connect to any servers',
{'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1',
9042)]. Last error: Connection refused")})
If your cluster is working correctly, then the nodes must know about each other by their own IPs (internal or external). So Cassandra isn't configured to bind 9042 to 127.0.0.1, which means trying to cqlsh to 127.0.0.1:9042 won't work.
One way to check, would be just to do a nodetool status, and use one of those IP addresses. But, as you're on GCP, you may have both internal and external IP addresses, so in that case it really depends on which IP is set as your broadcast_rpc_address. You can check them all by grepping your cassandra.yaml.
$ grep "_address:" cassandra.yaml
listen_address: 192.168.1.3
broadcast_address: 10.20.15.1
# listen_on_broadcast_address: false
rpc_address: 192.168.1.3
broadcast_rpc_address: 10.20.15.1
In this case, your cqlsh command would look something like this:
cqlsh 10.20.15.1 -u youruser -p yourpassword

Cassandra Cqlsh is not working

I've just started working with Cassandra (homebrew install), version 3.7 and cqlsh version 5.0.1. , OS X El Capitan
Cassandra starts up fine and the cluster is operational instantly.
Cqlsh is not working (on any of the nodes) and emits the following error:
Connection error: ('Unable to connect to any servers', {'127.0.0.1':
error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error:
Connection refused")})
Edit cqlsh and change DEFAULT_HOST = IP and then run cqlsh.
I think the first step you should be doing is running netstat -ntpl. This should list down all the ports active on the system. Check for Local Address there you shall find a IP prepended with 9042.
Use this IP to connect ie cqlsh IP . If you do not find the 9042 port in the netstat output than check your cassandra.yaml file. Grep for native_transport_port see if it is 9042 or something different.
If different than connect on that port via cqlsh.
For future reference, if someone else gets it.
I'm running [cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4].
Add start_native_transport: true field in cassandra.yaml file, by default it doesn't enables it and so no rpc communication with client.
Now try connecting with cqlsh rpc_endpoint(rpc addr set in cassandra.yaml).

How to configure cassandra for remote connection

I am trying to configure Cassandra Datastax Community Edition for remote connection on windows,
Cassandra Server is installed on a Windows 7 PC, With the local CQLSH it connects perfectly to the local server.
But when i try to connect with CQLSH from another PC in the same Network, i get this error message:
Connection error: ('Unable to connect to any servers', {'MYHOST':
error(10061, "Tried connecting to [('HOST_IP', 9042)]. Last error: No
connection could be made because the target machine actively refused
it")})
So i am wondering how to configure correctly (what changes should i make on cassandra.yaml config file) the Cassandra server to allow remote connections.
Thank you in advance!
How about this:
Make these changes in the cassandra.yaml config file:
start_rpc: true
rpc_address: 0.0.0.0
broadcast_rpc_address: [node-ip]
listen_address: [node-ip]
seed_provider:
- class_name: ...
- seeds: "[node-ip]"
reference: https://gist.github.com/andykuszyk/7644f334586e8ce29eaf8b93ec6418c4
Remote access to Cassandra is via its thrift port for Cassandra 2.0. In Cassandra 2.0.x, the default cqlsh listen port is 9160 which is defined in cassandra.yaml by the rpc_port parameter. By default, Cassandra 2.0.x and earlier enables Thrift by configuring start_rpc to true in the cassandra.yaml file.
In Cassandra 2.1, the cqlsh utility uses the native protocol. In Cassandra 2.1, which uses the Datastax python driver, the default cqlsh listen port is 9042.
The cassandra node should be bound to the IP address of your server's network card - it shouldn't be 127.0.0.1 or localhost which is the loopback interface's IP, binding to this will prevent direct remote access. To configure the bound address, use the rpc_address parameter in cassandra.yaml. Setting this to 0.0.0.0 will listen on all network interfaces.
Have you checked that the remote machine can connect to the Cassandra node? Is there a firewall between the machines? You can try these steps to test this out:
1) Ensure you can connect to that IP from the server you are on:
$ ssh user#xxx.xxx.xx.xx
2) Check the node's status and also confirm it shows the same IP:
$nodetool status
3) Run the command to connect with the IP (only specify the port if you are not using the default):
$ cqlsh xxx.xxx.xx.xx
Alternate solution to Kat. Worked with Ubuntu 16.04
ssh into server server_user#**.**.**.**
Stop cassandra if running:
Check if running with ps aux | grep cassandra
If running, will output a large block of commands / flags, e.g.
ubuntu 14018 4.6 70.1 2335692 712080 pts/2 Sl+ 04:15 0:11 java -Xloggc:./../logs/gc.log ........
Note 14018 in the example is the process id
Stop with kill <process_id> (in this case 14018)
edit cassandra.yaml file to be the following
rpc_address: 0.0.0.0
broadcast_rpc_address: **.**.**.** <- your server's IP (cannot be set to 0.0.0.0)
Restart cassandra ./bin/cassandra -f (from within cassandra root)
Open another terminal on local machine & connect via cqlsh **.**.**.** (your server's IP) to test.
The ./bin/nodetool status address reported my localhost IP (127.0.0.1), but cqlsh remotely still worked despite that.

cassandra 1.2 nodetool getting 'Failed to connect' when trying to connect to remote node

I am running a 6 node cluster of cassandra 1.2 on an Amazon Web Service VPC with Oracle's 64-bit JVM version 1.7.0_10.
When I'm logged on to one of the nodes (ex. 10.0.12.200) I can run nodetool -h 10.0.12.200 status just fine.
However, if I try to use another ip address in the cluster (10.0.32.153) from that same terminal I get Failed to connect to '10.0.32.153:7199: Connection refused'.
On the 10.0.32.153 node I am trying to connect to I've made the following checks.
From 10.0.12.200 I can run telnet 10.0.32.153 7199 and I get a connection, so it doesn't appear to be a security group/firewall issue to port 7199.
On 10.0.32.153 if I run netstat -ant|grep 7199 I see
tcp 0 0 0.0.0.0:7199 0.0.0.0:* LISTEN
so cassandra does appear to be listening on the port
The cassandra-env.sh file on 10.0.32.153 has all of the JVM_OPTS for jmx active
-Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
The only shot in the dark I've seen while trying to solve this problem while searching the interwebs is to set the following:
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=10.0.32.153"
But when I do this I don't even get a response. It just hangs.
Any guidance would be greatly appreciated.
The issue did end up being a firewall/security group issue. While it is true that the jmx port 7199 is used, apparently other ports are used randomly for rmi. Cassandra port usage - how are the ports used?
So the solution is to open up the firewalls then configure the cassandra-env.sh to include
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<ip>

Resources