How To Install Apache Cassandra on Rocky Linux 8

In this guide, we intend to teach you How To Install Apache Cassandra on Rocky Linux 8.

Apache Cassandra is a highly scalable, high-performance distributed database designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. It is a type of NoSQL database.

A NoSQL database (sometimes called Not Only SQL) is a database that provides a mechanism to store and retrieve data other than the tabular relations used in relational databases. These databases are schema-free, support easy replication, have simple API, are eventually consistent, and can handle huge amounts of data.

How To Install Apache Cassandra on Rocky Linux 8

To install Apache Cassandra, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Rocky Linux 8.

Now follow the steps below to complete this guide.

Installing Java

For installing Apache Cassandra, you need to have Java installed on your Rocky Linux 8.

First, update your local package index with the following command:

sudo dnf update

Then, install OpenJDK on your server with the following command:

sudo dnf install java-1.8.0-openjdk-devel

When your installation is completed, verify it by checking the Java version:

java -version
Output
openjdk version "1.8.0_342"
OpenJDK Runtime Environment (build 1.8.0_342-b07)
OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)

Now you can start to install Apache Cassandra on Rocky Linux 8.

Install Cassandra on Rocky Linux 8

You need to create the Apache Cassandra repository file with your favorite text editor, here we use vi:

sudo vi /etc/yum.repos.d/cassandra.repo

Add the following contents to the file:

[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/311x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS

When you are done, save and close the file.

Install Python 2 on your server with the following command:

sudo dnf install python2 -y

Now you can install Apache Cassandra with the following command:

sudo dnf install cassandra -y

Here you need to create a symbolic link with the following command:

ln -s /usr/lib/python3.6/site-packages/cqlshlib /usr/lib/python2.7/site-packages/

Then, start your Cassandra service on Rocky Linux 8 with the following command:

/etc/init.d/cassandra start
Output
Reloading systemd: [ OK ]
Starting cassandra (via systemctl): [ OK ]

Verify that your service is up and running with the command below:

nodetool status

In your output you will see:

Output
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 70.94 KiB 256 100.0% 9359995a-cb38-463f-9e96-a21f56ed3379 rack1

The UN option means that your service is up and normal.

At this point, you can log in to your cluster with the following command:

cqlsh

Your output should similar to this:

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

Here that you have Apache Cassandra installed on your Rocky Linux 8, let’s see how to configure it.

Configure Cassandra on Rocky Linux 8

At this point, you can change your default cluster name. From cqlsh run the command below to change your cluster name. Remember to replace the name with your own.

cqlsh> UPDATE system.local SET cluster_name = 'Orca Cluster' WHERE KEY = 'local';

Then, exit from your cluster with the following command:

cqlsh> exit

Now you need to edit the Cassandra YAML file. Open the file with your favorite text editor here we use vi:

sudo vi /etc/cassandra/default.conf/cassandra.yaml

Find the cluster_name directive and change it to your name:

cluster_name: 'Orca Cluster'

When you are done, save and close the file.

To apply the changes restart Apache Cassandra on Rocky Linux 8 with the following command:

sudo systemctl restart cassandra

Again login to your cluster and you will see that it changed to the name that you have given it:

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

For more information, you can visit the Apache Cassandra Documentation page.

Conclusion

At this point, you learn to Install and Configure Apache Cassandra on Rocky Linux 8.

Hope you enjoy it.

You may be interested in these articles:

How To Set up WineHQ on Rocky Linux 8

How To Set up CSF Firewall on Rocky Linux 8

How To Install Plesk on Rocky Linux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!