Install and Configure Apache Cassandra on AlmaLinux 8

In this article, we want to teach you How To Install and Configure Apache Cassandra on AlmaLinux 8.

Apache Cassandra is the only distributed NoSQL database that delivers always-on availability, fast read-write performance, and unlimited linear scalability that enables you to meet the demands of successful modern applications.

How To Install and Configure Apache Cassandra on AlmaLinux 8

To install Apache Cassandra on AlmaLinux 8, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article about the Initial Server Setup with AlmaLinux 8.

Now follow the steps below to install Apache Cassandra.

Install Java on AlmaLinux 8

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

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

sudo dnf update

Then, install OpenJDK on AlmaLinux 8 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_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

Now you can start to install Apache Cassandra on AlmaLinux 8.

Installing Apache Cassandra on AlmaLinux 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 into 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

Now you can install Apache Cassandra with the following command:

sudo dnf install cassandra

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 AlmaLinux 8 with the following command:

/etc/init.d/cassandra start

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 186.76 KiB 256 100.0% d5c0a5c5-e5ed-490f-a50c-0541ede5ddc3 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.11 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>

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

Configuring Apache Cassandra

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 AlmaLinux 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 to it:

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

Conclusion

At this point, you learn to install Apache Cassandra on AlmaLinux 8.

Hope you enjoy using it.

May you will be interested in these articles in the Linux Tutorials section on the orcacore website about:

Install and Configure Apache Cassandra on Debian 11.

Set up and Configure Apache Cassandra on Ubuntu 20.04.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!