How To Install Apache Cassandra on CentOS 6

Install Apache Cassandra on CentOS 6

For those of you who didn’t know, Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster. NoSQL refers to a database with a data model other than the tabular relations used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL. The Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation Apache Cassandra on CentOS 6.

Install Apache Cassandra on CentOS 6

Step 1. First, Downloading latest Java archive.

Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from shell:

### CentOS 64-Bit ###
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""
tar xzf jdk-8u40-linux-x64.tar.gz
### CentOS 32-Bit ###
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie:; oraclelicense=accept-securebackup-cookie" ""
tar xzf jdk-8u40-linux-i586.tar.g

Install JAVA using alternatives:

# cd /opt/jdk1.8.0_40/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_40/bin/java 2
# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
*  1           /opt/jdk1.8.0/bin/java
 + 2           /opt/jdk1.8.0_25/bin/java
   3           /opt/jdk1.8.0_40/bin/java
Enter to keep the current selection[+], or type selection number: 3

At this point JAVA 8 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives:

alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_40/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_40/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_40/bin/jar
alternatives --set javac /opt/jdk1.8.0_40/bin/javac

Verify Installed Java version:

# java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

Step 2. Add DataStax Community Repository.

Add new repository:

nano /etc/yum.repos.d/datastax.repo

Add the following information to the file you’ve created:

name = DataStax Repo for Apache Cassandra
baseurl =
enabled = 1
gpgcheck = 0

Step 3. Install Apache Cassandra.

yum install dsc20

Step 4. Configure Apache Cassandra Environment.

export JAVA_HOME=/usr/java/jre1.8.0_40/
export PATH=$PATH:/usr/java/jre1.8.0_40/bin/

Step 5. Start and Verify the newly installed cassandra.

service cassandra start

Check Cassandra service status:

service cassandra status

Enter Cassandra command line:

# cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 3.1.7 | Cassandra 1.2.10 | CQL spec 3.0.0 | Thrift protocol 19.36.0]
Use HELP for help.

Check Cassandra node status:

nodetool status

Congratulation’s! You have successfully installed Apache Cassandra. Thanks for using this tutorial for installing Apache Cassandra on CentOS 6 system.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!