1

The Environment:

Nodes: 5
Replication: 5
Consistency: 1

The code:

using System;
using Cassandra;

    namespace CassandraSelectTest
    {
        class Program
        {
            static void Main(string[] args)
            {
                var cluster = Cluster.Builder()
                .AddContactPoints("192.168.0.18","192.168.0.21","192.168.0.22","192.168.0.23","192.168.0.24")
                .WithPort(9042)
                .Build();

                var session = cluster.Connect("test_keyspace");

                var results = session.Execute("SELECT * FROM test_table");

                foreach(var result in results)
                {
                    Console.WriteLine(result.GetValue<string>("col1"));
                }

                Console.WriteLine($"Finished");
                Console.ReadKey();
            }
        }
    }

The problem:

Some of the nodes ideally need to be highly portable, which results in the IP address of the node changing when it is in a different location, and then changing back to its normal IP address when back to its original location. This happens a few times a week.


The question:

Is it possible to configure a single node to have multiple IP addresses, or dynamic addresses which change automatically?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
oshirowanen
  • 15,297
  • 82
  • 198
  • 350

1 Answers1

3

I think that in that scenario the driver will receive a protocol event which will make the driver refresh the cluster's topology. As long as the node's IP is up to date in system.peers table, i.e., you update broadcast_rpc_address / rpc_address / listen_address on the node's cassandra.yml the driver should be able to notice that the old IP is no longer in that table (which will remove the old host) and that there's a new IP (which will add a new host).

If the control connection is not able to reconnect to any of the IPs on the local metadata cache (e.g. if all the nodes go down and change their IP addresses at the same time) then the driver will not be able to reconnect. There's this open ticket which will resolve this issue as long as the user provides hostnames as the contact points (and DNS resolution returns the updated IPs).

João Reis
  • 712
  • 3
  • 9
  • > (you update `broadcast_rpc_address` / `rpc_address` / `listen_address` on the node's cassandra.ym) So if 1 node's IP address changes, do I have to update the cassandra.yml file on all nodes, or just that 1 single node which has had it's IP address changed? – oshirowanen Nov 13 '19 at 17:24
  • you will need to update the seed list in `cassandra.yaml` if any other node had the old IP address. This is not a hard requirement if you have other IP's that are reachable in that list – Carlos Monroy Nieblas Nov 13 '19 at 20:16
  • The specific settings that I mentioned are for the single node which had its IP change but like Carlos said it's a different story if that node is also used as a seed in other nodes' yml files. – João Reis Nov 13 '19 at 23:47
  • I think I need a different distributed database in that case. Any recommendations? – oshirowanen Nov 15 '19 at 09:17
  • Do you have the possibility of using hostnames and having DNS resolve these hostnames to the correct IP? In that case you wouldn't have to change `cassandra.yaml` files I think. – João Reis Nov 15 '19 at 15:12
  • @JoãoReis, Don't think that can be an option unfortunately. Back to the drawing board. – oshirowanen Nov 17 '19 at 16:51