ilapasle
ilapasle

Reputation: 349

Cassandra client connection to multiple addresses

I have a question about Cassandra. Is it possible to open Cassandra client connection on many IPs?

On my server I have 2 network cards (eth0 and eth1) with IP 10.197.11.21 (eth0) and 192.168.0.45 (eth1) and 127.0.0.1 (lo).

I want my client to connect to Cassandra database with this three IP in localhost, 10.197.11.21 and 192.168.0.45

For the moment I can choose only 1 IP, what does it do to modify in the file cassandra.yaml ?

Upvotes: 1

Views: 1239

Answers (1)

Justin Cameron
Justin Cameron

Reputation: 611

You need to set rpc_address: 0.0.0.0 in cassandra.yaml

Note that when you set rpc_address to 0.0.0.0, you also must set broadcast_rpc_address to something other than 0.0.0.0 (e.g. 10.197.11.21).

  • rpc_address is the address that Cassandra listens on for connections from clients
  • listen_address is the address that Cassandra listens on for connections from other Cassandra nodes (not client connections)
  • broadcast_rpc_address is the address that Cassandra broadcasts to clients that are attempting to discover the other nodes in the cluster. When an application first connects to a Cassandra cluster, the cluster sends the application a list of all the nodes in the cluster, and their IP addresses. The IP address sent to the application is the broadcast_ip_address (side-note: cassandra actually sends all IP addresses, this is just the one that it tells the client to connect on). This allows the application to auto-discover all the nodes in the cluster, even if only one IP address was given to the application. This also allows applications to handle situations like a node going offline, or new nodes being added.

Even though your broadcast_rpc_address can only point to one of those two IP addresses, you application can still connect to either one. However, your application will also attempt to connect to other nodes via the broadcast_rpc_addresses sent back by the cluster. You can get around this by providing a full list of the address of every node in the cluster to your application, but the best solution is to build a driver-side address translator.

Upvotes: 1

Related Questions