✅ 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_lab
keyspace - Verify files in the snapshot directory
- Simulate restore (copy snapshot to live folder)
Run and interpret
nodetool
commands: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