Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to cassandra node from different host

I have a cassandra node at a machine. When I access cqlsh from the same machne it works properly.

But when I tried to connect to it's cqlsh using "192.x.x.x" from another machine, I'm getting an error saying

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

What is the reason for this? How can I fix it?

like image 345
Chamila Wijayarathna Avatar asked Jan 03 '15 19:01

Chamila Wijayarathna


People also ask

How do I connect to 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.

How Cassandra nodes communicate with each other?

In Cassandra all nodes communicating with each other via a gossip protocol. Gossip is the message system that Cassandra node use to make their data consistent with each other.

How do I change a Cassandra node?

You can replace a running node in two ways: Adding a node and then decommissioning the old node. Using nodetool to replace a running node.


1 Answers

Probably the remote Cassandra node is not bound to the external network interface but to the loopback one (this is the default configuration). You can ensure this by using "telnet thecassandrahost 9042" from the remote machine, it should not work.

In order to bind Cassandra to the external network interface you need to edit the cassandra.yaml configuration file and set the properties "listen_address" and "rpc_address" to your remote IP or "0.0.0.0" (not all versions of Cassandra support wildcard addresses).

Check also that the firewall is properly configured or disabled (sudo service iptables stop).

like image 93
Nicola Ferraro Avatar answered Sep 28 '22 09:09

Nicola Ferraro