Apache Cassandra is an open-source NoSQL database system designed to handle a large amount of data. It supports clusters spanning multiple data centers and high availability with no single point of failure. It offers a lot of features including, Highly Scalable, Distributed, Replication Support, Fault-tolerant, MapReduce support, Query language, and many more. If you are looking for scalability and high availability without compromising performance then Apache Cassandra is the best choice for you.
In this tutorial, we will show you how to install Apache Cassandra on CentOS 8.
Table of Contents
- A CentOS 8 VPS (we’ll be using our SSD 2 VPS plan)
- Access to the root user account (or access to an admin account with root privileges)
Step 1: Log in to the Server & Update the Server OS Packages
First, log in to your CentOS 8 server via SSH as the root user:
ssh root@IP_Address -p Port_number
You will need to replace ‘IP_Address‘ and ‘Port_number‘ with your server’s respective IP address and SSH port number. Additionally, replace ‘root’ with the username of the admin account if necessary.
Before starting, you have to make sure that all CentOS packages installed on the server are up to date. You can do this by running the following commands:
dnf update -y
Step 2: Install Java
Apache Cassandra requires Java 8 to be installed in your system. You can install it by running the following command:
dnf install java-1.8.0-openjdk-devel -y
After installing Java 8, verify the installed version of Java with the following command:
You should see the following output:
openjdk version "1.8.0_272" OpenJDK Runtime Environment (build 1.8.0_272-b10) OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)
Step 3: Install Apache Cassandra
By default, Apache Cassandra is not available in the CentOS 8 default repo. So you will need to create a repo for that. You can create it with the following command:
Add the following lines:
Save and close the file then install the Apache Cassandra with the following command:
dnf install cassandra -y
Step 4: Create a Systemd Service File For Apache Cassandra
Next, you will need to create a systemd service file to manage the Cassandra service. You can create it with the following command:
Add the following lines:
[Unit] Description=Apache 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 Restart=always [Install] WantedBy=multi-user.target
Save and close the file then reload the systemd daemon with the following command:
Next, start the Cassandra service and enable it to start at system reboot:
systemctl start cassandra systemctl enable cassandra
Next, verify the Apache Cassandra with the following command:
If everything is fine, you should get the following output:
Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 127.0.0.1 70.69 KiB 256 100.0% 560b5524-2293-4872-a2d5-03c9c1f62f94 rack1
Step 5: Connect to Cassandra with CQL
Cassandra Query Language (CQL) is a query language for the Apache Cassandra database. It is used for communicating with the Apache Cassandra database. You can use the cqlsh utility to interact with Cassandra through CQL. But, cqlsh requires Python 2 to be installed in your system. You can install it with the following command:
dnf install python2 alternatives --set python /usr/bin/python2
Next, run the following command to access the CQL:
Once connected, you should get the following output:
Connected to Test Cluster at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.11.9 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh>
Step 6: Rename Cassandra Cluster Name
By default, the Cassandra cluster is set to “Test Cluster”. You can change it through the cqlsh:
First, connect to the CQL using the following command:
Next, change the cluster name with the following command:
UPDATE system.local SET cluster_name = 'My Cluster' WHERE KEY = 'local';
Next, exit from the CQL with the following command:
Now just $43 .99
Next, open the Cassandra default configuration file and change the cluster name:
Change the following line:
cluster_name: 'My Cluster'
Save and close the file then flush the system cache and restart the Cassandra service to apply the changes:
nodetool flush system systemctl restart cassandra
Congratulations! you have successfully installed Apache Cassandra on CentOS 8.
Follow this guide for installing Apache Cassandra on Ubuntu 20.04
Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
1 thought on “How to Install Apache Cassandra on CentOS 8”
yes you are right…In today’s digital age, there is a ton of data that is stored and passed through the world wide web. All this data comes forth from different devices like – computers, tablets, smartphones, etc. Handling this sheer amount of data from various sources is a huge undertaking. With Big Data becoming a staple for business models, data management can be an issue that needs to be addressed