Adding a datacenter to a cluster using a designated datacenter as a data source

Add a datacenter to an existing cluster using a designated datacenter as a data source.

Complete the following steps to add a datacenter to an existing cluster using a designated datacenter as a data source. In this procedure, a new datacenter, DC4 is added to an existing cluster with existing datacenters DC1, DC2, and DC3.


  • The cassandra.yaml file is located in the installation_location/conf directory.

  • The file is located in the installation_location/conf directory.


The location of the system.log file is:
  • /var/log/cassandra/system.log

  • The file is located in the installation_location/conf directory.


Important: Complete the prerequisite tasks outlined in Initializing a Cassandra cluster to prepare the environment.


  1. Configure every keyspace using SimpleStrategy to use the NetworkTopologyStrategy replication strategy, including (but not restricted to) the following keyspaces.

    If SimpleStrategy was used previously, this step is required to configure NetworkTopologyStrategy.

    1. Use ALTER KEYSPACEALTER KEYSPACE to change the keyspace replication strategy to NetworkTopologyStrategy for the following keyspaces.
      {'class' : 'NetworkTopologyStrategy', 'ExistingDC1' : 3};
      • All keyspaces created by users
    2. Use DESCRIBE SCHEMA to check the replication strategy of keyspaces in the cluster. Ensure that any existing keyspaces use the NetworkTopologyStrategy replication strategy.
  2. In the new datacenter, install Cassandra on each new node. Do not start the service or restart the node.
    Important: Use the same version of DDAC on all nodes in the cluster.
  3. Configure properties in cassandra.yaml on each new node, following the configuration of the other nodes in the cluster.
    1. Configure node properties:
    2. Configure node architecture (all nodes in the datacenter must use the same type):

      Virtual node (vnode) allocation algorithm settings

      For more information, refer to Virtual node (vnode) configuration.

      Single-token architecture settings

  4. In the (GossipingPropertyFileSnitch) or (PropertyFileSnitch) file, assign datacenter and rack names to the IP addresses of each node, and assign a default datacenter name and rack name for unknown nodes.
    Note: Migration information: The GossipingPropertyFileSnitch always loads when the file is present. Remove the file from each node on any new cluster, or any cluster migrated from the PropertyFileSnitch.
    # Transactional Node IP=Datacenter:Rack
    # default for unknown nodes
    Note: After making any changes in the configuration files, you must the restart the node for the changes to take effect.
  5. Make the following changes in the existing datacenters.
    1. On nodes in the existing datacenters, update the -seeds property in cassandra.yaml to include the seed nodes in the new datacenter.
    2. Add the new datacenter definition to the cassandra.yaml properties file for the type of snitch used in the cluster. If changing snitches, see Switching snitches.
  6. After you have installed and configured Cassandra on all nodes, start the seed nodes one at a time, and then start the rest of the nodes:
  7. Run nodetool status to ensure that new datacenter is up and running.
    installation_location/bin/nodetool status
    Datacenter: DC1
    |/ State=Normal/Leaving/Joining/Moving
    --  Address         Load       Owns    Host ID                               Token                     Rack
    UN   474.23 KiB  ?       7297d21e-a04e-4bb1-91d9-8149b03fb60a  -9223372036854775808     rack1
    Datacenter: DC2
    |/ State=Normal/Leaving/Joining/Moving
    --  Address         Load       Owns    Host ID                               Token                     Rack
    UN  518.36 KiB  ?       2ff7d46c-f084-477e-aa53-0f4791c71dbc  -9223372036854775798     rack1
    Datacenter: DC3
    |/ State=Normal/Leaving/Joining/Moving
    --  Address         Load       Owns    Host ID                               Token                     Rack
    UN  961.56 KiB  ?       ac43e602-ef09-4d0d-a455-3311f444198c  -9223372036854775788     rack1
    Datacenter: DC4
    |/ State=Normal/Leaving/Joining/Moving
    --  Address         Load       Owns    Host ID                               Token                     Rack
    UN  361.56 KiB  ?       ac43e602-ef09-4d0d-a455-3322f444198c  -9223372036854775688     rack1
  8. After all nodes are running in the cluster and the client applications are datacenter aware, use cqlsh to alter the keyspaces to add the desired replication in the new datacenter.
    {'class' : 'NetworkTopologyStrategy', 'ExistingDC1' : 3, 'NewDC2' : 2};
    Warning: If client applications, are not properly configured, they might connect to the new datacenter before it is online. Incorrect configuration results in connection exceptions, timeouts, and/or inconsistent data.
  9. Run nodetool rebuild on each node in the new datacenter, specifying the corresponding datacenter/rack from the source datacenter.
    installation_location/bin/nodetool rebuild -dc source_datacenter_name:source_datacenter_rack_name
    The following commands replicate data from an existing datacenter DC1 to the new datacenter DC2 on each DC2 node. The rack specifications correspond with the rack specifications in DC1:
    On DC2:RACK1 nodes run:
    installation_location/bin/nodetool rebuild -dc DC1:RACK1
    On DC2:RACK2 nodes run:
    installation_location/bin/nodetool DC1:RACK2
    On DC2:RACK3 nodes run:
    installation_location/bin/nodetool rebuild -dc DC1:RACK3
    1. Use installation_location/bin/nodetool rebuild -dc on one or more nodes at the same time. Run on one node at a time to reduce the impact on the source datacenter.
    2. Alternatively, run the command on multiple nodes simultaneously when the cluster can handle the extra I/O and network pressure.
      Rebuild can be safely run in parallel, but has potential performance tradeoffs. The nodes in in the source datacenter will be streaming data, so application performance involving that datacenter's data will be potentially impacted. Run tests within a the environment, adjusting various levels of parallelism and streaming throttling to strike the optimal balance of speed and performance.
  10. Monitor the rebuild progress for the new datacenter using installation_directory/bin/nodetool netstats and examining the size of each node.
    The nodetool rebuild command issues a JMX call to the node and waits for rebuild to finish before returning to the command line. Once the JMX call is invoked, the rebuild process will continue on the server regardless of the nodetool rebuild process (the rebuild will continue to run if nodetool dies.) There is not typically significant output from the nodetool rebuild command itself. Instead, rebuild progress should be monitored via nodetool netstats, as well as examining the data size of each node.
    Note: The data load shown in nodetool status will only be updated after a given source node is done streaming, so it will appear to lag behind bytes reported on disk (e.g. du). If any streaming errors occur, ERROR messages will be logged to system.log and the rebuild will stop. In the event of temporary failure, nodetool rebuild can be re-run and skips any ranges that were already successfully streamed.
  11. Adjust stream throttling on the source datacenter as required to balance out network traffic. See nodetool setstreamthroughput.
  12. Confirm that all rebuilds are successful by searching for finished rebuild in the system.log of each node in the new datacenter.
    Note: In rare cases the communication between two streaming nodes may hang, leaving the rebuild operation alive but with no data streaming. Monitor streaming progress using nodetool netstats, and, if the streams are not making any progress, restart the node where nodetool rebuild was executed and re-run nodetool rebuild with the same parameters used originally.