Apache Cassandra is a free, open-source and distributed database management system. It is capable to handle large amounts of data across many servers and provides high availability with no single point of failure. It is used by many companies including Github, NetFlix, Reddit and Instagram. Cassandra works with peer to peer architecture, with each node connected to all other nodes. Each Cassandra node performs all database operations and can serve client requests without the need for a master node.

In this post, we will show you how to install Apache Cassandra database management system on Debian 11.

Prerequisites

  • A server running Debian 11.
  • A root password is configured on the server.

Install Java

Before starting, you will need to install Java on your server. You can install it by running the following command:

apt-get install openjdk-11-jre -y

After installing Java, verify the Java installation using the following command:

java -version

You should get the following output:

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12 7-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.12 7-post-Debian-2, mixed mode, sharing)

Install Cassandra

By default, the Cassandra package is not included in the Debian 11 default repository. So you will need to add the Cassandra repository to APT.

First, install the required dependencies using the following command:

apt-get install curl gnupg2 -y

Next, add the Cassandra GPG key and repository with the following command:

curl https://downloads.apache.org/cassandra/KEYS | apt-key add -

echo "deb https://downloads.apache.org/cassandra/debian 40x main" | tee -a /etc/apt/sources.list.d/cassandra.list

Once the repository is added, update the repository and install the Cassandra package with the following command:

apt-get update -y

apt-get install cassandra -y

Once Cassandra has been installed, you can verify the status of the Cassandra using the following command:

systemctl status cassandra

You should get the following output:

? cassandra.service - LSB: distributed storage system for structured data
     Loaded: loaded (/etc/init.d/cassandra; generated)
     Active: active (running) since Sat 2021-09-25 17:23:08 UTC; 23s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 24537 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
      Tasks: 53 (limit: 9510)
     Memory: 2.2G
        CPU: 23.439s
     CGroup: /system.slice/cassandra.service
             ??24666 /usr/bin/java -ea -da:net.openhft... -XX: UseThreadPriorities -XX: HeapDumpOnOutOfMemoryError -Xss256k -XX: AlwaysPreTouc>

Sep 25 17:23:08 debian11 systemd[1]: Starting LSB: distributed storage system for structured data...
Sep 25 17:23:08 debian11 systemd[1]: Started LSB: distributed storage system for structured data.

Verify Apache Cassandra Cluster

Wait for some time to up the Cassandra cluster then run the following command to verify the cluster status:

nodetool status

You should see 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.09 KiB  16      100.0%            2813344d-5006-4360-a57e-61deeea9fe70  rack1

Next, connect to the Cassandra cluster using the following command:

cqlsh

You should get the following output:

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> 

Configure Cassandra

If you want to change the Cassandra cluster name, run the following command:

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

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

cqlsh> exit

Next, edit the Cassandra main configuration file:

nano /etc/cassandra/cassandra.yaml

Change the Cassandra cluster name as shown below:

cluster_name: 'New Cluster'

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

systemctl restart cassandra

Next, verify the Cluster name using the following command:

cqlsh

You should see the new cluster name in the following output:

Connected to New 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

Congratulations! you have successfully installed Apache Cassandra on Debian 11. You can now start using Apache Cassandra as per your requirements.

<img alt="Hitesh Jethva" data-ezsrc="https://kirelos.com/wp-content/uploads/2021/10/echo/hitesh-80.jpg61719a89b5142.jpg" ezimgfmt="rs rscb5 src ng ngcb5" src="data:image/svg xml,”>

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.