Apache Cassandra

How to Install Apache Cassandra on Linux

Apache Cassandra, commonly known as Cassandra, is a free and open-source wide-column database. It is mainly used in critical systems to handle large amounts of data with flexibility and scalability. Therefore, Cassandra is probably your best bet if you have an environment where you need to handle a large collection of data.

This tutorial will elaborate on the installation and configuration of Apache Cassandra on Linux systems.

Please note that this tutorial is tested on Ubuntu 16 and above, Debian 8 and above, Linux Mint, and related flavors.

Requirements

Before we can begin, please ensure you have:

    1. Access to a terminal session
    2. A root or sudo user
    3. A network connection

Step 1 – Install Apache Cassandra Dependencies (Java JDK and Python Interpreter)

Before setting up Cassandra, ensure you have the required dependencies installed and configured on your system. By default, Cassandra requires the Java JDK, and Python interpreter installed.

Start by updating your system repository index:


 

Next, run the command below to install the HTTPS transports package. This will allow you to access repositories on HTTPS.


 

Install the JDK:

$ sudo apt-get install java-common openjdk-11-jdk

 

Step 2 – Setup Cassandra Repository

Start by adding the Apache repository to the sources list. Execute:

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

 

Next, import the repository keys:

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

 

Ensure you have curl installed on your system.

Update the repo index:

$ sudo apt-get update

 
Finally, install Cassandra with the command:


 

Starting the Cassandra Service

Once installed, start the service:


The command will run the Cassandra service using systemd.

We can verify by running the command:


Output:

Cassandra is running.

 

Stopping Cassandra

To stop the Cassandra server, run:

$ sudo service cassandra stop

 

Restarting Cassandra Service

To restart the Cassandra service, run the command:

$ sudo service cassandra restart

 

Enable Cassandra Start after Reboot

To enable Apache Cassandra to start after reboot, use the systemd tool as shown in the command below:

$ sudo service enable cassandra

 

Test Cassandra Shell

You can test if you can connect to your CQL shell using the command:

$ cqlsh

 
If Cassandra is running, the command will automatically login to the server as shown:


You can now start executing CQL commands in the shell.

Conclusion

If you followed the steps in this tutorial, you should have a running cluster of Apache Cassandra on your Linux system.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list