How To Install Cassandra on CentOS 7
Apache Cassandra was initially released in 2008 by the Apache Software Foundation. It is a free, open-source, NoSQL type database management system that is designed to address large amounts of information that can be shared across multiple servers and, it provides high availability, so it eliminates the single point of failure issues! It has excellent fault tolerances when operating on basic hardware or in a larger cloud infrastructure. It is used by high-profile companies like Constant Contact, CERN, Comcast, eBay, GitHub, GoDaddy, Hulu, Instagram, Intuit, Netflix, Reddit, The Weather Channel and a multitude of other business concerns. They selected to use Cassandra as it’s a wise choice to host your decentralized, NoSQL database solution.
Let’s get started with the installation. In this article, we’ll be installing Apache Cassandra on a CentOS 7 VPS server.
Prerequisites
We need to verify a few items and then install Java as Cassandra was developed using the Java programming language.
First, let’s verify our version of CentOS
[root@test yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
Next, make sure your server is up to date with the latest software
yum -y update
Step 1: Install Java
Now that we have those prerequisites out of the way let’s install Java. We’re going to use the newer OpenJDK install (Open Java Development Kit) because, the earlier Oracle JDK is EOL (end of life) as of Jan. 2019 and will no longer provide any updates unless you purchase a business license. As Oracle announced, “Public updates for Oracle Java SE 8 released after January 2019 will not be available for business, commercial, or production use without a commercial license”. However, the OpenJDK is completely open source and can be used freely.
There are no radical technical differences between the two software titles since the builds for the Oracle JDK is based on OpenJDK. All the major Linux distributions (Fedora, Ubuntu, Red Hat) provide OpenJDK as the default Java SE implementation, so we’ll trust their judgment in choosing that platform as well.
yum -y install java
Now, let’s quickly check the version of java we just installed
java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
Step 2: Adding the Cassandra Repo
Ok, time to add the Cassandra repo to the server. We’ll be using VIM (because what other awesome editor is there?)
vim /etc/yum.repos.d/cassandra.repo
(click insert on your keyboard and then
copy/paste the info below into the repo 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
(after that, click on the escape key to end editing the file)
Once complete, use ‘:wq’ to save the file.
Ok, let’s update our system again, so all the changes are picked up.
[root@new ~]# yum -y update
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirrors.liquidweb.com
* extras: mirrors.liquidweb.com
* updates: mirrors.liquidweb.com
cassandra/signature | 833 B 00:00:00
Retrieving key from https: // www . apache . org / dist / cassandra / KEYS
Importing GPG key 0xF2833C93:
Userid : "Eric Evans <eevans@sym-link.com>"
Fingerprint: cec8 6bb4 a0ba 9d0f 9039 7cae f835 8fa2 f283 3c93
From : https://www.apache.org/dist/cassandra/KEYS
cassandra/signature | 2.9 kB 00:00:00 !!!
cassandra/primary_db | 4.2 kB 00:00:00
No packages marked for update
Step 3: Install Cassandra
Now, time to install Cassandra!
[root@new ~]# yum install cassandra
Dependencies Resolved
Package Arch Version Repository Size
Installing:
cassandra noarch 3.11.4-1 cassandra 28 M
Transaction Summary
Install 1 Package
Total download size: 28 M
Installed size: 38 M
Is this ok [y/d/N]: y
Downloading packages:
warning: / var / cache / yum / x86_64 / 7 / cassandra / packages / cassandra-3.11.4-1.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID fe4b2bda: NOKEY
Public key for cassandra-3.11.4-1.noarch.rpm is not installed
cassandra-3.11.4-1.noarch.rpm | 28 MB 00:00:00
Retrieving key from https://www.apache.org/dist/cassandra/KEYS
Importing GPG key 0xF2833C93:
Userid : "Eric Evans <eevans@sym-link.com>"
Fingerprint: cec8 6bb4 a0ba 9d0f 9039 7cae f835 8fa2 f283 3c93
From : https://www.apache.org/dist/cassandra/KEYS
Is this ok [y/N]: y
Importing GPG key 0x8D77295D:
Userid : "Eric Evans <eevans@sym-link.com>"
Fingerprint: c496 5ee9 e301 5d19 2ccc f2b6 f758 ce31 8d77 295d
From : https://www.apache.org/dist/cassandra/KEYS
Is this ok [y/N]: y
Importing GPG key 0x2B5C1B00:
Userid : "Sylvain Lebresne (pcmanus) <sylvain@datastax.com>"
Fingerprint: 5aed 1bf3 78e9 a19d ade1 bcb3 4bd7 36a8 2b5c 1b00
From : https://www.apache.org/dist/cassandra/KEYS
Is this ok [y/N]: y
Importing GPG key 0x0353B12C:
Userid : "T Jake Luciani <jake@apache.org>"
Fingerprint: 514a 2ad6 31a5 7a16 dd00 47ec 749d 6eec 0353 b12c
From : https:// www . apache . org / dist / cassandra / KEYS
Is this ok [y/N]: y
Importing GPG key 0xFE4B2BDA:
Userid : "Michael Shuler <michael@pbandjelly.org>"
Fingerprint: a26e 528b 271f 19b9 e5d8 e19e a278 b781 fe4b 2bda
From : https:// www . apache . org / dist / cassandra / KEYS
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : cassandra-3.11.4-1.noarch 1/1
Verifying : cassandra-3.11.4-1.noarch 1/1
Installed:
cassandra.noarch 0:3.11.4-1
Complete!
Step 4: Start Cassandra
Now, let's start/enable the Cassandra service:
[root@new ~]# systemctl enable cassandra
cassandra.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig cassandra on[root@new ~]# systemctl start cassandra
Next, we’ll check to see if Cassandra is running.
[root@new ~]# nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
[root@new ~]# 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 103.67 KiB 256 100.0% cda3cdf2-e210-4736-a36c-4bad87eadf7b rack1
Perfect! Cassandra is now installed.
(As an aside, Cassandra's data is kept in the /var/lib/cassandra folder)
[root@new ~]# cd /var/lib/cassandra
[root@new cassandra]# ll
total 16
drwxr-xr-x 2 cassandra cassandra 4096 Mar 28 15:30 commitlog
drwxr-xr-x 7 cassandra cassandra 4096 Mar 28 15:30 data
drwxr-xr-x 2 cassandra cassandra 4096 Feb 2 18:48 hints
drwxr-xr-x 2 cassandra cassandra 4096 Feb 2 18:48 saved_caches
The configuration files are kept in the /etc/cassandra folder.
[root@new cassandra]# vim [root@new ~]# 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 103.67 KiB 256 100.0% cda3cdf2-e210-4736-a36c-4bad87eadf7b rack1/etc/cassandra/
conf/ default.conf/[root@new cassandra]# vim /etc/cassandra/conf/
cassandra-env.sh cassandra.yaml.orig logback.xml
cassandra-env.sh.orig commitlog_archiving.properties metrics-reporter-config-sample.yaml
cassandra-jaas.config cqlshrc.sample README.txt
cassandra-rackdc.properties hotspot_compiler triggers/
cassandra-topology.properties jvm.options
cassandra.yaml logback-tools.xml
Lastly, the java configs can be found in the /etc/default/cassandra file
[root@new cassandra]# cat /etc/default/cassandra
# NOTICE: See also / etc / cassandra / cassandra-env .sh# EXTRA_CLASSPATH provides the means to extend Cassandra's classpath with
# additional libraries. It is formatted as a colon-delimited list of
# class directories and/or jar files. For example, to enable the
# JMX-to-web bridge install libmx4j-java and uncomment the following.
#EXTRA_CLASSPATH="/usr/share/java/mx4j-tools.jar"
Cassandra starts off listening on localhost by default so the configurations will need to be modified by a dev or a system's admin to suit your needs.
If you get an error such as:
‘Failed to connect to ’127.0.0.1:7199′: Connection refused’
Then check the following tutorial to resolve that issue:
Error: Failed to connect to ’127.0.0.1:7199′: Connection refused (Cassandra) [SOLVED]
To restart Cassandra
[root@new cassandra]# systemctl restart cassandra
To shut down Cassandra
[root@new cassandra]# service cassandra stop
Related Articles:

About the Author: J. Mays
As a previous contributor, JMays shares his insight with our Knowledge Base center. In our Knowledge Base, you'll be able to find how-to articles on Ubuntu, CentOS, Fedora and much more!
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
Best authentication practices for email senders
Read ArticleWhat is SDDC VMware?
Read Article2024 cPanel and Plesk pricing breakdown
Read ArticleCentOS Linux 7 EOL — everything you need to know
Read ArticleHow to install Node.js on Linux (AlmaLinux)
Read Article