Guides 11792 Published by

This guide walks you through getting Apache Cassandra 4.x up and running on a fresh Rocky Linux 8 or 9 machine, beginning with installing JDK 17, adding the official Cassandra RPM repository, and then installing the daemon itself. Once installed it shows how to tweak the minimal `cassandra.yaml` for a single‑node cluster, enable the service at boot, open port 9042 in the firewall, and use `nodetool status` to confirm the node is up and normal. The article also offers quick fixes for common issues such as service failures, DNS misconfigurations, or port conflicts, plus a few production‑ready tuning knobs for read/write concurrency and commit‑log latency. Finally it reminds you that if anything seems off, the Cassandra logs usually hold a clear diagnostic message before the noise of startup chatter.



Install Apache Cassandra on Rocky Linux EL9/EL8

If you’re running a fresh Rocky Linux 8 or 9 server and need a NoSQL database that can scale to petabytes, this is how you get Cassandra up and humming without the usual “I don’t know why it keeps dying” headaches.

Why use Rocky Linux for Cassandra?

Rocky Linux ships with systemd, SELinux, and the same package management tools as RHEL. That means you can rely on CentOS‑style repos and get a stable, well‑supported environment for Cassandra 4.x or later.

1. Install prerequisites
sudo dnf install -y java-17-openjdk

Why it matters: Cassandra runs on the JVM; using JDK 17 is the current recommendation. A missing JRE will cause instant “java.lang.NoClassDefFoundError” crashes when you try to start the service.

2. Add the Apache repository
sudo dnf config-manager --add-repo https://repo.apache.org/dist/cassandra/4.1/rpm/

Why it matters: The official repo keeps all the latest packages and security patches in sync with the upstream project, so you avoid a half‑upgraded Cassandra that refuses to start.

3. Install Cassandra
sudo dnf install -y cassandra

If you hit “No matching Packages found,” double‑check the repo URL or switch to the centos subrepo if your version is older than 4.0.

4. Bootstrap initial configuration

Cassandra ships with a minimal config that only works on a single node. Open /etc/cassandra/cassandra.yaml and set:

cluster_name: 'MyCluster'
listen_address: localhost
rpc_address: localhost

Why it matters: Without those lines Cassandra will complain about “Unresolved DNS address” or refuse to bind its listening sockets.

5. Start and enable the service
sudo systemctl enable --now cassandra

If you see cassandra.service failed after this, run:

sudo journalctl -u cassandra --since "10 minutes ago"

Why it matters: The log will usually point to a port conflict (e.g., another process on 9042) or an SELinux denial. I’ve seen this happen when an old cassandra user from a previous installation still owns /var/lib/cassandra/commitlog.

6. Open the firewall
sudo firewall-cmd --permanent --add-port=9042/tcp
sudo firewall-cmd --reload

Why it matters: Cassandra’s native transport runs on port 9042 by default. Without opening this you can’t connect from another machine, even if the service is running.

7. Verify node status
nodetool status

You should see a single UN node (Up/Normal). If it says DN, the node failed to join the cluster due to configuration or networking issues.

Real‑world observation: I once got a DN after installing Cassandra on Rocky 9, only to discover that the machine’s hostname was set to an IPv6 address the node couldn’t resolve. Switching back to the short name fixed it instantly.

8. Basic tuning for production

Add the following to /etc/cassandra/cassandra.yaml:

concurrent_reads: 64
concurrent_writes: 128
commitlog_sync_batch_window_in_ms: 1000

Why it matters: These settings give a good balance between throughput and latency on modern multi‑core machines. If you’re running on an SSD, bump commitlog_sync to batch.

9. Common pitfalls
Symptom Likely cause Fix
“cassandra.service not loaded” after reboot The service was never enabled systemctl enable cassandra
nodetool status shows no nodes listen_address is set to localhost but you’re connecting from another host Set it to the actual IP or a DNS name
“Failed to bind port 9042” Another process (maybe Docker) uses that port Stop the conflicting service or change Cassandra’s listen_port in yaml
10. Wrap‑up

You’ve got a single‑node Cassandra cluster running on Rocky Linux, ready for the next step: scaling out, adding nodes, and writing your first keyspace.

If anything feels off—like unexpected timeouts or Too many connections errors—check /var/log/cassandra/system.log. The logs usually have a clear message; just scroll past the noise of “Starting Cassandra…”.