Adding a datacenter to a cluster
Steps for adding a datacenter to an existing cluster.
Steps for adding a datacenter to an existing cluster.
The location of the cassandra.yaml file depends on the type of
installation:
Package installations | /etc/cassandra/cassandra.yaml |
Tarball installations | install_location/resources/cassandra/conf/cassandra.yaml |
Procedure
Be sure to install the same version of Cassandra as is
installed on the other nodes in the cluster. .
- Ensure that you are using NetworkTopologyStrategy for all of your keyspaces.
-
For each node, set the following properties in the
cassandra.yaml file:
-
Update the relevant property file for snitch used on all servers to include the
new nodes. You do not need to restart.
- GossipingPropertyFileSnitch: cassandra-rackdc.properties
- PropertyFileSnitch: cassandra-topology.properties
-
Ensure that your clients are configured correctly for the new cluster:
- If your client uses the DataStax Java, C#, or Python driver, set the
load-balancing policy to
DCAwareRoundRobinPolicy
(Java, C#, Python). - If you are using another client such as Hector, make sure it does not
auto-detect the new nodes so that they aren't contacted by the client until
explicitly directed. For example if you are using Hector, use
sethostConfig.setAutoDiscoverHosts(false);
. If you are using Astyanax, useConnectionPoolConfigurationImpl.setLocalDatacenter("<data center name">)
to ensure you are connecting to the specified datacenter. - If you are using Astyanax 2.x, with integration with the DataStax Java
Driver 2.0, you can set the load-balancing policy to
DCAwareRoundRobinPolicy
by callingJavaDriverConfigBuilder.withLoadBalancingPolicy()
.AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder() ... .withConnectionPoolConfiguration(new JavaDriverConfigBuilder() .withLoadBalancingPolicy(new TokenAwarePolicy(new DCAwareRoundRobinPolicy())) .build()) ...
- If your client uses the DataStax Java, C#, or Python driver, set the
load-balancing policy to
- If using a QUORUM consistency level for reads or writes, check the LOCAL_QUORUM or EACH_QUORUM consistency level to see if the level meets your requirements for multiple data centers.
- Start Cassandra on the new nodes.
-
After all nodes are running in the cluster:
-
Change to true or remove auto_bootstrap: false in the cassandra.yaml
file.
Returns this parameter to its normal setting so the nodes can get all the data from the other nodes in the datacenter if restarted.