TechBuzzPro

Install Apache Cassandra on Debian 10

· 4 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide walks you through installing Apache Cassandra, a highly scalable NoSQL database, on Debian 10 (Buster). By the end, you'll have a running single-node Cassandra cluster, with the service enabled to start at boot. You'll need a Debian 10 server or desktop with root or sudo access, and an internet connection to download the packages.

What You'll Need

  • A Debian 10 system (64-bit recommended)
  • Root access or a user with sudo privileges
  • Internet connection to fetch packages
  • At least 2 GB of RAM (more if you plan heavy workloads)
  • Java 8 or 11 (OpenJDK works fine)

Step-by-Step

  1. Update your system
    Open a terminal and run:
    sudo apt update && sudo apt upgrade -y
    This ensures your package list is current and all existing software is up to date.
  2. Install Java
    Cassandra requires Java. Install OpenJDK 11 (or 8 if you prefer):
    sudo apt install openjdk-11-jdk -y
    Verify the installation:
    java -version
    You should see output like openjdk version "11.0.x".
  3. Add the Apache Cassandra repository
    Cassandra provides its own apt repository. First, add the Apache repository key:
    curl -fsSL https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
    If curl is not installed, install it first: sudo apt install curl -y.
  4. Add the repository to sources.list
    Create a new source list file for Cassandra:
    echo "deb https://downloads.apache.org/cassandra/debian 40x main" | sudo tee /etc/apt/sources.list.d/cassandra.sources.list
    Replace 40x with the major version you want, e.g., 41x for Cassandra 4.1. For this guide, we'll use 41x (Cassandra 4.1).
  5. Update and install Cassandra
    Run:
    sudo apt update
    Then install Cassandra:
    sudo apt install cassandra -y
    This installs the latest Cassandra from the repository.
  6. Start and enable Cassandra
    After installation, start the service:
    sudo systemctl start cassandra
    Enable it to start on boot:
    sudo systemctl enable cassandra
  7. Verify the installation
    Check the service status:
    sudo systemctl status cassandra
    You should see active (running). Then test with the Cassandra query language shell:
    cqlsh
    If everything works, you'll see a prompt like cqlsh>. Type exit to leave.

Common Mistakes

  • Using the wrong repository version – The repository URL must match a valid Cassandra version (e.g., 40x or 41x). Using an invalid one will cause apt update to fail.
  • Forgetting to install Java – Cassandra won't start without Java. Ensure Java is installed before installing Cassandra.
  • Not updating after adding the repo – You must run sudo apt update after adding the repository, or apt won't see the new packages.
  • Running cqlsh before the service is up – Give Cassandra a few seconds to fully start before running cqlsh. If it fails, wait and try again.

Tips

  • Set the JAVA_HOME environment variable if you have multiple Java versions. Add export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 to your .bashrc.
  • For production, configure Cassandra's cassandra.yaml file (usually in /etc/cassandra) to set cluster name, seeds, and listen addresses.
  • Use nodetool status to check the health of your cluster. It shows each node's state and load.
  • If you plan to use Cassandra with a firewall, open port 9042 (for CQL) and 7000 (for inter-node communication).

Troubleshooting

  • Service fails to start
    Check logs: sudo journalctl -u cassandra -n 50. Common causes: insufficient memory, Java not found, or a corrupt config. Ensure Java is installed and that you have at least 2 GB free RAM.
  • cqlsh connection refused
    This usually means Cassandra isn't listening on port 9042. Verify with sudo netstat -tulpn | grep 9042. If nothing, the service may have crashed – check logs. Also try cqlsh 127.0.0.1.
  • apt update gives "The repository ... does not have a Release file"
    This means the repository URL is wrong or the version doesn't exist. Double-check the URL and the version code (e.g., 41x).
  • Java version mismatch
    Cassandra 4.x works with Java 8 or 11. If you have Java 17, it may not work. Install Java 11 and set it as default: sudo update-alternatives --config java.
  • Out of memory errors
    Cassandra's default heap size is 1 GB. If your system has less RAM, edit /etc/cassandra/cassandra-env.sh and reduce MAX_HEAP_SIZE and HEAP_NEWSIZE.

Frequently Asked Questions

Do I need to install Java separately?

Yes, Cassandra does not bundle Java. You must install a compatible JDK (8 or 11) before installing Cassandra.

Can I install Cassandra on Debian 10 without adding a repository?

The Debian repositories do not include Cassandra. You must use the official Apache repository to get the latest versions.

How do I change the cluster name?

Edit /etc/cassandra/cassandra.yaml and change the cluster_name property. Then restart Cassandra with sudo systemctl restart cassandra.

Is it safe to run Cassandra as root?

No, Cassandra should run as a non-root user. The installer creates a cassandra user automatically, and the service runs under that user by default.

How do I uninstall Cassandra?

Run sudo apt remove cassandra to remove the packages. To also delete data, remove /var/lib/cassandra and /etc/cassandra manually.

Can I run multiple Cassandra nodes on the same machine?

Technically yes, but it's not recommended for production. Each node needs separate data directories and ports. For testing, you can use Docker or separate VMs.