Apache Cassandra is a distributed NoSQL database designed for high availability and linear scalability. It handles large volumes of data across commodity servers without a single point of failure, making it ideal for applications that require fault tolerance, low-latency writes, and the ability to scale horizontally. Additionally, common use cases include time-series data storage, real-time analytics, messaging platforms, and any application where uptime and write performance are critical.
This guide walks through installing Apache Cassandra on Rocky Linux 8, 9, or 10 using the official Apache RPM repository. By the end, you will have a working Cassandra installation with the cqlsh command-line client configured and a systemd service for process management.
Choose Your Cassandra Version
Apache Cassandra offers multiple release branches with different support timelines. The table below summarizes the available options to help you choose the right version for your deployment.
| Version | Status | Java Requirement | Best For |
|---|---|---|---|
| 5.0 | Latest GA (current) | Java 11 or 17 | New deployments wanting latest features |
| 4.1 | Previous stable | Java 8, 11, or 17 | Production systems needing proven stability |
| 4.0 | Older stable | Java 8, 11, or 17 | Legacy compatibility or specific version requirements |
For most new deployments, Cassandra 5.0 is recommended as it includes performance improvements, new features, and receives active development. This guide uses Cassandra 5.0 by default, but provides alternative repository configurations for 4.1 and 4.0 if you need them.
Update Rocky Linux System Packages
Before installing Cassandra, first update your system packages to ensure you have the latest security patches and dependency versions. This step helps prevent compatibility issues during installation.
sudo dnf upgrade --refresh
After the upgrade completes, next proceed to install the Java runtime that Cassandra requires.
Install Java OpenJDK
Apache Cassandra is a Java application and therefore requires a compatible Java Development Kit (JDK) to run. Cassandra 5.0 supports Java 11 or Java 17, while earlier versions also support Java 8. Additionally, install the headless variant to minimize disk usage on servers without graphical interfaces.
Rocky Linux 9:
sudo dnf install java-17-openjdk-headless -y
Rocky Linux 8:
sudo dnf install java-11-openjdk-headless -y
Next, verify the installation by checking the Java version:
java -version
openjdk version "11.x.x" or "17.x.x" OpenJDK Runtime Environment (Red_Hat-...) (build ...) OpenJDK 64-Bit Server VM (Red_Hat-...) (build ..., mixed mode, sharing)
Rocky Linux 10: Install Eclipse Temurin 17
Rocky Linux 10 only includes Java 21 in its default repositories, which Cassandra does not yet support. Therefore, to install the required Java 17, add the Eclipse Temurin repository from Adoptium, which provides enterprise-quality OpenJDK builds.
First, create the Adoptium repository configuration:
sudo tee /etc/yum.repos.d/adoptium.repo <<EOF
[Adoptium]
name=Adoptium
baseurl=https://packages.adoptium.net/artifactory/rpm/centos/10/x86_64
enabled=1
gpgcheck=1
gpgkey=https://packages.adoptium.net/artifactory/api/gpg/key/public
EOF
Rocky Linux 10 is binary-compatible with RHEL 10 and CentOS 10. The Adoptium repository uses the CentOS 10 path because Rocky 10 is not yet directly listed, but the packages work identically.
Install Eclipse Temurin 17:
sudo dnf install temurin-17-jdk -y
Then, verify the installation by checking the Java version:
java -version
openjdk version "17.x.x" 2025-xx-xx OpenJDK Runtime Environment Temurin-17.x.x+xx (build 17.x.x+xx) OpenJDK 64-Bit Server VM Temurin-17.x.x+xx (build 17.x.x+xx, mixed mode, sharing)
Add the Apache Cassandra Repository
Apache provides official RPM packages through their repository. Add the repository configuration file to your system to enable package installation via DNF. Choose the version that matches your requirements.
Cassandra 5.0 Repository (Recommended)
Create the repository configuration for the latest Cassandra 5.0 release:
sudo tee /etc/yum.repos.d/cassandra.repo <<EOF
[cassandra]
name=Apache Cassandra
baseurl=https://redhat.cassandra.apache.org/50x/
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://downloads.apache.org/cassandra/KEYS
EOF
The
repo_gpgcheck=0setting disables repository metadata signature verification. The Apache KEYS file contains multiple developer keys that can cause parsing failures with DNF. Package signatures are still verified viagpgcheck=1, maintaining security for the actual RPM files.
Cassandra 4.1 Repository (Alternative)
Alternatively, if you need the previous stable release for compatibility reasons, use the 4.1 repository instead:
sudo tee /etc/yum.repos.d/cassandra.repo <<EOF
[cassandra]
name=Apache Cassandra
baseurl=https://redhat.cassandra.apache.org/41x/
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://downloads.apache.org/cassandra/KEYS
EOF
Cassandra 4.0 Repository (Alternative)
Similarly, for the older stable release, use the 4.0 repository:
sudo tee /etc/yum.repos.d/cassandra.repo <<EOF
[cassandra]
name=Apache Cassandra
baseurl=https://redhat.cassandra.apache.org/40x/
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://downloads.apache.org/cassandra/KEYS
EOF
Install Apache Cassandra
With the repository configured, you can now install the Cassandra package using DNF. The package manager will automatically import the GPG keys and resolve dependencies.
sudo dnf install cassandra -y
During installation, you may see prompts to import GPG keys from Apache. Simply accept these to proceed with the installation.
Once complete, subsequently verify the installed version:
cassandra -v
5.0.6
Troubleshoot GPG Key Import Failures
On Rocky Linux 8, however, you may encounter GPG key import failures due to stricter crypto policies. If you see an error like Key import failed (code 2) or GPG check FAILED, temporarily disable GPG verification to complete the installation:
sudo dnf install cassandra -y --nogpgcheck
Using
--nogpgcheckbypasses package signature verification for this installation. Only use this flag if the standard installation fails with GPG errors. Avoid theupdate-crypto-policies --set LEGACYapproach, as it weakens system-wide cryptographic security and requires a reboot.
Create the Cassandra Systemd Service
The Apache Cassandra RPM package does not include a systemd service file by default. Therefore, to manage Cassandra as a system service with automatic startup, you need to create a custom service unit file.
sudo tee /etc/systemd/system/cassandra.service <<EOF
[Unit]
Description=Apache Cassandra
After=network.target
[Service]
Type=simple
PIDFile=/var/run/cassandra/cassandra.pid
User=cassandra
Group=cassandra
ExecStart=/usr/sbin/cassandra -f -p /var/run/cassandra/cassandra.pid
Restart=always
[Install]
WantedBy=multi-user.target
EOF
This service file runs Cassandra in the foreground (-f flag) under the cassandra user account, which was created during package installation. Furthermore, the Restart=always directive ensures the service recovers automatically from crashes.
After creating the service file, reload the systemd daemon to recognize the new unit:
sudo systemctl daemon-reload
Start and Enable the Cassandra Service
Start the Cassandra service:
sudo systemctl start cassandra
Then, check that the service is running correctly:
systemctl status cassandra
● cassandra.service - Apache Cassandra
Loaded: loaded (/etc/systemd/system/cassandra.service; enabled; preset: disabled)
Active: active (running) since ...
Main PID: xxxxx (java)
...
Cassandra requires 30-60 seconds to fully initialize. Consequently, the service status should show active (running) only after startup completes.
Finally, to enable automatic startup on boot:
sudo systemctl enable cassandra
Install the Cassandra Query Language Shell (cqlsh)
The Cassandra package includes a bundled cqlsh client, but it may fail to run due to Python path configuration issues on Rocky Linux. The most reliable approach is to install cqlsh separately using Python’s pip package manager.
Install Python and pip
First, ensure Python 3 and pip are installed:
sudo dnf install python3 python3-pip -y
Install cqlsh via pip
Next, install the standalone cqlsh package, which includes the Cassandra Python driver:
pip3 install --user cqlsh
The --user flag installs the package to your home directory, thereby avoiding permission issues and conflicts with system packages. Additionally, add the local bin directory to your PATH if it is not already included:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Finally, verify the cqlsh installation:
cqlsh --version
cqlsh 6.2.1
Connect to the Cassandra Database
Now, connect to the local Cassandra instance using cqlsh. Ensure the Cassandra service has fully started (wait at least 30 seconds after starting the service) before attempting to connect:
cqlsh
Connected to Test Cluster at 127.0.0.1:9042 [cqlsh 6.2.1 | Cassandra 5.0.6 | CQL spec 3.4.7 | Native protocol v5] Use HELP for help. cqlsh>
Type exit or press Ctrl+D to disconnect from the shell.
Configure Apache Cassandra
Cassandra stores its configuration files in /etc/cassandra/conf/. The main configuration file is cassandra.yaml, which controls cluster settings, networking, storage paths, and performance parameters. Data is stored in /var/lib/cassandra/ and logs are written to /var/log/cassandra/.
By default, Cassandra listens on several ports: 9042 (CQL client connections), 7000 (inter-node cluster communication), and 7199 (JMX monitoring). On a single-node development setup, these ports are bound to localhost and pose minimal risk. For production deployments or multi-node clusters, configure firewall rules to restrict access to trusted networks only.
JVM Configuration
For JVM-level adjustments such as heap size and garbage collection settings, instead edit the /etc/cassandra/conf/cassandra-env.sh file. You can then add JVM arguments to the JVM_OPTS variable, which Cassandra reads at startup.
Enable User Authentication
By default, Cassandra allows unauthenticated access, which is acceptable for development but should be changed for production deployments. Before modifying the configuration, first create a backup:
sudo cp /etc/cassandra/conf/cassandra.yaml /etc/cassandra/conf/cassandra.yaml.backup
Then, open the configuration file for editing:
sudo nano /etc/cassandra/conf/cassandra.yaml
Next, locate and modify the following parameters to enable password authentication:
authenticator: org.apache.cassandra.auth.PasswordAuthenticator
authorizer: org.apache.cassandra.auth.CassandraAuthorizer
roles_validity_in_ms: 0
permissions_validity_in_ms: 0
Setting the validity values to 0 disables caching of role and permission information, which is useful during initial setup. However, in production, you may want to increase these values to reduce authentication overhead.
Finally, save the file and restart Cassandra to apply the changes:
sudo systemctl restart cassandra
Create an Administrative Superuser
After enabling authentication, the default credentials are cassandra / cassandra. First, connect using these credentials:
cqlsh -u cassandra -p cassandra
Next, create a new superuser account. Replace admin and your_secure_password with your desired username and a strong password:
CREATE ROLE admin WITH PASSWORD = 'your_secure_password' AND SUPERUSER = true AND LOGIN = true;
Then, exit the shell and reconnect with your new account:
cqlsh -u admin -p your_secure_password
Subsequently, disable the default cassandra account to prevent unauthorized access:
ALTER ROLE cassandra WITH PASSWORD = 'disabled_account' AND SUPERUSER = false AND LOGIN = false;
REVOKE ALL PERMISSIONS ON ALL KEYSPACES FROM cassandra;
Finally, grant full permissions to your new administrative account:
GRANT ALL PERMISSIONS ON ALL KEYSPACES TO admin;
Configure Automatic Login
To avoid entering credentials each time you connect, you can configure a cqlshrc file. First, create the directory and copy the sample configuration:
mkdir -p ~/.cassandra
sudo cp /etc/cassandra/conf/cqlshrc.sample ~/.cassandra/cqlshrc
sudo chown $USER:$USER ~/.cassandra/cqlshrc
chmod 600 ~/.cassandra/cqlshrc
Then, edit the file to add your credentials:
nano ~/.cassandra/cqlshrc
Next, locate the [authentication] section and add your username and password:
[authentication]
username = admin
password = your_secure_password
Storing passwords in plain text files carries security risks. Ensure the cqlshrc file has restrictive permissions (
chmod 600) and consider using environment variables or a secrets manager for production environments.
Rename the Cluster
The default cluster name is “Test Cluster,” which should be changed for production deployments. First, update the system table:
cqlsh
UPDATE system.local SET cluster_name = 'Production Cluster' WHERE KEY = 'local';
Next, exit cqlsh and update the cluster name in the cassandra.yaml configuration file:
sudo nano /etc/cassandra/conf/cassandra.yaml
Then, find the cluster_name setting near the top of the file and change it to match:
cluster_name: 'Production Cluster'
Finally, flush the system keyspace and restart Cassandra to apply the change:
nodetool flush system
sudo systemctl restart cassandra
When you reconnect to cqlsh, the new cluster name will be displayed in the connection banner.
Update Apache Cassandra
Updates within the same minor version series (e.g., 5.0.5 to 5.0.6) are delivered through the configured repository and therefore can be applied using standard DNF commands:
sudo dnf upgrade cassandra -y
After upgrading, subsequently restart the Cassandra service to load the new version:
sudo systemctl restart cassandra
Then, verify the updated version:
cassandra -v
For major version upgrades (e.g., 4.1 to 5.0), consult the official Apache Cassandra documentation for migration procedures. Major upgrades may require data format migrations and configuration changes.
Remove Apache Cassandra
If you need to uninstall Cassandra from your system, follow these steps to remove the package and clean up associated files.
Stop and Disable the Service
To begin, stop the Cassandra service and disable it from starting on boot:
sudo systemctl stop cassandra
sudo systemctl disable cassandra
Remove the Cassandra Package
Uninstall the Cassandra package:
sudo dnf remove cassandra -y
Remove the Repository and Systemd Service
Delete the repository configuration file and the custom systemd service:
sudo rm -f /etc/yum.repos.d/cassandra.repo
sudo rm -f /etc/systemd/system/cassandra.service
sudo systemctl daemon-reload
Additionally, on Rocky Linux 10, also remove the Adoptium repository and Temurin package if no longer needed:
sudo dnf remove temurin-17-jdk -y
sudo rm -f /etc/yum.repos.d/adoptium.repo
Remove Data Directories (Optional)
The following commands permanently delete all Cassandra data, including databases, commit logs, and saved caches. Back up any important data before proceeding.
sudo rm -rf /var/lib/cassandra
sudo rm -rf /var/log/cassandra
sudo rm -rf /etc/cassandra
Furthermore, to remove the pip-installed cqlsh client:
pip3 uninstall cqlsh cassandra-driver -y
Also, remove any user-level cqlsh configuration files:
rm -rf ~/.cassandra
Finally, verify that Cassandra has been removed:
cassandra -v
bash: cassandra: command not found
Troubleshooting
Cassandra Service Fails to Start
If the service fails to start, check the system logs for error messages:
journalctl -xeu cassandra.service
Common causes typically include insufficient memory (Cassandra requires at least 2GB RAM by default), incorrect file permissions on data directories, or Java version incompatibilities.
Connection Refused When Using cqlsh
If cqlsh reports “Connection refused,” ensure Cassandra has fully started. The service can take 30-60 seconds to initialize. Check the service status and wait for it to complete startup:
systemctl status cassandra
Alternatively, you can also monitor the Cassandra log file for startup progress:
tail -f /var/log/cassandra/system.log
Look for a message containing “Startup complete” to confirm the service is ready to accept connections.
GPG Key Import Errors During Installation
If DNF reports GPG key import failures, this typically occurs on Rocky Linux 8 due to stricter crypto policies. In such cases, use the --nogpgcheck flag as a workaround:
sudo dnf install cassandra -y --nogpgcheck
Conclusion
You now have Apache Cassandra running on Rocky Linux with a custom systemd service, the cqlsh client for database interaction, and password authentication enabled. From here, you can create keyspaces and tables, add nodes to form a cluster, or tune performance settings in cassandra.yaml. For production deployments, configure firewall rules for ports 9042 (CQL) and 7000 (inter-node) and schedule regular backups of your data directories.