Update Topology Strategy From Simple to Network

The following procedure specifies how to update the replication stratagy from SimpleStrategy to NetworkTopologyStrategy. Note that SimpleStrategy is not recomendded for production usage, and its is strongly advise to create a new clusters with NetworkTopologyStrategy.

In case, you are using SimpleStrategy, there are two there are two alternatives:

  • Nodes are all on the same rack (can be update without down time)

  • Nodes are on different racks (requires full shutdown)

To check which node is on which rack, use nodetool status

All nodes are on the same rack

Alter each Keyspace replication to use class : NetworkTopologyStrategy and set the new DC replication factor to zero. This will prevent writing to the new DC until explicitly enabled.

Alter the following:

  • Keyspace created by the user.

  • System: system_auth, system_distributed, system_traces.

For example:

Before

DESCRIBE KEYSPACE mykeyspace;
CREATE KEYSPACE mykespace WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '3'};

ALTER Command

ALTER KEYSPACE mykespace WITH replication = { 'class' : 'NetworkTopologyStrategy', '<exiting_dc>' : 3};

After

DESCRIBE KEYSPACE mykeyspace;
CREATE KEYSPACE mykespace WITH replication = { 'class' : 'NetworkTopologyStrategy', '<exiting_dc>' : 3};

To complete the process, you need to change the Snitch and set the edit the cassandra-rackdc.properties file with the prefered data-center name.

Nodes are on different racks

This is a more complex scenario, as the new strategy may select different replicas depending if the nodes are on different racks. To fix that you will need a full shutdown of the cluster.

  1. Stop traffic to all nodes (using nodetool drain)

  2. Run full repair on the clutser

  3. Alter the stratagy as detailed above

  4. Run a second full repair

  5. Run node cleanup on each node

  6. Resume traffic

To complete the process, you need to change the Snitch and set the edit the cassandra-rackdc.properties file with the prefered data-center name.