How To Install Apache Cassandra 3.11 Database On CentOS 7/8

We can install the apache Cassandra database on CentOS 7/8 by downloading the package from the official website. Once we have download, the process is very easy to configure and install apache Cassandra on Linux.

Apache Cassandra is a free and open-source NoSQL database management system that’s designed to handle a large number of data across many commodity servers and providing high availability with no single point of failure.

Check Out: How To Install KDE Plasma 5 On Debian/Ubuntu 20.04

How To Install Apache Cassandra Database On CentOS 7/8:

First of all, you will need Java installed on the machine. you can use the below command to get that.

sudo yum install java-1.8* -y

Once it’s installed, check the version with java -version command. 

[root@cassandra~]# java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Update the packages on your machine only when you’re doing it in a test environment. 

sudo yum update

Check Out: How To Set System-Wide Proxy on Ubuntu 20.04/19.10

Create a repository file for Cassandra at the below location.

vim /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

Now run the below command to install it using yum command. 

sudo yum install Cassandra -y

During the installation, it will ask you to import the GPGkeys to check the fingerprints. So just simply say it “Yes“. 

Installed:
cassandra-3.11.6-1.noarch

Start and enable the service at the boot as well as using the below commands. 

systemctl enable Cassandra && systemctl start cassandra

Check Out: How To Disable IPv6 Network Interface On Linux 7

If you face any issue while starting the service, it’s failed. you can check the errors using systemctl status Cassandra -l

I got the error “cassandra.service: New main PID 11077 does not belong to service, and PID file is not owned by root. Refusing”.

To fix this issue, we need to follow the below instructions. Once the below commands are executed. you need to restart the service.

mv /etc/rc.d/init.d/cassandra /etc/rc.d/init.d/cassandra.old
curl -o /etc/rc.d/init.d/cassandra https://gist.githubusercontent.com/amalgjose/74cf98e0110c27b6124b0adbb698d372/raw/c08ce3481e9cb0601e79e127c78a65bf82080e5f/cassandra
chmod +x /etc/rc.d/init.d/cassandra
systemctl daemon-reload
systemctl start cassandra
systemctl is-active cassandra

You can also check the Cassandra service is running or not using the below command. 

[root@cassandra ~]# nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 70.05 KiB 256 100.0% f9b81b03-9a6d-41c1-adf2-bd677535d2e7 rack1
If you get an error like " error: failed to connect to 127.0.0.1:7199 Connection
refused", follow the below instructions.

Check Out: How To Create Account On sslforfree To Generate Certificates

Open the configuration file and find the below lines. 

vim /etc/cassandra/default.conf/cassandra-env.sh

# add this if you're having trouble connecting:
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"

Uncomment the line and change the <public name> to 127.0.0.1 and it should look like,

JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"

Restart the Service and run the nodetool status command. 

systemctl restart cassandra
nodetool status

That’s it. cassandra linux install

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment