How to Install Cassandra in CentOS

To Install Cassandra in CentOS

Apache Cassandra is a highly scalable database management system that used to manage very large amounts of structured data. It can able to perform on multi-node setups. The Cassandra supports relational databases including MySQL, PostgreSQL and Microsoft SQL. Installation of Cassandra in CentOS is explained in this manual.


Installation of Cassandra

Utilize the java-version command to check whether your server already has Java or not.

If you are not installed Java, then install a stable version Java 7.


To install Java package

Run the following command to install Java package.

[root@linuxhelp ~]# yum -y install java
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                          | 3.6 kB  00:00:00     
extras                                                                        | 3.4 kB  00:00:01     
mariadb                                                                       | 2.9 kB  00:00:00     
updates                                                                       | 3.4 kB  00:00:00     
(1/3): mariadb/primary_db                                                     |  18 kB  00:00:01     
(2/3): extras/7/x86_64/primary_db                                             | 166 kB  00:00:02     
(3/3): updates/7/x86_64/primary_db                                            | 9.1 MB  00:01:44     
Determining fastest mirrors
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
-->  Running transaction check
--->  Package java-1.8.0-openjdk.x86_64 1:1.8.0.101-3.b13.el7_2 will be updated
--->  Package java-1.8.0-openjdk.x86_64 1:1.8.0.111-1.b15.el7_2 will be an update
-->  Processing Dependency: java-1.8.0-openjdk-headless = 1:1.8.0.111-1.b15.el7_2 for package: 1:java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64
.
.
.
Updated:
  java-1.8.0-openjdk.x86_64 1:1.8.0.111-1.b15.el7_2                                                  

Dependency Updated:
  java-1.8.0-openjdk-headless.x86_64 1:1.8.0.111-1.b15.el7_2                                         

Complete!

Add the DataStax Community Repository.

[root@linuxhelp ~]# vim /etc/yum.repos.d/datastax.repo
[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0

Exit and save the file with the :wq command.

Now its time to install Apache Cassandra.

[root@linuxhelp ~]# yum -y install dsc20
Loaded plugins: fastestmirror, langpacks
datastax                                                                      | 2.5 kB  00:00:00     
datastax/primary_db                                                           | 131 kB  00:00:02     
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
-->  Running transaction check
--->  Package dsc20.noarch 0:2.0.17-1 will be installed
-->  Processing Dependency: cassandra20 = 2.0.17 for package: dsc20-2.0.17-1.noarch
-->  Running transaction check
--->  Package cassandra20.noarch 0:2.0.17-1 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
  dsc20.noarch 0:2.0.17-1                                                                            

Dependency Installed:
  cassandra20.noarch 0:2.0.17-1                                                                      

Complete!

Once the installation is completed, start the Cassandra.

[root@linuxhelp ~]# systemctl start cassandra

Use the following command to check the Cassandra service status

[root@linuxhelp ~]# systemctl status cassandra
 cassandra.service - SYSV: Starts and stops Cassandra
   Loaded: loaded (/etc/rc.d/init.d/cassandra)
   Active: active (exited) since Fri 2016-11-18 00:23:52 IST  38s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 18758 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=0/SUCCESS)

Nov 18 00:23:52 linuxhelp systemd[1]: Starting SYSV: Starts and stops Cassandra...
Nov 18 00:23:52 linuxhelp su[18765]: (to cassandra) root on none
Nov 18 00:23:52 linuxhelp cassandra[18758]: Starting Cassandra: OK
Nov 18 00:23:52 linuxhelp systemd[1]: Started SYSV: Starts and stops Cassandra.

Enable it to Start at Boot.

[root@linuxhelp ~]# systemctl enable cassandra
cassandra.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig cassandra on

Now enter the Cassandra in command line

[root@linuxhelp ~]# cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.17 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh> 
cqlsh>  exit

Use the following command to check the Cassandra node status.

[root@linuxhelp ~]# 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  46.09 KB   256     100.0%            da0e85b0-6e66-4de9-8f53-4ed15136dedb  rack1

Once the above process is completed, restart Cassandra with following command.

[root@linuxhelp ~]# systemctl restart cassandra

The below command helps to shutdown Cassandra.

[root@linuxhelp ~]# systemctl stop cassandra
FAQ
Q
What is the cluster in Cassandra?
A
A node is a single machine that runs Cassandra. A collection of nodes holding similar data are grouped in what is known as a "ring" or cluster.
Q
What are seed nodes in Apache Cassandra?
A
The seed node designation has no purpose other than bootstrapping the gossip process for new nodes joining the cluster. Seed nodes are not a single point of failure, nor do they have any other special purpose in cluster operations beyond the bootstrapping of nodes.
Q
How to install Cassandra in ubuntu?
A
Follow this link for the installation of Cassandra on Ubuntu https://www.linuxhelp.com/how-to-install-apache-cassandra-in-ubuntu/
Q
how to install Cassandra in Linux Mint?
A
For installing Cassandra in Linux Mint use the following link https://www.linuxhelp.com/how-to-install-apache-cassandra-on-linux-mint-18-3/ "
Q
What are the alternatives available for Cassandra?
A
There are tools like MySQL Community Edition, PostgreSQL, MariaDB are similar to Apache Cassandra.