Linux

How to Install Apache Cassandra on CentOS 8

How to Install Apache Cassandra on CentOS 8

Apache Cassandra is a free and open source NoSQL database without a single point of failure. This provides linear scalability and high availability without compromising performance. Apache Cassandra is used by many companies that have large active data sets, including Reddit, NetFlix, Instagram, and Github.

This article explains how to install Apache Cassandra on CentOS 8.

Install Apache Cassandra

An easy way to install Apache Cassandra on CentOS 8 is to install the rpm package from the official Apache Cassandra repository.

The latest version of Apache Cassandra is 3.11 and requires OpenJDK 8 to be installed on the system.

Run the following command as root or as a user with sudo privileges to install OpenJDK:

sudo dnf install java-1.8.0-openjdk-devel

When finished, verify the installation by printing the Java version:

java -version

The output will look like this:

Output :

openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

Now that Java is installed, the next step is to add the Apache Cassandra repository.

Open your text editor and create the following repository file:

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

Paste the following content into the file:

/etc/yum.repos.d/cassandra.repo
[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

Save the file and install the latest version of Apache Cassandra by typing:

sudo dnf install cassandra

When prompted, type y to import the GPG key.

After the installation is complete, start and activate the Cassandra service:
sudo systemctl start cassandra
sudo systemctl enable cassandra

Verify that Cassandra is running by typing:

nodetool status

You should see something similar to this:

Output :

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens  Owns (effective)  Host ID                               Rack
UN  127.0.0.1  69.99 KiB  256     100.0%            ce0389a3-b48c-4cc9-b594-abe23e677d33  rack1

There she is. At this point, you have installed Apache Cassandra on your CentOS server.

Configure Apache Cassandra

Apache Cassandra data is stored in the / var / lib / cassandra directory, the configuration file is located in / etc / cassandra and the Java start options can be configured in the / etc / default / cassandra file.

By default, Cassandra is configured to listen on localhost only. If the client connected to the database also runs on the same host, you don’t need to change the default configuration file.

To interact with Cassandra via CQL (the Cassandra Query Language), you can use the command-line utility called cqlsh that ships with the Cassandra package.

cqlsh requires Python 2 to be on the system PATH. If you don’t install Python 2 on the server, you can do it with the following command:
sudo dnf install python2
sudo alternatives --set python /usr/bin/python2

After python is set up, run cqlsh to access the CQL shell:

cqlsh
[cqlsh 5.0.1 | Cassandra 3.11.7 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> 

Rename the Apache Cassandra Cluster

By default, the Cassandra cluster is named “Test Cluster”. If you want to change the cluster name, follow the steps below:

1. Enter the Cassandra CQL terminal with cqlsh:

cqlsh

The following command will change the cluster name to “uberhowtoCluster”:

UPDATE system.local SET cluster_name = 'uberhowtoCluster' WHERE KEY = 'local';

Replace “uberhowtoCluster” with the name you want. When finished, type exit to exit the console.

2.Open the cassandra.yaml configuration file, search for “cluster_name” and enter your new cluster name:

sudo nano /etc/cassandra/default.conf/cassandra.yaml
/etc/cassandra/default.conf/cassandra.yaml
cluster_name: 'Linuxize Cluster'

3. Clean system cache:

nodetool flush system

4. Finally restart the Cassandra service:

sudo systemctl restart cassandra

Conclusion

We have shown you how to install Apache Cassandra on CentOS 8. You can now visit the official Cassandra Apache Documentation page and learn how to get started with Cassandra.

If you experience problems or get feedback, leave a comment below.

Related posts

How to Set Up WireGuard VPN on CentOS 8

Linux

How to Install and Use a Linux Firewall

Linux

How to Install the Open Source Computer Vision Library (OpenCV) on CentOS 8

Linux

How to Install Laravel on Ubuntu 20.04

Linux

How to Install Android Studio on Ubuntu 20.04

Linux

How to Install Memcached on Ubuntu 20.04 LTS

Linux

How to Install Atom Text Editor on Ubuntu 20.04

Linux

How to Destroy / Erase Data Safely on Hard Drive with Damaged on Linux

Linux

How to Run a Cron Job Every 5, 10 or 15 Minutes

Linux