How to Install Apache Cassandra on Ubuntu 20.04

How to Install Apache Cassandra on Ubuntu 20.04

Apache Cassandra is a free, open-source NoSQL database with no single point of failure. This provides linear scalability and high availability without sacrificing performance. Apache Cassandra is used by many companies that have large active data sets, including Reddit, NetFlix, Instagram, and Github.

This article guides you through installing Apache Cassandra on Ubuntu 20.04.

Installing Apache Cassandra on Ubuntu is straightforward. We will install Java, enable the Apache Cassandra repository, import the repository’s GPG key, and install the Apache Cassandra server.

Install Java

At the time of writing this article, the latest version of Apache Cassandra is 3.11 and requires OpenJDK 8 to be installed on the system.

Run the following command as root or user with sudo privileges to install OpenJDK:

sudo apt update
sudo apt install openjdk-8-jdk

Verify the Java installation by printing the Java version:

java -version

The output will look like this:

openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-8u265-b01-0ubuntu2~20.04-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)

Install Apache Cassandra

Install the dependencies needed to add the new repository over HTTPS:

sudo apt install apt-transport-https

Import the repository’s GPG key and add the Cassandra repository to the system:

wget -q -O - | sudo apt-key add -
sudo sh -c 'echo "deb 311x main" > /etc/apt/sources.list.d/cassandra.list'

Once the repository is enabled, update the packages list and install the latest version of Apache Cassandra:

sudo apt update
sudo apt install cassandra

The Apache Cassandra service will automatically start after the installation process is complete. You can verify it by typing:

nodetool status

You will see something similar to this:

Output :

Datacenter: datacenter1
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load    Tokens  Owns (effective)  Host ID                         Rack
UN  70 KiB  256     100.0%          2eaab399-be32-49c8-80d1-780dcbab694f  rack1

There she is. At this point, you have Apache Cassandra installed on your Ubuntu server.

Configuring Apache Cassandra

Apache Cassandra data is stored in the / var / lib / cassandra directory, the configuration file is located in / etc / cassandra, and Java start-up options can be configured in the / etc / default / cassandra file.

By default, Cassandra is configured to listen on localhost only. If the client connected to the database is also running on the same host, you don’t need to change the default configuration file.

To interact with Cassandra via CQL (Cassandra Query Language) you can use a command line tool called cqlsh which ships with the Cassandra package.


Output :

>Connected to Test Cluster at
[cqlsh 5.0.1 | Cassandra 3.11.7 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.

Renaming the Apache Cassandra Cluster

The default Cassandra cluster is named “Test Cluster”. If you want to change the cluster name, please do the steps below:

    1. Enter the Cassandra CQL terminal with cqlsh:

      Run the following command to change the cluster name to “uberhowto Cluster”:

      UPDATE system.local SET cluster_name = 'uberhowto Cluster' WHERE KEY = 'local';

      Change “uberhowto Cluster” to any name you want.

      When done, type exit to exit the console.

    2. Open the cassandra.yaml configuration file and enter a name for your new cluster.
      cluster_name: 'uberhowto Cluster'

      Save and close the file.

    3. Clear system cache:
      nodetool flush system
    4. Restart the Cassandra service:
      sudo systemctl restart cassandra


We have shown you how to install Apache Cassandra on Ubuntu 20.04. Now you can visit the official Apache Cassandra Documentation page and learn how to get started with Cassandra.

If you run into any issues or have feedback, leave a comment below.

Related posts

How to run Linux on an Android device


How to Install and Configure Fail2ban on Ubuntu 20.04


How to Count Files in Directories on Linux


How to install Lightworks on Ubuntu


How to properly secure sysctl on Linux


How to Set Up an FTP Server on Ubuntu


How to Add Elements to a List in Python (add, add and enter)


How to Install Tomcat 9 on Ubuntu 20.04


How To Remove Snap From Ubuntu