Installing Apache Cassandra on your Windows 10 or 11 system is now more straightforward, thanks to the Windows Subsystem for Linux (WSL). WSL allows you to run a Linux environment directly on Windows, making it easier to work with tools like Cassandra. Let’s walk through the updated steps to get Apache Cassandra 5.0 up and running on your machine.
Table of Contents
Step 1: Setting Up Windows Subsystem for Linux (WSL)
1. Enable WSL:
- Open PowerShell as Administrator: Right-click the Start button, select “Windows PowerShell (Admin)” to launch it with administrative privileges.
- Install WSL and Ubuntu: In the PowerShell window, type the following command and press Enter:
wsl --install -d Ubuntu
This command installs the latest version of WSL along with the Ubuntu distribution.
2. Restart Your Computer:
After the installation completes, you’ll be prompted to restart your system. Go ahead and do so to apply the changes.
3. Set Up Ubuntu:
- Launch Ubuntu: After rebooting, open Ubuntu from the Start menu. On the first run, it will set up the necessary files and prompt you to create a UNIX username and password.
Step 2: Installing Java (OpenJDK 17)
Apache Cassandra 5.0 requires Java Development Kit (JDK) 17 to function properly. Using an unsupported Java version can lead to errors when starting Cassandra. Follow these steps to install and verify Java on your system.
1. Update Package Lists
Before installing any software, it’s always a good practice to update your package lists. This ensures that you get the latest available version of OpenJDK from the Ubuntu repositories.
Run the following command in your Ubuntu terminal (inside WSL):
sudo apt-get update
- What this does:
- Fetches the latest package information from the Ubuntu repositories.
- Ensures that when you install OpenJDK 17, you get the latest stable version.
- Helps prevent installation issues caused by outdated package references.
2. Install OpenJDK 17
Now that your package lists are up-to-date, install OpenJDK 17 using the following command:
sudo apt-get install openjdk-17-jdk -y
- Breaking it down:
sudo
– Runs the command as a superuser (admin privileges).apt-get install
– Installs the specified package.openjdk-17-jdk
– The package name for Java Development Kit (JDK) 17.-y
– Automatically confirms installation, so you don’t have to press ‘Y’ manually.
- Why do we need JDK and not just JRE?
- JDK (Java Development Kit) includes the Java Runtime Environment (JRE) plus additional tools needed for running and compiling Java-based applications like Cassandra.
- JRE alone is not enough, as Cassandra uses Java compilation and debugging tools.
3. Verify the Installation
To confirm that Java was installed successfully, check the installed version:
java -version
If Java isn’t detected, the installation might have failed, or another version of Java might be set as default.
Expected Output:
After running this command, you should see an output similar to this:
openjdk version "17.0.9" 2024-01-15
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu, mixed mode)
Make sure it says “openjdk version 17”. If it shows an older version, Cassandra might not work correctly.
For more details, refer to the official Apache Cassandra installation guide.
Step 3: Installing Apache Cassandra 5.0
Now that Java 17 is set up, the next step is installing Apache Cassandra 5.0. Since Cassandra isn’t available in the default Ubuntu package repositories, we need to add the official Apache Cassandra repository, import the necessary keys, and then install the database.
1. Add the Apache Cassandra Repository
To install Cassandra, you need to add its official Debian repository to your sources list. Run the following command:
echo "deb https://downloads.apache.org/cassandra/debian 50x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
- What this does:
- Adds the Apache Cassandra repository URL to the system’s list of software sources.
tee -a
ensures that the repository is appended to thecassandra.sources.list
file.
- Why is this step necessary?
- Ubuntu’s default package sources don’t include Apache Cassandra.
- This command allows Ubuntu to recognize Cassandra as an installable package.
2. Import the Repository Keys
Before installing Cassandra, we need to import the security key that verifies the authenticity of the software package:
curl -o /etc/apt/keyrings/apache-cassandra.asc https://downloads.apache.org/cassandra/KEYS
- What this does:
- Downloads the official Cassandra public key and saves it to
/etc/apt/keyrings/apache-cassandra.asc
. - This key is used to verify that the downloaded Cassandra package is legitimate.
- Downloads the official Cassandra public key and saves it to
- Why is this step important?
- Ensures that you’re installing a trusted and untampered version of Cassandra.
- Without this step, Ubuntu may block the installation due to missing security signatures.
3. Update Package Lists Again
Since we added a new repository, we need to refresh the package list so Ubuntu recognizes Cassandra:
sudo apt-get update
- What this does:
- Re-fetches package lists from all configured repositories, including the newly added Cassandra repository.
- Ensures that the
apt-get install
command in the next step works correctly.
- Common issue:
- If you see “GPG error: NO_PUBKEY”, it means the repository key wasn’t added correctly. Try re-running the key import step.
4. Install Apache Cassandra
Now that the repository is set up and recognized, install Apache Cassandra using:
sudo apt-get install cassandra
- Breaking it down:
sudo
– Runs the command with administrative privileges.apt-get install
– Installs the specified package.cassandra
– The actual package name.
- What to expect during installation:
- The package manager will download and install Cassandra along with its dependencies.
- Once installed, Cassandra’s system service will be created but might not start automatically.
5. Start the Cassandra Service
To start the Cassandra service manually, run:
sudo systemctl start cassandra
- What this does:
- Starts Cassandra as a background service.
- Ensures the database is ready to accept connections.
- Optional:
- If you want Cassandra to start automatically whenever the system reboots, enable it with:
sudo systemctl enable cassandra
- If you want Cassandra to start automatically whenever the system reboots, enable it with:
6. Verify That Cassandra is Running
To confirm that Cassandra is active, check its status:
sudo systemctl status cassandra
- Expected output:
- You should see “active (running)” in green text.
- If it says “inactive” or “failed”, Cassandra may not have started properly.
Troubleshooting Tips
- WSL Installation Issues: If you encounter errors during the WSL installation, ensure that your Windows system is updated to the latest version. Additionally, verify that the Virtual Machine Platform and Windows Subsystem for Linux features are enabled in the Windows Features settings.
- Java Version Conflicts: If multiple Java versions are installed, you might face conflicts. Ensure that Java 17 is set as the default by checking the
JAVA_HOME
environment variable and updating it if necessary. - Cassandra Service Fails to Start: If the Cassandra service doesn’t start, check the logs located at
/var/log/cassandra/
for error messages. Common issues include incorrect configurations or insufficient system resources.
By following these updated steps, you should have Apache Cassandra 5.0 running smoothly on your Windows system via WSL. This setup leverages the latest versions as of 2025, ensuring optimal performance and compatibility.
FAQs
Can I install Apache Cassandra directly on Windows without WSL?
Apache Cassandra is designed for Linux-based environments, and running it directly on Windows can be challenging. The best way to install and use Cassandra on Windows is through Windows Subsystem for Linux (WSL), which allows you to run a Linux environment natively.
What version of Java do I need for Apache Cassandra?
Apache Cassandra 5.0 requires Java 17 (OpenJDK 17). Installing the wrong version may cause errors during startup. You can check your installed version by running java -version
in the terminal. If needed, install OpenJDK 17 using sudo apt install openjdk-17-jdk
.
How do I verify that Cassandra is installed correctly?
Once installed, you can check if Cassandra is running by entering cqlsh
in your Linux terminal. If everything is set up correctly, you should see the Cassandra Query Language Shell (CQLSH) prompt. If it fails, ensure that the Cassandra service is started using sudo systemctl start cassandra
.
What should I do if Cassandra fails to start?
First, check the logs using sudo journalctl -u cassandra --no-pager | tail -n 50
to identify any issues. Common problems include incorrect Java versions, missing dependencies, or incorrect permissions. Running sudo systemctl restart cassandra
can also help resolve startup issues.
How can I uninstall Apache Cassandra if needed?
To remove Cassandra from your system, first stop the service using sudo systemctl stop cassandra
. Then, remove the package with sudo apt remove cassandra
. If you want to remove all configuration files as well, use sudo apt purge cassandra
.
Can I run multiple Cassandra nodes on Windows?
Yes, but it’s more complicated. Running multiple Cassandra nodes requires configuring a multi-node cluster, which is best done in a Linux-based server environment. On Windows, it’s possible using multiple WSL instances, but it requires manual configuration of Cassandra’s cassandra.yaml
file.
How do I access Cassandra data from a Windows application?
You can connect to Cassandra from Windows applications using Cassandra drivers (Python, Java, Node.js, etc.). If using Python, install the cassandra-driver
package and connect using the appropriate IP address of your WSL instance. Always check firewall settings to allow connections between Windows and WSL.