Atlantic.Net Blog

How to Install Apache Cassandra on Rocky Linux 8

Hitesh Jethva
by Atlantic.Net (345 posts) under Dedicated Server Hosting, Tutorials
0 Comments

Apache Cassandra is a free and open-source distributed NoSQL database management system. It is specially designed to handle large amounts of data across many commodity servers. Generally, it is used as a real-time data store for transactional applications and as a read-intensive database. It supports relational databases including MySQL, PostgreSQL, and Microsoft SQL. It is used by many companies that use large data sets including, Instagram, GitHub, Netflix, Reddit, and more.

In this guide, we will show you how to install Apache Cassandra on Rocky Linux 8.

Prerequisites

  • A server running Rocky Linux 8 on the Atlantic.Net Cloud Platform
  • A root password is configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Rocky Linux as the operating system with at least 4GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Java 8

Apache Cassandra supports Java version 8, so you will need to install OpenJDK 8 to your system. You can install it with other required packages using the following command:

dnf install epel-release python2 python2-pip java-1.8.0-openjdk -y

Once Java is installed, verify the Java installation using the following command:

java -version

Sample output:

openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)

You will also need to install cqlsh utility to your system. You can install it using the following command:

pip2 install cqlsh

Step 3 – Install Apache Cassandra

By default, the Apache Cassandra package is not included in the RockyLinux 8 default repository, so you will need to create a repository for Apache Cassandra.

nano /etc/yum.repos.d/cassandra.repo

Add the following lines:

[cassandra]
name=Apache Cassandra
baseurl=https://www.apache.org/dist/cassandra/redhat/40x/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://www.apache.org/dist/cassandra/KEYS

Save and close the file, then install the Apache Cassandra with the following command:

dnf install cassandra -y

Step 4 – Create a Service File for Cassandra

Next, you will need to create a systemd service file to manage the Apache Cassandra service. You can create it with the following command:

nano /etc/systemd/system/cassandra.service

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 to apply the changes:

systemctl daemon-reload

Next, start and enable the Cassandra service with the following command:

systemctl start cassandra
systemctl enable cassandra

Next, verify the status of Apache Cassandra with the following command:

systemctl status cassandra

You should see the following output:

● cassandra.service - Apache Cassandra
   Loaded: loaded (/etc/systemd/system/cassandra.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-09-22 08:07:05 UTC; 603ms ago
 Main PID: 11515 (cassandra)
    Tasks: 4 (limit: 11411)
   Memory: 156.1M
   CGroup: /system.slice/cassandra.service
           ├─11515 /bin/sh /usr/sbin/cassandra -f -p /var/run/cassandra/cassandra.pid
           ├─11584 /bin/sh /usr/sbin/cassandra -f -p /var/run/cassandra/cassandra.pid
           ├─11588 find /lib64 /lib /usr/lib64 /usr/lib /usr/lib64//bind9-export /lib /lib64 /lib/sse2 /lib64/sse2 /lib64/tls -regex .*/libjem>
           └─11589 head -n 1

Sep 22 08:07:05 RockyLinux8 systemd[1]: cassandra.service: Service RestartSec=100ms expired, scheduling restart.
Sep 22 08:07:05 RockyLinux8 systemd[1]: cassandra.service: Scheduled restart job, restart counter is at 5.
Sep 22 08:07:05 RockyLinux8 systemd[1]: Stopped Apache Cassandra.
Sep 22 08:07:05 RockyLinux8 systemd[1]: Started Apache Cassandra.

Step 5 – Verify Apache Cassandra

Wait for some time to bring up Apache Cassandra completely, then verify the Apache Cassandra using the following command:

nodetool status

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  69.08 KiB  16      100.0%            d6672930-2b15-426b-8445-e6f6a2e923f2  rack1

You can also connect to Cassandra with the following command:

cqlsh

Once you are connected, you should get the following output:

Python 2.7 support is deprecated. Install Python 3.6+ or set CQLSH_NO_WARN_PY2 to suppress this message.

Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.0.0 | Cassandra 4.0.1 | CQL spec 3.4.5 | Native protocol v5]
Use HELP for help.
cqlsh> 

Step 6 – Change Cassandra Cluster Name

In order to change the Cassandra cluster name, connect to the Cassandra with the following command:

cqlsh

Next, change the cluster name with the following command:

cqlsh> UPDATE system.local SET cluster_name = 'Atlantic Cluster' WHERE KEY = 'local';

Next, exit from the Cassandra shell with the following command:

cqlsh> exit

Next, edit the Apache Cassandra main configuration file:

nano /etc/cassandra/default.conf/cassandra.yaml

Change the Cassandra cluster name as shown below:

cluster_name: 'Atlantic Cluster'

Save and close the file, then restart the Apache Cassandra to apply the changes:

systemctl restart cassandra

Now, verify the Cassandra cluster name with the following command:

cqlsh

You should get your new cluster name in the following output:

Connected to Atlantic Cluster at 127.0.0.1:9042
[cqlsh 6.0.0 | Cassandra 4.0.1 | CQL spec 3.4.5 | Native protocol v5]
Use HELP for help.

Conclusion

In the above guide, we explained how to install Apache Cassandra on RockyLinux 8. You can now use Apache Cassandra to handle and manage large data sets. Try it on dedicated hosting from Atlantic.Net today!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Python 3.10 on Rocky Linux 8
How to Install TaskBoard on Rocky Linux 8
How to Set Up Pritunl VPN Server on Rocky Linux 8
How to Install Teampass Password Manager on Rocky Linux 8
How to Install and Configure RabbitMQ Server on Rocky Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources