top of page

Cassandra Cluster With Single Seed Node

Cassandra Cluster


The cluster is a collection of nodes that represents a single system. In this tutorial, we'll be going to put some highlights on Cassandra Cluster and its working. By default, every stand-alone Cassandra server act as a Single-Node Cassandra cluster. Here, We'll be going to set up the nodes to function in Multi-Node Cassandra Cluster.


So before we start let's get the existing dataset clear from the Single-Node cluster.


1. Deleting Default Data


On Node 1.

[root@siddhesh ~]# service cassandra stop

[root@siddhesh ~]# rm -rf /var/lib/cassandra/data/system/*

2. Set Cluster Configuration


On Node 1.

[root@siddhesh ~]# vim /etc/cassandra/cassandra.yaml

cluster_name: 'BuildDevOps'
num_tokens: 256
seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
         - seeds: "192.168.56.1,192.168.56.2"
listen_address: 192.168.56.1
rpc_address: 192.168.56.1
endpoint_snitch: GossipingPropertyFileSnitch

Here

[192.168.56.1 is primary node1 & 192.168.56.2 is secondary node2]

[cluster_name : All nodes of this cluster should have a common name]

[num_tokens : Starting point of the cluster from where the date gets spread throughout the cluster]

[seeds : IP address of Nodes]

[listen_address : the IP address that Cassandra service will bind to]

[rpc_address] : IP address that Cassandra will listen for a client]



3. Copy the same configuration parameters on Node2 except listen_address & rpc_address.

This two-parameter will have a Node2 IP address ie 192.168.56.2


4. Make sure to allow the following network ports for each node.


7000 : TCP port for command and data

9042 : cqlsh, Cassandra command lint utility will connect to the cluster through this port.


5. Start Cassandra service & Check cluster status

 [root@siddhesh ~]# nodetool status 
Datacenter: TecgeekCluster
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address      Load       Tokens       Owns    Host ID                               Rack
UN  192.168.56.1  347.48 KB  256          ?       f50733ee-8689-4cg4-a0c8-241cd873e434  rack1
UN  192.168.56.2  339.48 KB  256          ?       22b34af1-ad0a-4255-b34e-cacab39caette  rack1
 [root@siddhesh ~]#

Here

[UN : is UpNode, if node is down/fail then you can DN]

[Load : Amount of data in data directory]

[Owns : The percentage of the data own by node]

[Rack : The rack or availability zone of node]

[Host ID : The Network ID of Host]


6. You can also connect to any cluster node using cqlsh.

 [root@siddhesh ~]# cqlsh 192.168.56.2 9042
Connected to My DO Cluster at 192.168.56.2:9042.
[cqlsh 5.0.1 | Cassandra 2.2.3 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
cqlsh>exit
[root@siddhesh ~]#








bottom of page