Installing Apache Cassandra 3.x on Debian-based systems

Install using APT repositories on Debian and Ubuntu.

The latest version of Cassandra 3.x is 3.11.5.

Use these steps to install Apache Cassandra using APT repositories on Debian and Ubuntu Linux.

Prerequisites

  • APT (Advanced Package Tool) is installed.
  • Root or sudo access to the install machine.
  • Python 2.7 if using cqlsh.
  • DataStax recommends using the latest version of either OpenJDK 8 or Oracle Java Platform, Standard Edition 8 (JDK).

The packaged releases create a cassandra user. When starting Cassandra as a service, the service runs as this user.

Procedure

In a terminal window:
  1. Check which version of Java is installed by running the following command:
    java -version
    DataStax recommends using the latest version of Java 8 on all nodes. See Installing the JDK and Python 2.7.
  2. Add the Apache Cassandra repository to the /etc/apt/sources.list.d/cassandra.sources.list:
    echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
  3. If using Oracle Java on Debian systems:
    1. In /etc/apt/sources.list, find the line that describes your source repository for Debian and add contrib non-free to the end of the line. For example:
      deb http://some.debian.mirror/debian/ $distro main contrib non-free
      This allows installation of the Oracle JVM instead of the OpenJDK JVM.
    2. Save and close the file when you are done adding/editing your sources.
  4. Add the Apache Cassandra repository key to your aptitude trusted keys.
    curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
  5. Install the packages:
    Note: Apache Cassandra only provides the latest patch version. If you need to install an earlier patch version, contact DataStax Support.
    sudo apt-get update
    If you encounter this error:
    GPG error: http://dl.bintray.com/apache/cassandra 311x InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A278B781FE4B2BDA
    1. Add the public key A278B781FE4B2BDA as follows:
      sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA
      Note: The key may be different. If this happens, use key listed in the error message. For a full list of Apache contributors public keys, refer to https://www.apache.org/dist/cassandra/KEYS.
    2. Update the packages:
      sudo apt-get update
  6. Install Cassandra:
    sudo apt-get install cassandra
  7. Install the optional tools:
    sudo apt-get install cassandra-tools=3.11.x.x ## Optional utilities
  8. Because the Debian packages start the Cassandra service automatically, you must stop the server and clear the data:

    Doing this removes the default cluster_name (Test Cluster) from the system table. All nodes must use the same cluster name.

    sudo service cassandra stop
    sudo rm -rf /var/lib/cassandra/*
    Cassandra is ready for configuration.
  9. Optional: To change the location of the default directories (/var/lib/cassandra), see the following in /etc/cassandra/conf/cassandra.yaml:
  10. Optional: To change the location of the log files (/var/log/cassandra), replace the path to the log directory in /usr/sbin/cassandra:
    if [ -z "$CASSANDRA_LOG_DIR" ]; then
      CASSANDRA_LOG_DIR=/var/log/cassandra
    fi

What's next