This is because of some pre-configurations in the cassandra. And to fix this, there are following commented lines in the cassandra-env.sh file:
#add this if you’re having trouble connecting:
#JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>
where you have to start fixing the error.
Open the terminal and start fixing using the following easy steps:
Step-1
use
sudo nano /etc/cassandra/cassandra-env.sh
this command and search for JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname= uncomment the line by simply removing # attached in the start of the line.
NOTE: If you have never opened this file to fix this error then you will find JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>
Step-2
Now replace <public name> with 127.0.0.1
Step-3 Save the file and restart the cassandra using systemctl restart cassandra.service (if you haven't the server is alredy running). OR start the cassandra using systemctl start cassandra.service (if the server is not running).
Step-4 Check the status either by using sudo service cassandra status or systemctl status cassandra.service.
Note: Once check the system monitor whether cassandra is running there or not.
Try cqlsh now. It'll work.
Note: nano is editor you can use other editors you are comfortable with.
cqlsh 1.1.2.2 9160- Chroslisten_address,rpc_addressandbroadcast_rpc_address...the latter setting being new with 2.1.x. I would be interested to know thelisten_addressandrpc_addresssettings (not necessarily the values, but how they relate to the 1.1.2.2 IP used with cqlsh). If you try 2.1.x again, setlisten_addressto your local IP,rpc_addressto 0.0.0.0, andbroadcast_rpc_addressto your external IP. - Aaron1.1.2.2being the host IP (host only has an internal IP) the values were:listen_address: 1.1.2.2rpc_address: 0.0.0.0broadcast_rpc_address: 1.1.2.2. The broadcast address was required (cassandra logs). Tried most combinations yet none proved fruitful. Ended up having to remove/comment it out for 2.0.13 so it could very well be thebroadcast_rpc_addresscreating the problems. Not sure which other value I could have given it. Wouldn't it have thrown an error anywhere else? - Chros