1

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.

Nikunj
  • 33
  • 9
  • did you try a telnet? `telnet 127.0.0.1 9042` connection refused already tells you that there is something listening on that port but didn't accept the connection. – questionaire Apr 17 '17 at 11:50
  • 1
    can you run `nodetool status` just to see what's going on with your cluster. – Marko Švaljek Apr 17 '17 at 11:56
  • @questionare, I have tried telnet `127.0.0.1 9042` which gives me following output: ` Trying 127.0.0.1... ' ' telnet: connect to address 127.0.0.1: Connection refused ' – Nikunj Apr 17 '17 at 11:56
  • @MarkoŠvaljek Somehow **nodetool status** is not working.. gives me following output: ` Error: The node does not have system_traces yet, probably still bootstrapping' – Nikunj Apr 17 '17 at 12:01
  • do you see something in the system.log of cassandra? It looks like your instance might not have even started. – Marko Švaljek Apr 17 '17 at 12:02
  • System.log gives me this: ` ERROR [MemtableFlushWriter:2] 2017-04-17 11:56:21,521 CassandraDaemon.java:205 - Exception in thread Thread[MemtableFlushWriter:2,5,main] java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native at org.apache.cassandra.utils.memory.MemoryUtil.allocate(MemoryUtil.java:97) ~[apache-cassandra-3.0.9.jar:3.0.9] at org.apache.cassandra.io.util.Memory.(Memory.java:74) ~[apache-cassandra-3.0.9.jar:3.0.9] at org.apache.cassandra.io.util.SafeMemory.(SafeMemory.java:32) ~[apache-cassandra-3.0.9.jar:3.0.9] – Nikunj Apr 17 '17 at 12:11

1 Answers1

1

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.

Community
  • 1
  • 1
Marko Švaljek
  • 2,071
  • 1
  • 14
  • 26
  • thanks it works. but still i am not able to open **cqlsh**.. it gives me following error. Traceback (most recent call last): File "/usr/bin/cqlsh.py", line 163, in from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling ImportError: No module named cqlshlib – Nikunj Apr 17 '17 at 12:44
  • http://stackoverflow.com/questions/35197362/unable-to-open-cqlsh-apache-cassandra-importerror-no-module-named-cqlshlib sorry for delay had to take care of the baby ;) – Marko Švaljek Apr 17 '17 at 13:30
  • sorry for late reply. i have gone through the link you gave but when i installed **cqlsh** using **pip install cqlsh**. cqlsh is open but not able to connect to any servers, giving me same error which i was getting earlier. but without **cqlsh**, cassandra working fine. i can Insert data to tables. but still **cqlsh** issue is there. do i need to restart the cassandra after installation? because i have stopped cassandra service and again started the service after installation. – Nikunj Apr 18 '17 at 10:31
  • If Cassandra is running then cqlsh should also be able to connect. So basically even after installing the `cqlsh` you are getting `No module named cqlshlib`. Hm I would try to restart the whole machine then, But just as a confirmation the error is still 100% the same? Can you provide how you are using cqlsh i.e. command line call? – Marko Švaljek Apr 18 '17 at 11:13
  • No i not getting error `No module named cqlshlib`. i am getting `Unable to connect to any servers`. and to start `cqlsh` , i am just writing `cqlsh` in command prompt. – Nikunj Apr 18 '17 at 11:22
  • Can you try to go to folder where you installed cassandra and just run `./bin/cqlsh` .... just to see what happens? – Marko Švaljek Apr 18 '17 at 11:27
  • Sorry i forgot to tell you temporary i have uninstalled `cqlsh` , which i have installed using `pip install cqlsh`, because i am working on some other part of project, i just need to insert data into cassandra tables and i am getting those inserted data by API. but as you said, i have tried top open cassandra command line by writing `cqlsh`. but it gives me following error: `Traceback (most recent call last): File "/usr/bin/cqlsh.py", line 163, in from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling ImportError: No module named cqlshlib` – Nikunj Apr 18 '17 at 11:46
  • I guess you'll have to go then and check the answers out: http://stackoverflow.com/questions/35197362/unable-to-open-cqlsh-apache-cassandra-importerror-no-module-named-cqlshlib but then again if it works for the scope that you need (app usage) I'm guessing you are good then ;) Anyway thanks, just wanted to follow up – Marko Švaljek Apr 18 '17 at 11:48
  • yeah Marko, its working fine for me right now. and thank you very much for your help as you saved my lots of time. and i will get back to you on this topic, if i need your help. thanks again :) – Nikunj Apr 18 '17 at 11:53