Installing Cassandra

Apache Cassandra can be installed on a number of Linux distributions:

  • AlmaLinux

  • Amazon Linux Amazon Machine Images (AMIs)

  • Debian

  • RedHat Enterprise Linux (RHEL)

  • SUSE Enterprise Linux

  • Ubuntu

This is not an exhaustive list of operating system platforms, nor is it prescriptive. However, users are well-advised to conduct exhaustive tests if using a less-popular distribution of Linux. Deploying on older Linux versions is not recommended unless you have previous experience with the older distribution in a production environment.

Prerequisites

  1. Verify the version of Java installed. For example:
  • Command

  • Result

  1. $ java -version
  1. openjdk version "11.0.20" 2023-07-18
  2. OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)
  3. OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
  • To use the CQL shell cqlsh, install the latest version of Python 3.7+.

To verify that you have the correct version of Python installed, type python --version.

Support for Python 2.7 is deprecated.

Choosing an installation method

There are three methods of installing Cassandra that are common:

  • Docker image

  • Tarball binary file

  • Package installation (RPM, YUM)

If you are a current Docker user, installing a Docker image is simple. You’ll need to install Docker Desktop for Mac, Docker Desktop for Windows, or have docker installed on Linux. Pull the appropriate image from the Docker Hub and start Cassandra with a docker run command.

For many users, installing the binary tarball is also a simple choice. The tarball unpacks all its contents into a single location with binaries and configuration files located in their own subdirectories. The most obvious advantage of a tarball installation is that it does not require root permissions and can be installed on any Linux distribution.

Packaged installations require root permissions, and are most appropriate for production installs. Install the RPM build on CentOS and RHEL-based distributions if you want to install Cassandra using YUM. Install the Debian build on Ubuntu and other Debian-based distributions if you want to install Cassandra using APT.

Note that both the YUM and APT methods required root permissions and will install the binaries and configuration files as the cassandra OS user.

Install with Docker

  1. Pull the docker image. For the latest image, use:

    1. docker pull cassandra:latest

    This docker pull command will get the latest version of the official Docker Apache Cassandra image available from the Dockerhub.

  2. Start Cassandra with a docker run command:

    1. docker run --name cass_cluster cassandra:latest

    The --name option will be the name of the Cassandra cluster created. This example uses the name cass_cluster.

  3. Start the CQL shell, cqlsh to interact with the Cassandra node created:

    1. docker exec -it cass_cluster cqlsh

Install tarball file

  1. Verify the version of Java installed. For example:
  • Command

  • Result

  1. $ java -version
  1. openjdk version "11.0.20" 2023-07-18
  2. OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)
  3. OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
  1. Download the binary tarball from one of the mirrors on the Apache Cassandra Download site. For example, to download Cassandra 4.0:

    1. $ curl -OL http://apache.mirror.digitalpacific.com.au/cassandra/4.0.0/apache-cassandra-4.0.0-bin.tar.gz

    The mirrors only host the latest versions of each major supported release. To download an earlier version of Cassandra, visit the Apache Archives.

  2. OPTIONAL: Verify the integrity of the downloaded tarball using one of the methods here. For example, to verify the hash of the downloaded file using GPG:

    • Command

    • Result

    1. $ gpg --print-md SHA256 apache-cassandra-4.0.0-bin.tar.gz
    1. apache-cassandra-4.0.0-bin.tar.gz: 28757DDE 589F7041 0F9A6A95 C39EE7E6
    2. CDE63440 E2B06B91 AE6B2006 14FA364D

    Compare the signature with the SHA256 file from the Downloads site:

    • Command

    • Result

    1. $ curl -L https://downloads.apache.org/cassandra/4.0.0/apache-cassandra-4.0.0-bin.tar.gz.sha256
    1. 28757dde589f70410f9a6a95c39ee7e6cde63440e2b06b91ae6b200614fa364d
  3. Unpack the tarball:

    1. $ tar xzvf apache-cassandra-4.0.0-bin.tar.gz

    The files will be extracted to the apache-cassandra-4.0.0/ directory. This is the tarball installation location.

  4. Located in the tarball installation location are the directories for the scripts, binaries, utilities, configuration, data and log files:

    1. <tarball_installation>/
    2. bin/ (1)
    3. conf/ (2)
    4. data/ (3)
    5. doc/
    6. interface/
    7. javadoc/
    8. lib/
    9. logs/ (4)
    10. pylib/
    11. tools/ (5)
    1location of the commands to run cassandra, cqlsh, nodetool, and SSTable tools
    2location of cassandra.yaml and other configuration files
    3location of the commit logs, hints, and SSTables
    4location of system and debug logs <5>location of cassandra-stress tool
  5. Start Cassandra:

    1. $ cd apache-cassandra-4.0.0/ && bin/cassandra

    This will run Cassandra as the authenticated Linux user.

  6. Monitor the progress of the startup with:

    • Command

    • Result

    1. $ tail -f logs/system.log

    Cassandra is ready when you see an entry like this in the system.log:

    +

    1. INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...

    See configuring Cassandra for configuration information.

  7. Check the status of Cassandra:

    1. $ bin/nodetool status

    The status column in the output should report UN which stands for “Up/Normal”.

    Alternatively, connect to the database with:

    1. $ bin/cqlsh

Install as Debian package

  1. Verify the version of Java installed. For example:
  • Command

  • Result

  1. $ java -version
  1. openjdk version "11.0.20" 2023-07-18
  2. OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)
  3. OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
  1. Add the Apache repository of Cassandra to the file cassandra.sources.list.

    The latest major version is 4.0 and the corresponding distribution name is 40x (with an “x” as the suffix). For older releases use:

    • 311x for C* 3.11 series

    • 30x for {30_version}

    • 22x for {22_version}

    • 21x for {21_version}

For example, to add the repository for version 4.0 (40x):

+

  1. $ echo "deb https://debian.cassandra.apache.org 42x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
  2. deb https://debian.cassandra.apache.org 42x main
  1. Add the Apache Cassandra repository keys to the list of trusted keys on the server:

    • Command

    • Result

    1. $ curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
    1. % Total % Received % Xferd Average Speed Time Time Time Current
    2. Dload Upload Total Spent Left Speed
    3. 100 266k 100 266k 0 0 320k 0 --:--:-- --:--:-- --:--:-- 320k
    4. OK
  2. Update the package index from sources:

    1. $ sudo apt-get update
  3. Install Cassandra with APT:

    1. $ sudo apt-get install cassandra
  4. Monitor the progress of the startup with:

    • Command

    • Result

    1. $ tail -f logs/system.log

    Cassandra is ready when you see an entry like this in the system.log:

    +

    1. INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...

    See configuring Cassandra for configuration information.

  5. Check the status of Cassandra:

    1. $ nodetool status

    The status column in the output should report UN which stands for “Up/Normal”.

    Alternatively, connect to the database with:

    1. $ cqlsh

Install as RPM package

  1. Verify the version of Java installed. For example:
  • Command

  • Result

  1. $ java -version
  1. openjdk version "11.0.20" 2023-07-18
  2. OpenJDK Runtime Environment Temurin-11.0.20+8 (build 11.0.20+8)
  3. OpenJDK 64-Bit Server VM Temurin-11.0.20+8 (build 11.0.20+8, mixed mode)
  1. Add the Apache repository of Cassandra to the file /etc/yum.repos.d/cassandra.repo (as the root user).

    The latest major version is 4.0 and the corresponding distribution name is 40x (with an “x” as the suffix). For older releases use:

    • 311x for C* 3.11 series

    • 30x for {30_version}

    • 22x for {22_version}

    • 21x for {21_version}

For example, to add the repository for version 4.0 (40x):

+

  1. [cassandra]
  2. name=Apache Cassandra
  3. baseurl=https://redhat.cassandra.apache.org/42x/
  4. gpgcheck=1
  5. repo_gpgcheck=1
  6. gpgkey=https://downloads.apache.org/cassandra/KEYS
  1. Update the package index from sources:

    1. $ sudo yum update
  2. Install Cassandra with YUM:

    1. $ sudo yum install cassandra

    A new Linux user cassandra will get created as part of the installation. The Cassandra service will also be run as this user.

  3. Start the Cassandra service:

    1. $ sudo service cassandra start
  4. Monitor the progress of the startup with:

    • Command

    • Result

    1. $ tail -f logs/system.log

    Cassandra is ready when you see an entry like this in the system.log:

    +

    1. INFO [main] 2019-12-17 03:03:37,526 Server.java:156 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...

    See configuring Cassandra for configuration information.

  5. Check the status of Cassandra:

    1. $ nodetool status

    The status column in the output should report UN which stands for “Up/Normal”.

    Alternatively, connect to the database with:

    1. $ cqlsh

Further installation info

For help with installation issues, see the Troubleshooting section.