CASSANDRA Operations and Administration 1 — Questions and Answers
Question 1: What does 'nodetool repair' do in Cassandra?
- Rewrites corrupt SSTables
- Synchronizes replicas by comparing and streaming missing data between nodes (Correct answer)
- Rebuilds secondary indexes
- Restores data from a snapshot
Correct answer: Synchronizes replicas by comparing and streaming missing data between nodes
nodetool repair compares replica sets using Merkle trees and streams any missing or out-of-date data to bring all replicas into sync.
Question 2: What does the 'nodetool drain' command do before a node shutdown?
- Removes the node from the ring
- Flushes all MemTables, stops accepting writes, and drains the CommitLog so the node can be safely stopped (Correct answer)
- Decommissions the node and rebalances tokens
- Clears the key cache and row cache
Correct answer: Flushes all MemTables, stops accepting writes, and drains the CommitLog so the node can be safely stopped
nodetool drain ensures all pending writes are flushed to SSTables and the CommitLog is cleared, allowing a clean node shutdown without data loss.
Question 3: What does 'nodetool cleanup' do after adding a new node to a Cassandra cluster?
- Removes tombstones from all SSTables
- Deletes data from existing nodes that no longer falls within their token ranges after rebalancing (Correct answer)
- Compacts all SSTables on the new node
- Rebuilds materialized views on all nodes
Correct answer: Deletes data from existing nodes that no longer falls within their token ranges after rebalancing
After a new node joins and data streams to it, nodetool cleanup removes the portions of data on existing nodes that the new node now owns.
Question 4: What is the purpose of 'nodetool rebuild' command?
- Rebuilds SSTables from the CommitLog after corruption
- Streams data for all token ranges from a specified data center, used when adding a new DC (Correct answer)
- Rebuilds secondary indexes for all tables
- Replays hinted handoff hints
Correct answer: Streams data for all token ranges from a specified data center, used when adding a new DC
nodetool rebuild streams the current data for the node's token ranges from another data center, used to populate a new DC without running a full repair.
Question 5: How can you monitor Cassandra metrics using industry-standard monitoring tools?
- Cassandra exposes metrics only via its REST API
- Cassandra exposes metrics via JMX, which can be scraped by tools like Prometheus via a JMX exporter (Correct answer)
- Metrics are only available through cqlsh system tables
- Cassandra pushes metrics to a CloudWatch endpoint automatically
Correct answer: Cassandra exposes metrics via JMX, which can be scraped by tools like Prometheus via a JMX exporter
Cassandra exposes hundreds of metrics via JMX (Java Management Extensions), and tools like the Prometheus JMX Exporter or Datadog Agent can scrape and forward them.
Question 6: What does 'nodetool move' do in Cassandra?
- Migrates all data to a new data center
- Changes the token assignment of the current node to rebalance data distribution (Correct answer)
- Moves CommitLog files to a new directory
- Transfers ownership of all token ranges to a peer node
Correct answer: Changes the token assignment of the current node to rebalance data distribution
nodetool move changes the node's token to a new value, causing Cassandra to stream the appropriate data to/from neighboring nodes to maintain correct distribution.
What does 'nodetool repair' do in Cassandra?