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
or the server IP.
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.