Update Topology Strategy From Simple to Network

The following procedure specifies how to update the replication strategy from SimpleStrategy to NetworkTopologyStrategy. Note that SimpleStrategy is not recommended for production usage, and it is strongly advised to create new clusters with NetworkTopologyStrategy.

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

  • Nodes are all on the same rack (can be updated without downtime)

  • 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', '<existing_dc>' : 3};

After

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

To complete the process, you need to change the snitch, edit the cassandra-rackdc.properties file, and set the preferred 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 cluster

  3. Alter the strategy as detailed above

  4. Run a second full repair

  5. Run nodetool cleanup on each node

  6. Resume traffic

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