Initializing a multiple node cluster (single data center)
A deployment scenario for a Cassandra cluster with a single data center.
This topic contains information for deploying a Cassandra cluster with a single data center.
- Install Cassandra on each node.
- Choose a name for the cluster.
- Get the IP address of each node.
- Determine which nodes will be seed nodes. (Cassandra nodes use the seed node list for finding each other and learning the topology of the ring.)
- Determine the snitch.
- If using multiple data centers, determine a naming convention for each data center and rack, for example: DC1, DC2 or 100, 200 and RAC1, RAC2 or R101, R102.
- Other possible configuration settings are described in The cassandra.yaml configuration file.
This example describes installing a six node cluster spanning two racks in a single data center. Each node is configured to use the RackInferringSnitch (multiple rack aware) and 256 virtual nodes (vnodes). It is recommended to have more than one seed node per data center.
Suppose you install Cassandra on these nodes:
node0 220.127.116.11 (seed1) node1 18.104.22.168 node2 22.214.171.124 node3 126.96.36.199 (seed2) node4 188.8.131.52 node5 184.108.40.206It is a best practice to have more than one seed node per data center.
- If you have a firewall running on the nodes in your cluster, you must open certain ports to allow communication between the nodes. See Configuring firewall port access.
If Cassandra is running:
$ sudo service cassandra stop
Clear the data:
$ sudo rm -rf /var/lib/cassandra/*
$ ps auwx | grep cassandra $ sudo kill <pid>
Clear the data:
$ cd <install_location> $ sudo rm -rf /var/lib/cassandra/*
- Stop Cassandra:
Modify the following property settings in the
cassandra.yaml file for each node:
- num_tokens: <recommended value: 256>
- -seeds: <internal IP address of each seed node>
- listen_address: <localhost IP address>
- endpoint_snitch: <name of snitch> (See endpoint_snitch.)
- auto_bootstrap: false (Add this setting only when initializing a fresh cluster with no data.)
cluster_name: 'MyDemoCluster' num_tokens: 256 seed_provider: - class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters: - seeds: "220.127.116.11,18.104.22.168" listen_address: 22.214.171.124 rpc_address: 0.0.0.0 endpoint_snitch: RackInferringSnitch
node1 to node5
The properties for these nodes are the same as node0 except for the listen_address.
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.
If the node has restarted because of automatic restart, you must stop the node and clear the data directories, as described above.
For packaged installs, run the following command:
$ sudo service cassandra start
For binary installs, run the following commands:
$ cd <install_location> $ bin/cassandra
To check that the ring is up and running, run the nodetool