Initializing a multiple node cluster (multiple datacenters)
This example describes installing a six node cluster spanning two datacenters. Each node is configured to use the GossipingPropertyFileSnitch (multiple rack aware) and 256 virtual nodes (vnodes).
In Cassandra, "datacenter" is synonymous with "replication group". Both terms refer to a set of nodes configured as a group for replication purposes.
ubuntu-c-4-8gib-blr1-01 159.65.157.45 (seed1)
cassandra_cluster_monitoring_001 34.227.26.121
cassandra_cluster_monitoring_002 34.239.132.58
cassandra_cluster_monitoring_003 34.226.139.41 (seed2)
cassandra_cluster_monitoring_004 52.90.90.172
Stop the service and clear the data
Doing this removes the default cluster_name (Test Cluster) from the system table. All nodes must use the same cluster name.
sudo service cassandra stop
sudo rm -rf /var/lib/cassandra/data/system/*
Set the properties in the cassandra.yaml file for each node
sudo vim /etc/cassandra/cassandra.yaml
cluster_name: 'MyCassandraCluster'
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "159.65.157.45,34.226.139.41"
listen_address: private_ip
broadcast_address: public_ip
rpc_address: public_ip
endpoint_snitch: GossipingPropertyFileSnitch
Note: Include at least one node from each datacenter in the seeds list.
Assign the datacenter and rack names in cassandra-rackdc.properties
sudo vim /etc/cassandra/cassandra-rackdc.properties
Nodes 0 to 2
dc=DC1
rack=RAC1
Nodes 3 to 4
dc=DC2
rack=RAC1
Remove cassandra-topology.properties from each node
The GossipingPropertyFileSnitch always loads cassandra-topology.properties when that file is present. Remove the file from each node on any new cluster or any cluster migrated from the PropertyFileSnitch
sudo rm /etc/cassandra/cassandra-topology.properties
Start Cassandra on the nodes
DataStax recommends starting the seed nodes one at a time, and then starting the rest of the nodes
sudo service cassandra start