In this blog, we will explain how to Install Cassandra v3.11.1 on CentOS 6.x. Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster.

Pre-requisiteHow to Install Cassandra v3.11.1 on CentOS 6.x

Check Java version if it is already installed:

[root@Sks-cluster-linux ~]# java -version

java version “1.8.0_151”

Java(TM) SE Runtime Environment (build 1.8.0_151-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

[root@Sks-cluster-linux ~]#

 Install Java 8

$ sudo yum install java-1.8.0-openjdk

Create cassandra.repo file, so that you can install from yum command:

[root@Sks-cluster-linux ~]# cat /etc/yum.repos.d/cassandra.repo

[cassandra]

name=Apache Cassandra

baseurl=https://www.apache.org/dist/cassandra/redhat/311x/

gpgcheck=0

enabled = 1

repo_gpgcheck=0

gpgkey=https://www.apache.org/dist/Cassandra/KEYS

[root@Sks-cluster-linux ~]#

Now install Cassandra:

[root@Sks-cluster-linux ~]# sudo yum install Cassandra

Start Cassandra (will not start automatically):

[root@Sks-cluster-linux ~]# service cassandra start

Make Cassandra start automatically after reboot:

[root@Sks-cluster-linux ~]# chkconfig cassandra on

Restart Cassandra
1 service cassandra restart
Shutdown Cassandra
1 service cassandra stop
 Related files:

/etc/cassandra/conf/cassandra-env.sh

/var/log/cassandra/cassandra.log

/var/log/cassandra/debug.log

/var/log/cassandra/gc.log.0.current

/var/log/cassandra/system.log

 Cassandra commands for service  start|stop|status:

service cassandra start

service cassandra stop

service cassandra status

Known Issue:

ERROR: [root@sks-cluster-linux~]# service cassandra status

cassandra dead but pid file exists

(OR)

ERROR:

CassandraDaemon.java:706 – Local host name unknown: java.net.UnknownHostException

Solutions 1:

//This error may be because of heap-memory of system – check your system memory (free -m/2 after divide it should be greate than 2GB)

//So upgrade your box to min 6GB

Solution 2:

In AWS EC2, when you install Cassandra you can have this problem because of the initially configured hostname which is set to ip-x-x-x-x being x-x-x-x the EC2 instance private address. The steps to solve it:

Edit network configuration file /etc/sysconfig/network

HOSTNAME=[myservername]

Edit hosts file:

sudo vi /etc/hosts

Add hostname entry to /etc/hosts

127.0.0.1 [myservername]

Set hostname or reboot

sudo hostname [myservername]