Installing Apache Cassandra 3-Node Cluster
Setup
Server | IP Address | Seed Node |
---|---|---|
cassandra-1 | 192.168.50.37 | seed node |
cassandra-2 | 192.168.50.38 | |
cassandra-3 | 192.168.50.39 |
Package | Version | Install Location |
---|---|---|
Apache Cassandra | 4.0.0 | /opt/apache-cassandra-4.0.0/ |
Java | jdk1.8.0_241 | /opt/jdk1.8.0_241 |
Python | python-2.7.5-76.el7.x86_64 | /usr/bin/python |
Prerequisites
Follow the steps in below document to complete Cassandra install
How to Install Cassandra Software
Cluster Configuration
- Update the cassandra configuration file for setting up 3-node cluster
- Update the cassandra rack properties file to use custom datacenter name
# vi /opt/apache-cassandra-4.0.0/conf/cassandra.yaml
Node-1 Configuration
cluster_name: 'LTS Cluster'
num_tokens: 256
seeds: "192.168.50.37"
listen_address: 192.168.50.37
rpc_address: 192.168.50.37
endpoint_snitch: GossipingPropertyFileSnitch
Node-2 Configuration
cluster_name: 'LTS Cluster'
num_tokens: 256
seeds: "192.168.50.37"
listen_address: 192.168.50.38
rpc_address: 192.168.50.38
endpoint_snitch: GossipingPropertyFileSnitch
Node-3 Configuration
cluster_name: 'LTS Cluster'
num_tokens: 256
seeds: "192.168.50.37"
listen_address: 192.168.50.39
rpc_address: 192.168.50.39
endpoint_snitch: GossipingPropertyFileSnitch
Use the same parameters on all three nodes
# vi /opt/apache-cassandra-4.0.0/conf/cassandra-rackdc.properties
dc=LTS-DC1
rack=rack1
Start Cassandra Service
# systemctl start cassandra
# systemctl status cassandra
Node-1 output
cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/rc.d/init.d/cassandra; bad; vendor preset: disabled)
Active: active (running) since Sun 2021-08-22 21:26:26 EDT; 2min 28s ago
Docs: man:systemd-sysv-generator(8)
Process: 3955 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=0/SUCCESS)
Main PID: 4040 (java)
CGroup: /system.slice/cassandra.service
4040 /opt/jdk1.8.0_241/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+AlwaysPreTouch -...
Aug 22 21:26:17 cassandra-1.linuxtechspace.com systemd[1]: Starting LSB: distributed storage system for structured data...
Aug 22 21:26:17 cassandra-1.linuxtechspace.com runuser[3963]: pam_unix(runuser:session): session opened for user cassandra by (uid=0)
Aug 22 21:26:26 cassandra-1.linuxtechspace.com cassandra[3955]: Starting Cassandra: OK
Aug 22 21:26:26 cassandra-1.linuxtechspace.com systemd[1]: Started LSB: distributed storage system for structured data.
Node-2 output
cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/rc.d/init.d/cassandra; bad; vendor preset: disabled)
Active: active (running) since Sun 2021-08-22 21:27:02 EDT; 1min 59s ago
Docs: man:systemd-sysv-generator(8)
Process: 4874 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=0/SUCCESS)
Main PID: 4959 (java)
CGroup: /system.slice/cassandra.service
4959 /opt/jdk1.8.0_241/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+AlwaysPreTouch -...
Aug 22 21:26:55 cassandra-2.linuxtechspace.com systemd[1]: Starting LSB: distributed storage system for structured data...
Aug 22 21:26:55 cassandra-2.linuxtechspace.com runuser[4882]: pam_unix(runuser:session): session opened for user cassandra by (uid=0)
Aug 22 21:27:02 cassandra-2.linuxtechspace.com cassandra[4874]: Starting Cassandra: OK
Aug 22 21:27:02 cassandra-2.linuxtechspace.com systemd[1]: Started LSB: distributed storage system for structured data.
Node-3 output
cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/rc.d/init.d/cassandra; bad; vendor preset: disabled)
Active: active (running) since Sun 2021-08-22 21:35:42 EDT; 59s ago
Docs: man:systemd-sysv-generator(8)
Process: 5195 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=0/SUCCESS)
Main PID: 5278 (java)
CGroup: /system.slice/cassandra.service
5278 /opt/jdk1.8.0_241/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:+AlwaysPreTouch -...
Aug 22 21:35:41 cassandra-3.linuxtechspace.com systemd[1]: Starting LSB: distributed storage system for structured data...
Aug 22 21:35:41 cassandra-3.linuxtechspace.com runuser[5201]: pam_unix(runuser:session): session opened for user cassandra by (uid=0)
Aug 22 21:35:42 cassandra-3.linuxtechspace.com cassandra[5195]: Starting Cassandra: OK
Aug 22 21:35:42 cassandra-3.linuxtechspace.com systemd[1]: Started LSB: distributed storage system for structured data.
# /opt/apache-cassandra-4.0.0/bin/nodetool status
Datacenter: LTS-DC1
===================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 192.168.50.37 78.51 KiB 256 66.0% d087f297-9a23-4971-bfa9-2226db8d8253 rack1
UN 192.168.50.38 73.53 KiB 256 60.0% 44791886-46c0-43f2-ba37-3d0a37e0dbd2 rack1
UN 192.168.50.39 191.46 KiB 256 74.0% fe151fce-868b-43f0-81f3-a32cc1f1f2d1 rack1