How to Install & Configure Apache Cassandra on Ubuntu 20.04

Apache Cassandra is a free & open-source NoSQL management system database engine.It is used for storing large amounts of data.It helps to manage large amounts of data with dynamic replication.Apache Cassandra provides high availability with no single point of failure.

Install Apache Cassandra on Ubuntu

Update the System.

apt-get update

Install Java.

apt-get install openjdk-11-jdk 

Check Java version.

java -version

Here is the command output.

openjdk version "11.0.11"
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

Install required packages.

apt-get install apt-transport-https

Add repo & Key.

wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
&
sh -c 'echo "deb http://www.apache.org/dist/cassandra/debian 311x main" >
 /etc/apt/sources.list.d/cassandra.list'

Update the packages.

apt-get update

Install Apache Cassandra.

apt-get install cassandra

Check Apache Cassandra status.

systemctl status cassandra

Here is the command output.

● cassandra.service - LSB: distributed storage system for structured data
     Loaded: loaded (/etc/init.d/cassandra; generated)
     Active: active (exited) ; 12s ago
       Docs: man:systemd-sysv-generator(8)

Check the status of running node .

nodetool status

Here is the command output.

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                Rack
UN  127.0.0.1  70.71 KiB  256          100.0%            baf88d--aa50-baedb4ee  rack1

Log in to Cassandra.

cqlsh

Here is the command output.

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.9 | CQL spec 3.4.4 | Native protocol v4]
 Use HELP for help.
 cqlsh> 

Change Cluster Name.

UPDATE system.local SET cluster_name = 'Cluster-name' WHERE KEY = 'local';

Quit from the cqlsh.

exit;

Configure the cassandra.yaml file:

vim /etc/cassandra/cassandra.yaml

Update the following line.

cluster_name: 'Cluster-name'

Flush the system cache.

nodetool flush system

Restart the Cassandra service.

systemctl restart cassandra

Again Log in to Cassandra.

cqlsh

Here is the command output.

Connected to Cluster-name at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.9 | CQL spec 3.4.4 | Native protocol v4]
 Use HELP for help.
 cqlsh> 

 

Leave a Reply

Your email address will not be published.