✅ Day 11: Backups, Snapshots, and Monitoring in Cassandra
๐ฏ Objective:
Learn how to take backups, restore data using snapshots, and monitor a Cassandra node using nodetool.
๐ฆ 1. Backups via Snapshots
➤ What is a Snapshot?
A snapshot is a backup of the SSTable files (on-disk data) at a certain point in time.
➤ Take a Snapshot:
nodetool snapshot test_lab
๐ Snapshot files will be saved under:
/var/lib/cassandra/data/<keyspace>/<table>/snapshots/
♻️ 2. Restore from Snapshot
➤ Steps:
- Stop Cassandra:
sudo systemctl stop cassandra
- Copy snapshot files into the main table folder:
cp -R /var/lib/cassandra/data/test_lab/employee/snapshots/<snapshot_name>/* \
/var/lib/cassandra/data/test_lab/employee/
- Clear commit logs (optional for full restore)
- Restart Cassandra:
sudo systemctl start cassandra
- Run
SELECT *to verify data is back.
๐ 3. Monitoring with nodetool
➤ Status of the Node:
nodetool status
➤ Disk Usage:
nodetool cfstats
➤ View running compactions:
nodetool compactionstats
➤ View pending tasks and activity:
nodetool tpstats
๐งช 4. Optional: Enable Logging & Metrics
- Cassandra logs:
/var/log/cassandra/system.log - Enable JMX for metrics monitoring tools like Prometheus, Grafana
๐งช Day 11 Lab Tasks
- Take a snapshot of the
test_labkeyspace - Verify files in the snapshot directory
- Simulate restore (copy snapshot to live folder)
Run and interpret
nodetoolcommands:status,cfstats,tpstats,compactionstats
✅ Final Checklist
| Task | Done |
|---|---|
| Took snapshot of a keyspace | ✅ |
| Understood snapshot directory structure | ✅ |
| Restored data using snapshot files | ✅ |
Ran nodetool monitoring commands |
✅ |
๐ Congratulations! ๐
You've completed 11 Days of Cassandra Lab Practice with:
- Setup & Basic Operations
- Data Modeling
- Advanced Querying
- Backup & Monitoring
Tags:
Cassandra