Saturday, October 23, 2021
HomeLinuxHow to Install and Configure Apache Cassandra on Linux System

How to Install and Configure Apache Cassandra on Linux System

The Apache Cassandra is a widely used cross-platform NoSQL database for handling big data and live data. Many tech giants use the apache Cassandra database as a not conventional relational database engine; instead, it’s a wide column store, database engine. The Apache Cassandra tool is available for Linux, Windows, and Mac. In the benchmark, the speed of apache Cassandra is higher and trustworthy. If you own a large amount of data, you can surely use apache Cassandra for data security.

Moreover, it also allows a distributed method of sharing and handling data. The Cassandra cloud and DB engine can help you to build your own server. Handling data scalability, Hadoop MapReduce, and other features have made the apache Cassandra a giant tool for data management.

Apache Cassandra on Linux


The Apache Cassandra NoSQL DB engine is built with Java programming language, and it has the Apache 2.0 privacy license. The Git repository of the Apache Cassandra tool holds all the versions of Cassandra. Apache Cassandra NoSQL database works with Java on Linux. It can read, write, and repair databases.

In Linux, the Apache Cassandra can really help to find the faulty cluster data from an enormous amount of data; moreover, it has been used for decades for its distributed storage method and flexibility. In this post, we will see how to install apache Cassandra on Linux.

1. Install Apache Cassandra on Ubuntu/Debian Distribution


Since Apache Cassandra is written in Java, so obviously, it will require the Java installed and configured on the system to install the Cassandra tool on Ubuntu and other Linux systems. Here, very first, we will install the Java packages on our Ubuntu machine, then we will install the Apache Cassandra through the Java and the HTTPS protocol.

Step 1: Install Java on Ubuntu/Debian


Installing Java on Ubuntu and Debian distributions is easy and straightforward. First, update your system repository, then run the following apt command to install Java on the system.

java on Linux

sudo apt update
sudo apt install openjdk-8-jdk -y
- -

When the installation ends up, you can run a quick version check to ensure that Java runs successfully. If you see other versions of java is installed on the machine, please make sure that Java 1.8 is on the machine.

java -version

java -version

Step 2: Install HTTPS Ubuntu Linux


The HTTPS will allow the Apache Cassandra tool executable on the Ubuntu Linux system. You can run the following apt command on the terminal shell to install the HTTPS protocol on the system.

Install HTTPS Ubuntu

sudo apt install apt-transport-https

Then the following commands for add the Cassandra key for the network protocols on your Ubuntu system.

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

Step 3: Install Cassandra on Ubuntu Linux


Finally, you may now run the commands given below to update the system repository and install the Apache Cassandra NoSQL DB engine on your Linux machine. If you install the Java and HTTPS protocols correctly on your system correctly, the following commands won’t take long to finish the Cassandra installation.

install cassandra on Linux

sudo apt update
sudo apt-get install cassandra

Step 4: Monitor Cassandra on Ubuntu


Monitoring the Apache Cassandra tool on Ubuntu requires root access to the system. At the very beginning, you may run the following node tool command to check the Cassandra status, runtime details, cluster status.

nodetool status

nodetool status

The following system control commands will allow you to start and restart the Cassandra service. It will also let you know the Cassandra status on your system.

sudo systemctl status cassandra
sudo systemctl start cassandra
sudo systemctl restart Cassandra

sudo systemctl status Apache Cassandra on Linux

You may also use the following system control commands with superuser permission to stop and enable the Cassandra services on your Linux machine.

sudo systemctl stop cassandra
sudo systemctl enable Cassandra

To edit and configure the Apache Cassandra configuration file, you might need to make a backup of the current configuration script. Later, we will use the file to restore the default setups if you mess something up.

sudo cp /etc/cassandra/cassandra.yaml /etc/cassandra/cassandra.yaml.backup

Then you can edit the script with your favorite script editing tool.

$ sudo vim /etc/cassandra/cassandra.yaml

Finally, to login into the Apache Cassandra database, please execute the following command; it will allow you to enter the Cassandra query language.

$ cqlsh

2. Install Cassandra on Fedora Workstation


Installing the Apache Cassandra on a Fedora or another Red Hat-based system require java services on both server and client end. You may run the following command to get an extensive view of Cassandra packages on your system.

dnf list cassandra\*

Step 1: Install Cassandra on Fedora


Since the Apache foundation provides the official repository of the Cassandra for Linux, you can use the official DNF package installer command for installing the Apache Cassandra tool on Fedora Linux.

Please run the following DNF command with root access to install the Apache Cassandra on your DENF-based Linux environments.

$ sudo dnf install cassandra cassandra-server

Step 2: Add Firewall for Cassandra On Fedora


If your DNF-based system has an active firewall system, you can execute the following commands to let your firewall daemon allow the Cassandra applications.

firewall daemon on Fedora for Apache casandra

sudo firewall-cmd --zone=public --add-port=9081/tcp --permanent
sudo firewall-cmd --zone=public --add-port=9042/tcp --permanent
sudo firewall-cmd --reload

If you’re an old Cassandra user, you can run the following command on the shell for performing the system control commands to stop the Cassandra tool. 

$ sudo systemctl stop cassandra
$ sudo rm -rf /var/lib/cassandra/data/system/*

3. Installing Apache Cassandra on Arch-based Linux


The CLI method of installing the Apache Cassandra tool on Arch and other Arch-based systems requires the Snap daemon on the system. If you don’t have the Snap daemon installed on the system, please follow this post to get the guideline on how to install and use the Snap on Linux machine.

When you have the Snap system installed on the machine, you may now run the following Snap command to install the latest Apache Cassandra tool on your Arch Linux. Here, I’ve used the Manjaro KDE desktop to demonstrate how to install the Apache Cassandra on the Arch system.

sudo snap install cassandra --edge

Get Started with Apache Cassandra


When the installation ends up, run the system control command given below to start and restart the Cassandra tool on the system.

$ sudo systemctl start cassandra
$ sudo systemctl restart Cassandra

The following Cassandra Query Language will help you to create a new superuser on your system for Cassandra.

cqlsh> CREATE ROLE WITH PASSWORD = '' 
AND SUPERUSER = true
AND LOGIN = true;

Final Words


Installing the Apache Cassandra on Linux distributions was an easy task with proper commands and guides. If you face any errors while installing the Cassandra on Linux, please make sure that you did all the steps right. In the entire post, I have described how to install the Apache Cassandra NoSQL database on a Linux machine. It also offers third-party addons for integrating with other services. 

 Please share this post with your friends and the Linux community if you find it helpful and handy. You can also write down your opinions regarding this post in the comment section.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

spot_img

Latest Post

Must Read