Apache Cassandra is a NoSQL database intended for storing large amounts of data in a decentralized, highly available cluster.
Cassandra or Apache Cassandra is a distributed database system which manages large amounts of structured data across different commodity servers by providing highly available service with no point of failure.
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.
Cassandra is one the popular and robust distributed database management system. It is known for providing high availability with no single point of failure.
It has one of the awesome feature that is asynchronous replication between multiple nodes without requiring master nodes.
Cassandra is a reliable, clusterable, highly-scalable database capable of handling large quantities of data on commodity hardware.
If you have big data needs, and are looking for a proven open source solution that has received battle testing from many large companies, then Cassandra may be exactly what you’re looking for.
If you have a CentOS 7 server, this guide will get you up and running with a single Cassandra node.
It will use pre-packaged Cassandra distributions built for CentOS, making installation and upgrades a snap.
You can then build it out by performing additional installations on other servers, then clustering the resulting instances for higher scalability and reliability.
This article will guide you on how to install Apache Cassandra on CentOS 7 Server.
CentOS 7 Cassandra systemd service file
# /usr/lib/systemd/system/cassandra.service
[Unit]
Description=Cassandra
After=network.target
[Service]
PIDFile=/var/run/cassandra/cassandra.pid
User=cassandra
Group=cassandra
ExecStart=/usr/sbin/cassandra -f -p /var/run/cassandra/cassandra.pid
StandardOutput=journal
StandardError=journal
LimitNOFILE=100000
LimitMEMLOCK=infinity
LimitNPROC=32768
LimitAS=infinity
Restart=always
[Install]
WantedBy=multi-user.target
How To Install Cassandra on CentOS 7
Step 1: Install Java
First, you’ll follow a simple best practice: ensuring the list of available packages is up to date before installing anything new.
yum -y update
At this point, installing lsyncd is as simple as running just one command:
yum -y install java
tar -zxvf jdk-8u121-linux-x64.tar.gz
mv jdk-8u121-linux-x64.tar.gz /root/software/
vi /etc/profile.d/java.sh
# Uncomment the following line to set the JAVA_HOME variable a
#JAVA_HOME=/usr/lib/jvm/jre
export JAVA_HOME=/usr/java/jdk1.8.0_121
export JRE_HOME=/usr/java/jdk1.8.0_121/jre
export PATH=$PATH:/usr/java/jdk1.8.0_121/bin
export CLASSPATH=./:/usr/java/jdk1.8.0_121/lib:/usr/java/jdk1.8.0_121/jre/lib
source /etc/profile.d/java.sh
export
alternatives –config java
alternatives –install /usr/bin/java java /usr/java/jdk1.8.0_121/bin/java 5
alternatives –config java
Step #2: Add the DataStax Community Repository
vim /etc/yum.repos.d/datastax.repo
Add the following information to the file you’ve created, using i to insert:
[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0
Step #3: Install Apache Cassandra 2
At this point, installing Cassandra is as simple as running just one command:
yum -y install dsc20
Step #4: Get Cassandra Running
Start-Up Cassandra
systemctl start cassandra
Check Cassandra Service Status
systemctl status cassandra
Enable Cassandra to Start at Boot
systemctl enable cassandra
Enter the Cassandra Command Line
cqlsh
With Cassandra installed, we must now start the daemon via systemd.
/etc/init.d/cassandra start
The systemd unit is now created. Use “systemctl start cassandra” to launch the new unit.
systemctl enable cassandra.service
While the database should be running, it is not yet configured to launch on boot. Let’s tell systemd that Cassandra should automatically launch whenever your system boots.
[root@cassandra ~] systemctl status cassandra
cassandra.service – SYSV: Starts and stops Cassandra
Loaded: loaded (/etc/rc.d/init.d/cassandra)
Active: active (exited) since Thu 2016-09-15 04:36:47 UTC; 14s ago
Docs: man:systemd-sysv-generator(8)
Process: 9413 ExecStart=/etc/rc.d/init.d/cassandra start (code=exited, status=0/SUCCESS)
Let’s ensure that Cassandra is running using this command.
[root@cassandra ~] 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>
assandra ships with a powerful command line utility, cqlsh. Launch it to perform various vital tasks with your database.
[root@rmohan.com ~] nodetool status
Datacenter: rmohan
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
— Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 46.21 KB 256 100.0% 7dd2b7d9-404e-4a77-a36d-cc8f55168c0d rack1
[root@rmohan.com ~]#
Restart Cassandra
systemctl restart cassandra
Recent Comments