DebianDebian Based

How To Install Apache Cassandra on Debian 12

Install Apache Cassandra on Debian 12

In this tutorial, we will show you how to install Apache Cassandra on Debian 12. Apache Cassandra is a powerful, open-source NoSQL database management system designed to handle massive amounts of data across distributed servers. Its ability to provide high availability, fault tolerance, and scalability makes it a popular choice for organizations dealing with large-scale data storage and retrieval.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Apache Cassandra NoSQL database on a Debian 12 (Bookworm).

Prerequisites

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Apache Cassandra.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Apache Cassandra on Debian 12 Bookworm

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update

This command will refresh the repository, allowing you to install the latest versions of software packages.

Step 2. Installing Required Software.

Cassandra requires Java to run. Install OpenJDK 11, which is a compatible version for Cassandra:

sudo apt install openjdk-11-jdk

Most Linux distributions come with Python pre-installed. Check your Python version using:

python3 --version

If Python is not installed, you can install it using:

sudo apt install python3

Step 3. Installing Apache Cassandra on Debian 12.

Now use wget to download the Cassandra binary distribution. Replace <version> with the version you selected:

wget https://www.apache.org/dyn/closer.lua/cassandra/4.1.3/apache-cassandra-4.1.3-bin.tar.gz

Extract the downloaded file:

tar -xzvf apache-cassandra-4.1.3-bin.tar.gz

Move the extracted directory to the /opt directory using the following command:

sudo mv apache-cassandra-4.1.3 /opt/

Create a symbolic link to the Cassandra directory using the following command:

sudo ln -s /opt/apache-cassandra-4.1.3 /opt/cassandra

Add the following lines to the end of the /etc/environment file:

CASSANDRA_HOME="/opt/cassandra"
PATH="$PATH:$CASSANDRA_HOME/bin"

Reload the environment variables using the following command:

source /etc/environment

Start the Cassandra service using the following command:

sudo /opt/cassandra/bin/cassandra

Verify that the Cassandra service is running using the following command:

nodetool status

If the service is running, you should see the output similar to the following:

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns    Host ID                               Rack
UN  127.0.0.1  1.22 MiB   256          ?       12345678-1234-1234-1234-123456789012  rack1

Step 4. Creating a Systemd Service Unit.

To manage Cassandra as a service, create a systemd unit file:

sudo nano /etc/systemd/system/cassandra.service

Add the following lines to the file:

[Unit]
Description=Apache Cassandra database server
After=network.target

[Service]
Type=forking
User=cassandra
Group=cassandra
ExecStart=/opt/cassandra/bin/cassandra -p /var/run/cassandra/cassandra.pid
ExecStop=/opt/cassandra/bin/nodetool stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

Reload the systemd daemon using the following command:

sudo systemctl daemon-reload

Start the Cassandra service using the following command:

sudo systemctl start cassandra

Verify that the Cassandra service is running using the following command:

sudo systemctl status cassandra

Step 5. Monitoring Cassandra with nodetool.

Nodetool is a command-line utility for monitoring and managing Cassandra. Common nodetool commands include:

    • nodetool status: Cluster status.
    • nodetool tpstats: Thread pool statistics.
    • nodetool cfstats: Column family statistics.

Step 6. Accessing the Apache Cassandra on the Ubuntu 22.04.

The cqlsh is the command-line tool written in Python for executing the Cassandra Query Language (CQL) command. It’s the Cassandra client command-line utility. You can connect to the database by typing cqlsh:

cqlsh

Congratulations! You have successfully installed Cassandra. Thanks for using this tutorial to install the latest version of the Apache Cassandra NoSQL database on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Cassandra website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button