Nikunj
Nikunj

Reputation: 33

couldn't connect to server in cassandra on centos6.9

I am using VPS with centos 6.9. and I am new to cassandra. i have installed cassandra 3.0 using the following link:

https://docs.datastax.com/en/cassandra/3.0/cassandra/install/installRHEL.html

but when try to connect cassandra using python cassandra-driver using this:

from cassandra.cluster import Cluster
def get_cluster_connection_session():
    cluster = Cluster(['127.0.0.1',], port=9042)
    session = cluster.connect()
    return session

it gives me following error:

cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})

1) python --version gives me following output:

Python 2.7.6

2) java -version gives me following output:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

3) sudo service cassandra status gives me:

cassandra (pid  15193) is running...

Do i need to make any changes in cassandra.yaml file? if yes, can you please tell me what changes i need to make in cassandra.yaml file?

So can someone please help me to solve this issue?

Thank you.

Upvotes: 1

Views: 257

Answers (1)

Marko Švaljek
Marko Švaljek

Reputation: 2101

More or less it's all described here:

https://stackoverflow.com/a/34063341/7413631

Follow the steps from the answer and let me know if you're stuck somewhere.

Add the options to cassandra-env.sh file.

JVM_OPTS="$JVM_OPTS -Djava.io.tmpdir=/home/cassandra/tmp"

Also make sure the /home/cassandra/tmp is created and that cassandra process had all the rights on it.

Upvotes: 1

Related Questions