Cassandra Installation

Installing Cassandra on your machine takes less than 15 minutes. This topic covers installation on Linux (Ubuntu/Debian) and macOS, plus a Docker-based option for any operating system. By the end, you will have a running Cassandra node ready to accept your first commands.

Prerequisites

Cassandra runs on the Java Virtual Machine (JVM). You need Java installed before Cassandra can start. Cassandra 4.x requires Java 11. Cassandra 5.x supports Java 11 and Java 17.

Check Your Java Version

java -version

The output should show a version number like openjdk version "11.0.x". If Java is not installed, install it first using the steps below.

Install Java on Ubuntu/Debian

sudo apt update
sudo apt install -y openjdk-11-jdk
java -version

Install Cassandra on Ubuntu/Debian

Step 1: Add the Apache Cassandra Repository

echo "deb https://debian.cassandra.apache.org 41x main" \
  | sudo tee /etc/apt/sources.list.d/cassandra.sources.list

The URL above uses 41x for Cassandra 4.1. Replace with 50x for Cassandra 5.0 if needed.

Step 2: Add the GPG Key

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

Step 3: Install Cassandra

sudo apt update
sudo apt install -y cassandra

Step 4: Start the Service

sudo systemctl start cassandra
sudo systemctl enable cassandra

Step 5: Check That Cassandra Is Running

nodetool status

You should see a table showing one node with status UN (Up and Normal).

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load    Tokens  Owns    Host ID                               Rack
UN  127.0.0.1  100 KB  256     100.0%  a1b2c3d4-...                          rack1

Install Cassandra on macOS (using Homebrew)

Step 1: Install Homebrew (if not installed)

/bin/bash -c \
  "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install Cassandra

brew install cassandra

Step 3: Start Cassandra

brew services start cassandra

Step 4: Verify the Installation

nodetool status

Install Cassandra Using Docker (Any OS)

Docker lets you run Cassandra inside a container without modifying your system. This is the fastest way to get started on Windows, macOS, or Linux.

Step 1: Pull the Cassandra Image

docker pull cassandra:4.1

Step 2: Run a Cassandra Container

docker run --name my-cassandra -d cassandra:4.1

Step 3: Open the CQL Shell Inside the Container

docker exec -it my-cassandra cqlsh

You should now see the CQL prompt, which means Cassandra is running and ready.

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 6.1.0 | Cassandra 4.1.x | CQL spec 3.4.6]
Use HELP for help.
cqlsh>

Important Configuration Files

File                        Purpose
─────────────────────────────────────────────────────────────
cassandra.yaml              Main configuration file
cassandra-env.sh            JVM memory settings
cassandra-rackdc.properties Data center and rack names
logback.xml                 Logging configuration

Default File Locations on Linux

/etc/cassandra/cassandra.yaml
/var/lib/cassandra/data/        (data files)
/var/log/cassandra/system.log   (log file)

Key cassandra.yaml Settings for Beginners

cluster_name

This is the name of your cluster. All nodes you add later must use the same cluster name.

cluster_name: 'MyCluster'

seeds

Seed nodes help new nodes find and join the ring. You list at least one stable node IP address here.

seed_provider:
  - class_name: org.apache.cassandra.locator.SimpleSeedProvider
    parameters:
      - seeds: "127.0.0.1"

listen_address

This is the IP address other nodes use to communicate with this node.

listen_address: 127.0.0.1

Stop and Restart Cassandra

sudo systemctl stop cassandra
sudo systemctl start cassandra
sudo systemctl restart cassandra

View Cassandra Logs

tail -f /var/log/cassandra/system.log

Uninstall Cassandra

sudo systemctl stop cassandra
sudo apt remove --purge cassandra
sudo rm -rf /var/lib/cassandra /etc/cassandra

Summary

Installing Cassandra requires Java as a prerequisite. You can install it via the APT package manager on Ubuntu, via Homebrew on macOS, or via Docker on any platform. After installation, nodetool status confirms that your node is up and running normally. The next step is connecting to your node through the CQL shell and running your first commands.

Leave a Comment

Your email address will not be published. Required fields are marked *