How to Install Apache Cassandra on CentOS 7

Install Apache Cassandra on CentOS 7

In this article, we will have explained the necessary steps to install and configure Apache Cassandra on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Apache Cassandrais a highly scalable database management systemthat used to manage very large amounts of structured data. It can able to perform on multi-node setups. The Cassandrasupports relational databases including MySQL, PostgreSQLand Microsoft SQL.

Install Apache Cassandra on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum install epel-release
sudo yum update

Step 2. Install Java package.

Cassandra is written in Java. As such, you’ll need the Java VM installed in order to run it. Do so via Yum:

sudo yum install java-1.8.0-openjdk-devel

Verify the Java installation by running the following command which will print the Java version:

java -version

Step 2. Install Apache Cassandra.

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

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

Paste the following content 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

Now we can install Cassandra by running the following command:

sudo yum install cassandra

Start and enable the Cassandra service:

sudo systemctl enable cassandra
sudo systemctl start cassandra

Now enter the Cassandrain the command line:

cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.17 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh>

Verify that Cassandra is running by typing:

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

Congratulation, you have learned how to install and configure Apache Cassandra on CentOS 7. If you have any question, please leave a comment below.