How To Install Apache Cassandra on CentOS 7

  • Post category:Spark
  • Reading time:5 mins read

apache_assandra_logo

In this post we will learn how to install Apache Cassandra on CentOS 7. Apache Cassandra is a free open-source NoSQL database. Apache Cassandra can handle large amounts of data and is highly scalable. Organizations like Apple, Netflix, eBay are using Cassandra.

Prerequisite

As a prerequisite, let’s check whether Java is present on the machine. To verify the Java version type below mentioned command in a new terminal.

 java --version

To work with Apache Cassandra we have to first install java if it is not present in the machine. Let’s start installing java as mentioned below.

Install Oracle Java (JRE)

Cassandra requires your using Oracle Java SE (JRE) installed on your server. First, you will have to add Java from the Oracle website. Once downloaded, run the installer and when complete, verify the default version of Java by typing:

java --version

Installation of Apache Cassandra

Now we will install Cassandra as mentioned below.

Installing Apache Cassandra

Add the Apache repository of Cassandra to the file /etc/yum.repos.d/cassandra.repo (as the root user). The latest major version is 4.0 and the corresponding distribution name is 40x (with an “x” as the suffix). For older releases use 311x for C* 3.11 series, 30x for 3.0, 22x for 2.2 and 21x for 2.1. For example, to add the repository for version 4.0 (40x):

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

Update the package index from sources:

$ sudo yum update

Install Cassandra with YUM:

$ sudo yum install cassandra

NOTE: A new Linux user cassandra will get created as part of the installation. The Cassandra service will using this user.

Start the Cassandra service:

$ sudo service cassandra start

Monitor the progress of the startup with:

$ tail -f /var/log/cassandra/system.log

Cassandra is ready when you see an entry like this in the system.log:

INFO  [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...

NOTE: For information on how to configure your installation, see Configuring Cassandra.

  1. Check the status of Cassandra:
$ nodetool status

The status column in the output should report UN which stands for “Up/Normal”.

Alternatively, connect to the database with:

$ cqlsh