How to completely clear down, reset and restart a Cassandra cluster?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Apache Cassandra is a distributed NoSQL database designed to handle large amounts of data across many commodity servers while providing high availability with no single point of failure. Occasionally, you may need to completely clear, reset, and restart a Cassandra cluster, whether for maintenance or testing purposes. This article provides a step-by-step guide to achieve a clean reset of your Cassandra cluster, along with technical explanations and examples.
Prerequisites
Before proceeding with the steps to reset your Cassandra cluster, ensure the following prerequisites are met:
- Administrative access to all nodes in the Cassandra cluster
- Backups of any essential data, as these procedures will erase all stored data
- Understanding of the basic Cassandra architecture and operations
Steps to Clear and Reset a Cassandra Cluster
1. Backup Your Data
It's essential to back up any data you want to preserve. You can use Cassandra's snapshot feature:
This command will create a snapshot, which can later be used to restore data.
2. Stop the Cassandra Service
On all nodes, stop the Cassandra service. Depending on your system, you can use:
- For Debian/Ubuntu systems:
- For RedHat/CentOS systems:
3. Clear Data Directories
Cassandra stores its data in specific directories defined in cassandra.yaml. Typically, you’ll need to clear the following directories:
- Data files:
/var/lib/cassandra/data - Commit logs:
/var/lib/cassandra/commitlog - Saved caches:
/var/lib/cassandra/saved_caches
Execute the following commands on each node:
4. Clear Logs
Additionally, clear out any logs to reset the operational state:
5. Configuration Reset (Optional)
If you want to reset configuration files to default, you'll need to replace your current cassandra.yaml and other configuration files with default versions. This step might necessitate reinstallation if defaults are not available.
6. Verify Cluster Topology
Before restarting, check and verify the cluster topology. Your cassandra.yaml file should correctly reference each node's IP and settings, including seeds. Adjust these settings if needed:
7. Restart the Cassandra Service
After clearing all necessary data and optionally resetting configurations, restart the Cassandra service on all nodes:
- For Debian/Ubuntu systems:
- For RedHat/CentOS systems:
8. Rebuild the Cluster
With the service restarted, you may need to rebuild the cluster, especially if you have altered the topology. Use nodetool for managing and rebuilding the ring:
If necessary, decommission unnecessary nodes or bootstrap new ones based on the desired cluster setup.
9. Verify Cluster Status
Finally, confirm the cluster's status and ensure all nodes are operational. Use the command:
Summary Table
| Step Number | Action | Command/Procedure |
| 1 | Backup Data | nodetool snapshot <keyspace> -t my_backup |
| 2 | Stop Service | sudo service cassandra stop
sudo systemctl stop cassandra |
| 3 | Clear Data Directories | sudo rm -rf /var/lib/cassandra/data/*
sudo rm -rf /var/lib/cassandra/commitlog/* |
| 4 | Clear Logs | sudo rm -f /var/log/cassandra/* |
| 5 | Reset Configuration | Replace existing configs with default values if necessary |
| 6 | Verify Topology | Update and verify cassandra.yaml configurations |
| 7 | Restart Service | sudo service cassandra start
sudo systemctl start cassandra |
| 8 | Rebuild the Cluster | nodetool repair |
| 9 | Verify Cluster Status | nodetool status |
Additional Considerations
- Monitoring: Continuously monitor the cluster after restart to ensure there are no issues.
- Performance Tuning: Post-reset, revisit performance tuning for optimal operation.
- Security: Reapply any security configurations, such as setting up authentication and authorization.
A complete Cassandra cluster reset should be approached with caution, given its disruptive nature. Ensure that all stakeholders are aware of the reset and plan for potential downtime. Remember, meticulous planning and extensive backups will mitigate risks during this procedure.
Related reading
- How to completely uninstall kubernetes
- How to completely uninstall Minikube in windows 10 Pro? chocolatey
- How to config simple login/pass authentication for kubernetes desktop UI
- How to configure a Kubernetes Multi-Pod Deployment
- How to compute a 3D Morton number interleave the bits of 3 ints
- How to configure access permissions for Cassandra on Linux Ubuntu
- How to configure a non-default serviceAccount on a deployment
- How to configure Apache Tika in a kube environment to obtain maximum throughput when parsing a massive number of documents?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.