2

I am totally new to Cassandra and met the following error when using cqlsh:

cqlsh

Connection error: Could not connect to localhost:9160

I read the solutions from the following link and tried them all. But none of them works for me.

How to connect Cassandra to localhost using cqlsh?

I am working on CentOS6.5 and installed Cassandra2.0 using yum intall dsc20.

Community
  • 1
  • 1
Chunkun
  • 21
  • 1
  • 3

2 Answers2

4

I ran into the same issue running the same OS and same install method. While the cassandra service claims that it's starting ok, if you run service cassandra status it would tell me that the process was dead. Here are the steps I took to fix it:

Viewing the log file at /var/log/cassandra/cassandra.log gave told me that my heap size was too small. Manually set the heap size in /etc/cassandra/conf/cassandra-env.sh:

MAX_HEAP_SIZE="1G"
HEAP_NEWSIZE="256M"

Tips on setting the heap size for your system can be found here

Next, the error log claimed the stack size was too small. Once again in /etc/cassandra/conf/cassandra-env.sh find a line that looks like JVM_OPTS="$JVM_OPTS -Xss128k" and raise that number to JVM_OPTS="$JVM_OPTS -Xss256k"

Lastly, the log complained that the local url was misformed and threw a java exception. I found the answer to the last part here. Basically, you want to manually bind your server's hostname in your /etc/hosts file.

127.0.0.1   localhost localhost.localdomain server1.example.com

Hope this helps~

Community
  • 1
  • 1
Chuck
  • 196
  • 1
  • 6
1

Change:

/etc/cassandra/cassandra.yaml

Whether to start the thrift rpc server.

start_rpc: false

to

start_rpc: true

Community
  • 1
  • 1
Hall Newman
  • 111
  • 1
  • 1