Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra-cli cant connect to remote cassandra server

I have a cassandra server running on a server(serv1). cassandra-cli can connect to it when run on serv1. However, when i try to connect to it through some other server(serv2), i get the following exception:

org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
    at org.apache.thrift.transport.TSocket.open(TSocket.java:183)
    at org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81)
    at org.apache.cassandra.cli.CliMain.connect(CliMain.java:80)
    at org.apache.cassandra.cli.CliMain.main(CliMain.java:256)
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at org.apache.thrift.transport.TSocket.open(TSocket.java:178)
    ... 3 more
Exception connecting to jckstore/9160. Reason: Connection refused.

I looked in cassandra.yaml and found that the property "listen_address" is configured to "localhost" and using 0.0.0.0 is severely discouraged. I tried to change localhost to serv2, ip address of serv1 but nothing worked. Even commenting out didnt help.

Is there a way i can make my cassandra server listen on all the ip's without using 0.0.0.0

like image 246
Chander Shivdasani Avatar asked Jul 25 '12 21:07

Chander Shivdasani


People also ask

How do I access Cassandra remotely?

For security reasons, the Cassandra ports in this solution cannot be accessed over a public IP address. To connect to Cassandra from a different machine, you must open ports 9042, 9160, 7000, 7001 and 7199 for remote access.

What protocol Cqlsh uses to connect to a Cassandra node?

cqlsh is implemented with the Python native protocol driver, and connects to the single specified node.


2 Answers

I was able to solve the problem as following:

  1. changing the rpc_address property in cassandra.yaml to 0.0.0.0 instead of localhost.
  2. set the broadcast_rpc_address property in cassandra.yaml to a value other than 0.0.0.0

Then I can access.

like image 129
Chander Shivdasani Avatar answered Sep 30 '22 16:09

Chander Shivdasani


Cassandra cli uses thrift to connect to Cassandra. The rpc_address decides how the thrift clients can connect to Cassandra. Setting it to 0.0.0.0 will work, but setting it to the hostname of the server and then using the same hostname to connect will also work.

like image 23
Mohit Avatar answered Sep 30 '22 17:09

Mohit