How to Install Cassandra: Step-by-Step Tutorial
How to Install Cassandra: Step-by-Step Tutorial
Apache Cassandra is a powerful, open-source distributed NoSQL database designed to handle large amounts of data across many commodity servers, providing high availability and no single point of failure. This tutorial guides you through the installation process of Cassandra on different platforms and helps you get started quickly.
Prerequisites
- A system running Linux (Ubuntu, CentOS), Windows, or MacOS.
- Java Development Kit (JDK) 8 or later installed. Cassandra requires Java to run.
- Basic knowledge of command line interface (CLI).
- Internet connection to download packages.
Step 1: Install Java
Cassandra depends on Java. Ensure an appropriate version is installed:
- On Ubuntu/Linux:
sudo apt update
sudo apt install openjdk-11-jdk
java -version
Verify the installation by checking Java version.
- On Windows:
Download and install OpenJDK 11 or later from Eclipse Temurin (Official site). Then set JAVA_HOME environment variable.
- On MacOS:
brew install openjdk@11
brew link --force --overwrite openjdk@11
Step 2: Add Apache Cassandra Repository and Install
The installation differs slightly depending on your operating system.
On Ubuntu/Linux:
echo "deb https://downloads.apache.org/cassandra/debian 40x main" | sudo tee /etc/apt/sources.list.d/cassandra.list
curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
sudo apt update
sudo apt install cassandra
On Windows:
Download the latest binary from Apache Cassandra’s official website here (Official site). Unzip it, and set up PATH variables. No installer is provided; Cassandra runs via scripts inside the folder.
On MacOS:
You can use Homebrew to install:
brew install cassandra
Step 3: Start Cassandra Service
After installation, start the Cassandra service:
- Ubuntu/Linux (systemd):
sudo systemctl start cassandra
sudo systemctl status cassandra
- MacOS (Homebrew):
brew services start cassandra
- Windows:
Run cassandra.bat in the bin directory or use PowerShell to launch the service manually.
Step 4: Verify Cassandra Installation
Use the Cassandra Query Language shell (CQLSH) to verify:
cqlsh
If you get the prompt, Cassandra is running.
Step 5: Basic Configuration
Cassandra’s configuration files are usually located at /etc/cassandra/ or inside the installation directory on Windows/MacOS.
cassandra.yaml: Main configuration file to adjust cluster name, seeds, listen address, and other parameters.- Check
listen_addressandrpc_addressto ensure proper network binding.
Make backups of config files before making changes and restart Cassandra after modifications.
Troubleshooting Tips
- Ensure Java version is compatible (at least JDK 8).
- Check firewall settings that may block Cassandra ports (default 9042 for CQL).
- Check Cassandra logs at
/var/log/cassandra/(Linux) for errors. - Use
nodetool statusto check node health. - If
cqlshfails to connect, verify that Cassandra service is running and listening on ports.
Summary Checklist
- Installed Java JDK 8 or later.
- Added Apache Cassandra repository or downloaded binaries.
- Installed Cassandra according to OS.
- Started Cassandra service and verified with
cqlsh. - Checked and configured necessary network and cluster settings.
- Troubleshot any issues with logs and tools.
For more advanced setups and usage, explore cluster management and data modeling best practices.
Consider checking our related tutorials like How to Install Storm: A Step-by-Step Tutorial which shares similar setup principles for distributed data systems.
