How to connect to Cassandra(remotehost) using cqlsh

mobileDev picture mobileDev · Sep 3, 2015 · Viewed 44.9k times · Source

I cannot cqlsh to remote host

 ./cqlsh xx.xx.x.xxx 9042
   Connection error: ('Unable to connect to any servers', {'10.101.33.163':   
   ConnectionException(u'Did not get expected SupportedMessage response; 
   instead, got: <ErrorMessage code=0000 [Server error]      
   message="io.netty.handler.codec.DecoderException: 
   org.apache.cassandra.transport.ProtocolException: Invalid or unsupported 
   protocol version: 4">',)})

I am using cqlsh 5.0.1 and python 2.7.10

  ./cqlsh --version
     cqlsh 5.0.1
  python -V
    Python 2.7.10

I am on mac and used the instructions from http://www.datastax.com/2012/01/working-with-apache-cassandra-on-mac-os-x to download cassandra.

Cassandra on my local is 2.2.1(as I understand from the zip file) and it appears like cassandra on remote host is NOT 2.2.1 (I assume it is either 2.0 or 2.1). Without definitively knowing what the version is on remote host, how can I try to connect to cassandra on remote host

Answer

Chris Gerlt picture Chris Gerlt · Sep 3, 2015

1) Make sure the service is running:

$ ps aux | grep cassandra

Example: 106 7387 5.1 70.9 2019816 1454636 ? SLl Sep02 16:39 /usr/lib/jvm/java-7-oracle/jre//bin/java -Ddse.system_cpu_cores=2 -Ddse.system_memory_in_mb=2003 -Dcassandra.config.loader=com.datastax.bdp.config.DseConfigurationLoader -Ddse.system_cpu_cores=2 -Ddse.system_memory_in_mb=2003 -Dcassandra.config.loader=com.datastax.bdp.config.DseConfigurationLoader -ea -javaagen...

2) Make sure you are using the correct IP by checking the server config:

$ ifconfig

Example:

eth1 Link encap:Ethernet HWaddr 08:00:27:a6:4e:46
inet addr:192.168.56.10 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fea6:4e46/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

3) Ensure you can connect to that IP from the server you are on:

$ ssh [email protected]

4) Check the node's status and also confirm it shows the same IP:

$nodetool status

5) run the command to connect with the IP (only specify port if you are not using the default):

$ cqlsh xxx.xxx.xx.xx