How to Install Apache Cassandra on Ubuntu Linux

In this blog post, we'll walk through installing Apache Cassandra on an Ubuntu Linux server using the apt package manager. We'll also be locking its version to prevent accidental upgrades.

How to Install Apache Cassandra on Ubuntu Linux
Photo by Gabriel Heinzer / Unsplash

Contents


Prerequisites:

  • An Ubuntu Linux distribution is installed on a server or virtual machine.
  • Root access or a user account with sudo privileges (In this example, we're using a user account with sudo privileges).

Let's get started!


Update Your System

Before installing Apache Cassandra, updating your system is vital. Open a terminal and run the following command:

sudo apt update && sudo apt upgrade -y

Install a Java Development Kit (JDK)

Apache Cassandra requires Java to be installed on your system. Install OpenJDK 8 or OpenJDK 11 using one of the following commands:

sudo apt install openjdk-8-jdk -y

or

sudo apt install openjdk-11-jdk -y

Apache Cassandra / Java Version Matrix

  • Apache Cassandra 3.11
    • Java 8 is the recommended version for Cassandra 3.11.
      Java 11 is also supported, but it is not as widely used and tested as Java 8.
  • Apache Cassandra 4.0 and 4.1
    • Java 8 and Java 11 are both supported and recommended for this version of Cassandra.

Verify the Java installation by running the following:

java -version

Add the Apache Cassandra Repository

To add the Apache Cassandra repository, run the following commands:

echo "deb http://www.apache.org/dist/cassandra/debian <version> main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list

curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
  • Replace with the desired Cassandra version (e.g., 311x for 3.11, 40x for 4.0, or 41x for 4.1).
Note: The APT repository will differ based on the version of Cassandra you want to install. Replace  in the echo line with the appropriate version code (e.g., 311x for 3.11, 40x for 4.0, or 41x for 4.1).
  • Update the package list:
sudo apt update

Install Apache Cassandra

Now that the repository is set up install Apache Cassandra using the following command:

sudo apt install cassandra -y
⚠️ APT only installs the latest version of Cassandra available in the repository. Unfortunately, you cannot directly install a specific version of Cassandra using APT.

Lock the Apache Cassandra Version

Lock the Apache Cassandra version to prevent accidental upgrades of Apache Cassandra, you can lock its version using the apt-mark command. First, check the installed version of Cassandra:

apt-cache policy cassandra

Lock the Apache Cassandra version by running the following:

sudo apt-mark hold cassandra

You can confirm that the version is locked by checking the status of the package:

apt-mark showhold

To unlock the version in the future, use the following command:

sudo apt-mark unhold cassandra

Congratulations! You have successfully installed Apache Cassandra on your Ubuntu Linux distribution and locked its version to prevent accidental upgrades. Please consult the official documentation for further instructions to start the Cassandra process.

Here is the official Apache Cassandra documentation link for further configuration, usage, and maintenance information.

Stay tuned for our blog post covering basic configuration settings for Apache Cassandra.