Website Vidya
Linux & ServersStep-by-Step Guide

How to Install Apache Cassandra on Ubuntu 24.04

Learn how to install apache cassandra on ubuntu 24.04 with official Apache repositories, OpenJDK runtime, nodetool cluster checks, and cqlsh queries.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install Apache Cassandra on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Learn how to install apache cassandra on ubuntu 24.04 with official Apache repositories, OpenJDK runtime, nodetool cluster checks, and cqlsh queries.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Installing the Java Runtime Prerequisite (OpenJDK)
  • Step 2: Adding the Official Apache Cassandra APT Repository
Grounded in full engineering runbookWebsiteVidya AI Engine

When building global-scale internet services, Internet of Things (IoT) sensor pipelines, financial fraud detection systems, or high-velocity messaging platforms, traditional relational databases collapse under immense write volumes.

Apache Cassandra is a distributed, decentralized, highly scalable NoSQL wide-column database management system designed to handle massive volumes of data across multiple data centers with zero single point of failure.

Originally developed at Facebook and open-sourced under the Apache Software Foundation, Cassandra's masterless peer-to-peer ring architecture guarantees linear scalability and high availability.

Deploying Apache Cassandra on Ubuntu 24.04 LTS requires configuring a compatible Java runtime environment, integrating upstream Apache repositories, and tuning cluster parameters in cassandra.yaml.

Advertisement

In this guide, we walk through how to install apache cassandra on ubuntu 24.04, verify cluster health with nodetool, and execute Cassandra Query Language (CQL) operations.

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

Advertisement
  • A server or virtual machine running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
  • Minimum 4 GB RAM and 2 CPU cores (8 GB+ recommended for production).
  • A non-root user account with sudo administrative privileges.
  • Python 3 installed (required for the cqlsh command-line utility).

Step 1: Installing the Java Runtime Prerequisite (OpenJDK)

Apache Cassandra is written in Java and requires a compatible Java Virtual Machine (JVM).

Cassandra 5.0 and 4.x run natively on OpenJDK 11 or OpenJDK 17 LTS.

Install the OpenJDK runtime package using apt:

Verify that the Java binary is available on your system path:

Advertisement
# Update package index and install OpenJDK 17:
sudo apt update
sudo apt install -y openjdk-17-jre-headless

# Verify Java version:
java -version
# Expected output confirms:
# openjdk version "17.0.x" ...
# OpenJDK 64-Bit Server VM ...

Step 2: Adding the Official Apache Cassandra APT Repository

To install the latest verified stable release of Apache Cassandra, configure the official Apache Software Foundation APT repository.

First, install prerequisite network and encryption utilities:

Import the official Apache Cassandra GPG signing key into /etc/apt/keyrings/:

Add the repository definition specifying the Cassandra 5.0 release series (50x):

# Install repository transport tools:
sudo apt install -y curl gnupg apt-transport-https

# Ensure secure keyrings directory exists:
sudo mkdir -p /etc/apt/keyrings

# Download and dearmor Apache Cassandra GPG key:
curl -fsSL https://downloads.apache.org/cassandra/KEYS | \
  sudo gpg --dearmor -o /etc/apt/keyrings/cassandra-archive-keyring.gpg

# Add Cassandra 5.0 repository definition:
echo "deb [signed-by=/etc/apt/keyrings/cassandra-archive-keyring.gpg] https://debian.cassandra.apache.org 50x main" | \
  sudo tee /etc/apt/sources.list.d/cassandra.list

# Refresh APT repository cache:
sudo apt update

Step 3: Installing Apache Cassandra on Ubuntu 24.04

With the official repository configured, install the cassandra package using apt.

The package manager installs all database daemons, systemd service definitions, and the nodetool administration utility:

Start and enable the Cassandra service:

# Install Cassandra:
sudo apt install -y cassandra

# Enable service to launch automatically on boot:
sudo systemctl enable cassandra

# Verify service health:
sudo systemctl status cassandra
# Expected output confirms: Active: active (running)

Step 4: Verifying Cluster Status with nodetool

The primary diagnostic utility for managing Apache Cassandra nodes is nodetool.

Because Cassandra initializes its distributed ring topology asynchronously, wait 30–60 seconds after starting the daemon before checking cluster health.

Execute nodetool status to inspect the active node state:

Confirm that your node displays the status UN (Up and Normal):

# Check cluster node status:
sudo nodetool status

# Output confirms single-node ring:
# Datacenter: datacenter1
# =======================
# Status=Up/Down
# |/ State=Normal/Leaving/Joining/Moving
# --  Address    Load       Tokens  Owns (effective)  Host ID                               Rack
# UN  127.0.0.1  105.2 KiB  16      100.0%            a1b2c3d4-e5f6-7890-abcd-1234567890ab  rack1

Understanding Nodetool Status Flags

The two leading characters in the status table indicate the health of the node:

U indicates that the node is Up and online.

N indicates that the node is in the Normal operating state participating in the token ring.

Step 5: Connecting to the Database via cqlsh

Cassandra Query Language (CQL) provides a familiar SQL-like syntax for creating schemas, tables, and querying wide-column data.

Launch the interactive CQL shell utility (cqlsh):

Create a keyspace (the Cassandra equivalent of a database schema) and test table creation:

-- Launch cqlsh from terminal:
-- cqlsh

-- Inside cqlsh shell:
-- Connected to Test Cluster at 127.0.0.1:9042
-- [cqlsh 6.2.0 | Cassandra 5.0.0 | CQL spec 3.4.7]

-- Create a keyspace with SimpleStrategy replication:
CREATE KEYSPACE ecommerce_data WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};

-- Use the keyspace:
USE ecommerce_data;

-- Create a sample time-series orders table:
CREATE TABLE customer_orders (
    customer_id uuid,
    order_id timeuuid,
    product_name text,
    amount decimal,
    PRIMARY KEY (customer_id, order_id)
);

-- Describe the keyspace:
DESCRIBE KEYSPACE ecommerce_data;

-- Exit shell:
QUIT;

Step 6: Configuring Firewall Rules for Multi-Node Clusters

In single-node development, Cassandra binds strictly to localhost (127.0.0.1).

In multi-node production clusters, configure UFW to allow inter-node gossip (port 7000) and client CQL connections (port 9042) strictly from authorized cluster IP addresses:

Review this port reference table for Cassandra services:

Port NumberProtocolDefault PurposeExposure Recommendation
7000TCPIntra-node cluster communication (Gossip)Strictly internal cluster VPC nodes only
7001TCPTLS encrypted intra-node communicationStrictly internal cluster VPC nodes only
9042TCPCQL native transport client portApplication servers only (protected by UFW)
7199TCPJMX monitoring portLocalhost only (or authenticated monitoring agents)

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': ...})

Cause: Cassandra daemon is still in the middle of JVM initialization or failed due to low RAM.

Resolution: Wait 60 seconds and check /var/log/cassandra/system.log to confirm initialization completed.

sudo tail -n 50 /var/log/cassandra/system.log

Cassandra fails to start: Insufficient memory (OOM)

Cause: JVM heap exceeded available physical RAM on the system.

Resolution: Edit /etc/cassandra/jvm11-server.options or /etc/cassandra/jvm17-server.options and reduce max heap size (e.g. -Xmx2G -Xms2G).

free -m

cqlsh: command not found

Cause: Python 3 is missing or python3-cqlsh was not symlinked.

Resolution: Install python3: sudo apt install -y python3 python3-pip.

which python3

Security Best Practices and Hardening

Never expose Cassandra ports (7000, 7199, 9042) to the public internet; always isolate nodes inside private VPC subnets with strict UFW rules.

Enable internal authentication in /etc/cassandra/cassandra.yaml by changing authenticator: AllowAllAuthenticator to PasswordAuthenticator.

Change the default superuser credentials (cassandra / cassandra) immediately after enabling password authentication.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
Cassandra uses a peer-to-peer distributed architecture based on a Dynamo ring where all nodes play identical roles. Gossip protocols constantly exchange state across the cluster, and configurable replication factors guarantee data availability even if multiple nodes fail simultaneously.
A keyspace is the top-level container defining replication strategy and replication factor across data centers (similar to a database in SQL). A table (formerly column family) resides inside a keyspace and defines the partition key, clustering columns, and data attributes.
For enterprise production workloads, nodes typically require at least 16 GB to 32 GB of RAM, with 8 GB allocated to the JVM heap and the remainder dedicated to the Linux page cache for fast OS-level disk reads.
Cassandra stores SSTable data files in /var/lib/cassandra/data/, commit logs in /var/lib/cassandra/commitlog/, and operational logs in /var/log/cassandra/.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout