How to configure Cassandra in Linux server

Apache Cassandra is a free and open-source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers robust support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients.

This tutorial explains the detailed steps to install and configure Cassandra in Linux server

Step1: Download Oracle Java SE Runtime Environment 7

Head over to Oracle’s website and get the latest version of Oracle Java SE Runtime Environment 7.

Accept the license agreement and then download the Linux x64 RPM installer (which as of the writing of this article is jre-7u45-linux-x64.rpm ) to your local desktop.

Transfer the file to your web server.

Login to the server as root, and then from the directory where you uploaded the package run the install by using the command rpm -ivh <filename>, or in this case:

#rpm -ivh jre-7u45-linux-x64.rpm

Note: Your command will be slightly different if you downloaded a different version of Oracle Java SE Runtime Environment 7. Simply replace jre-7u45-linux-x64.rpm with the actual filename.

Then install the Java Native Access (JNA) which can improve Cassandra’s memory usage:

#yum install jna

Add a symbolic link to the Oracle Java SE Runtime Environment 7 installation so that your server uses the Oracle JRE instead of the OpenJDK JRE:

#alternatives --install /usr/bin/java java /usr/java/jre1.7.0_45/bin/java 20000

Note: Your command will be slightly different if you downloaded a different version of Oracle Java SE Runtime Environment 7. Simply replace jre1.7.0_45 with the actual version you’ve installed.

Then use the alternatives command to verify that the Oracle Java SE Runtime Environment 7 is selected. If not, simply choose the appropriate Selection after you run the command:

#alternatives --config java

Utilize the following command to double check the correct version of Oracle Java SE Runtime Environment 7 is being used:

#java -version

Step2: Add the DataStax Community Repository

#vim /etc/yum.repos.d/datastax.repo

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

[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0

Then exit and save the file with the command :wq (see the example below):

Step3: Install Apache Cassandra 2

At this point, installing Cassandra is as simple as running just one command:

#yum install dsc20

Step4: Configure the Apache Cassandra 2 Environment

Just two more simple environment tweaks that enable Cassandra to run correctly:

#export JAVA_HOME=/usr/java/jre1.7.0_45/
#export PATH=$PATH:/usr/java/jre1.7.0_45/bin/

Note: Your commands will be slightly different if you downloaded a different version of Oracle Java SE Runtime Environment 7. Simply replace jre1.7.0_45 with the actual version you’ve installed.

Step5: Get Cassandra Running

Start-Up Cassandra

#service cassandra start

Check Cassandra Service Status

#service cassandra status

Enter the Cassandra Command Line

#cqlsh

Check Cassandra Node Status

#nodetool status

Shutdown Cassandra

#service cassandra stop

Leave a Reply