How to Install Apache Cassandra on Debian 10 Linux

By 

Published on

4 min read

Install Apache Cassandra on Debian 10

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

In this article, we will explain how to install Apache Cassandra on Debian 10, Buster.

Prerequisites

The instructions assume that you are logged in as root or user with sudo privileges .

Installing Java

At the time of writing this article, the latest stable version of Apache Cassandra is 3.11 and requires OpenJDK 8, which is not available in the official Debian Buster repositories.

We’ll enable the Eclipse Temurin (Adoptium) repository and install the prebuilt OpenJDK 8 package.

Update the packages list and install the dependencies necessary to add a new repository over HTTPS:

Terminal
sudo apt update
sudo apt install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common

Import the repository’s GPG key and add the Adoptium APT repository to your system:

Terminal
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://packages.adoptium.net/artifactory/deb/

Install Java 8 by running the following commands:

Terminal
sudo apt update
sudo apt install temurin-8-jdk

Once completed, verify it by printing the Java version :

Terminal
java -version

The output should look something like this:

output
openjdk version "1.8.0_402"
OpenJDK Runtime Environment Temurin-8.0.402+6 (build 1.8.0_402-b06)
OpenJDK 64-Bit Server VM Temurin-8.0.402+6 (build 25.402-b06, mixed mode)

Installing Apache Cassandra

We’ll install Apache Cassandra using the deb package from the vendor repository. To do so we, need to enable the Apache Cassandra repository.

Import the repository’s public key using the following wget command:

Terminal
wget -q -O - https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -

The command above should output OK. That means that the key has been successfully imported, and packages from this repository will be considered trusted.

Add the Cassandra repository to your system sources’ list by running the command below:

Terminal
sudo sh -c 'echo "deb https://archive.apache.org/dist/cassandra/debian/ 311x main" > /etc/apt/sources.list.d/cassandra.list'

Update the packages’ index and install the Apache Cassandra package:

Terminal
sudo apt update
sudo apt install cassandra

When the installation process is complete the Cassandra service will automatically start. To verify that Cassandra is running, type:

Terminal
nodetool status

You should see something similar to below:

output
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load        Tokens       Owns (effective)  Host ID                               Rack
UN  127.0.0.1  103.71 KiB  256          100.0%            dd8f6709-08ef-45b8-881e-5c1b5bbfc7f7  rack1

That’s it. Apache Cassandra has been successfully installed.

Configuring Apache Cassandra

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

By default, Cassandra listens on the localhost only. If the client connecting to the database is also running on the same machine, you don’t need to change the binding interface.

To interact with Cassandra through the command line, use the cqlsh tool, which is shipped with the Cassandra package.

Terminal
cqlsh
output
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.5 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> 

Renaming Apache Cassandra Cluster

By default, the Cassandra cluster is named “Test Cluster”. If you want to change it follow the steps below:

  1. Login to the Cassandra CQL terminal with cqlsh:

    Terminal
    cqlsh
  2. Issue the following command to change the cluster name to “Linuxize Cluster”:

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

    Change “Linuxize Cluster” with your desired name. Once done, type exit to exit the terminal.

  3. Edit the cassandra.yaml configuration file and put your new cluster name:

    /etc/cassandra/cassandra.yamlyaml
    cluster_name: 'Linuxize Cluster'
  4. Clear the system cache:

    Terminal
    nodetool flush system
  5. Restart the Cassandra service by running:

    Terminal
    sudo systemctl restart cassandra

Conclusion

We’ve shown you how to install Apache Cassandra Debian 10 and optionally rename the default cluster. For more information about how to get started with Cassandra, visit the official Documentation page.

If you hit a problem or have feedback, leave a comment below.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page