Day 11: Cassandra Lab Practice – Backup, Restore & Monitoring

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:

  1. Stop Cassandra:
sudo systemctl stop cassandra
  1. 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/
  1. Clear commit logs (optional for full restore)
  2. Restart Cassandra:
sudo systemctl start cassandra
  1. 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

  1. Take a snapshot of the test_lab keyspace
  2. Verify files in the snapshot directory
  3. Simulate restore (copy snapshot to live folder)
  4. 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