From Fedora Project Wiki

(Created page with "This page contains example cluster setup for Apache Cassandra. == 2-node Cassandra cluster ==")
 
No edit summary
Line 2: Line 2:


== 2-node Cassandra cluster ==
== 2-node Cassandra cluster ==
The Cassandra main configuration file ''/etc/cassandra/cassandra.yaml'' needs to be edited to setup the cluster. The options that you have to modify are:
{| class="wikitable"
|-
! Option !! Description
|-
| cluster_name || Name of your cluster. '''Must be same on all nodes'''.
|-
| num_tokens || Number of virtual nodes within a Cassandra instance. This is used to partition the data and spread the data throughout the cluster. The recommended value is 256.
|-
| seeds || Comma-delimited list of the IP address of each node in the cluster.
|-
| listen_address || The IP address or hostname that Cassandra binds to for connecting to other Cassandra nodes. It defaults to localhost and needs to be changed to the IP address of the node.
|-
| rpc_address || The listen address for client connections (CQL protocol).
|-
| endpoint_snitch || Set to a class that implements the IEndpointSnitch. Cassandra uses snitches for locating nodes and routing requests. The default one is SimpleSnitch but we will change to GossipingPropertyFileSnitch which is more suitable for production environments.
|-
| auto_bootstrap || This parameter is not present in the configuration file, so it has to be added and set to false. It makes new (non-seed) nodes automatically migrate the right data to themselves.
|}
Node 1 with IP address 10.0.0.1 edit/add options to ''/etc/cassandra/cassandra.yaml'':
<pre>
num_tokens: 256
seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: 10.0.0.1, 10.0.0.2
listen_address: 10.0.0.1
rpc_address: 10.0.0.1
endpoint_snitch: GossipingPropertyFileSnitch
auto_bootstrap: false
</pre>
Node 2 with IP address 10.0.0.2 edit/add options to ''/etc/cassandra/cassandra.yaml'':
<pre>
num_tokens: 256
seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: 10.0.0.1, 10.0.0.2
listen_address: 10.0.0.2
rpc_address: 10.0.0.2
endpoint_snitch: GossipingPropertyFileSnitch
auto_bootstrap: false
</pre>
{{admon/note|Note:|If you use firewall, remember to [[Apache Cassandra#Ports and remote access|open ports]].}}
On both nodes create file ''/etc/cassandra/cassandra-rackdc.properties'':
<pre>
dc=DC1
rack=RAC1
</pre>
Now you can start cluster, on both nodes start cassandra:
<pre>
systemctl start cassandra
</pre>
You should see cluster status and joined nodes with client tools:
<pre>
$ nodetool status
</pre>

Revision as of 15:26, 16 May 2018

This page contains example cluster setup for Apache Cassandra.

2-node Cassandra cluster

The Cassandra main configuration file /etc/cassandra/cassandra.yaml needs to be edited to setup the cluster. The options that you have to modify are:

Option Description
cluster_name Name of your cluster. Must be same on all nodes.
num_tokens Number of virtual nodes within a Cassandra instance. This is used to partition the data and spread the data throughout the cluster. The recommended value is 256.
seeds Comma-delimited list of the IP address of each node in the cluster.
listen_address The IP address or hostname that Cassandra binds to for connecting to other Cassandra nodes. It defaults to localhost and needs to be changed to the IP address of the node.
rpc_address The listen address for client connections (CQL protocol).
endpoint_snitch Set to a class that implements the IEndpointSnitch. Cassandra uses snitches for locating nodes and routing requests. The default one is SimpleSnitch but we will change to GossipingPropertyFileSnitch which is more suitable for production environments.
auto_bootstrap This parameter is not present in the configuration file, so it has to be added and set to false. It makes new (non-seed) nodes automatically migrate the right data to themselves.

Node 1 with IP address 10.0.0.1 edit/add options to /etc/cassandra/cassandra.yaml:

num_tokens: 256
seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: 10.0.0.1, 10.0.0.2
listen_address: 10.0.0.1
rpc_address: 10.0.0.1
endpoint_snitch: GossipingPropertyFileSnitch
auto_bootstrap: false

Node 2 with IP address 10.0.0.2 edit/add options to /etc/cassandra/cassandra.yaml:

num_tokens: 256
seed_provider:
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          - seeds: 10.0.0.1, 10.0.0.2
listen_address: 10.0.0.2
rpc_address: 10.0.0.2
endpoint_snitch: GossipingPropertyFileSnitch
auto_bootstrap: false
Note:
If you use firewall, remember to open ports.

On both nodes create file /etc/cassandra/cassandra-rackdc.properties:

dc=DC1
rack=RAC1

Now you can start cluster, on both nodes start cassandra:

systemctl start cassandra

You should see cluster status and joined nodes with client tools:

$ nodetool status