Cassandra Playbook: Replace a Dead Node
This playbook provides step-by-step instructions for replacing a failed Cassandra node that cannot be recovered.
Overview
Section titled “Overview”| Attribute | Value |
|---|---|
| Estimated Duration | 30 minutes - 4 hours (depends on data size) |
| Risk Level | Medium |
| Requires Downtime | No (cluster remains available) |
| Prerequisites | Replacement hardware ready, network accessible |
When to Use This Playbook
Section titled “When to Use This Playbook”- Node hardware has failed and cannot be recovered
- Node has been down longer than
max_hint_window_in_ms(default: 3 hours) - Corrupted data that cannot be repaired
- Decommissioning and replacing simultaneously
Prerequisites
Section titled “Prerequisites”- Replacement server provisioned with same specifications
- Cassandra installed (same version as cluster)
- Network connectivity verified to all cluster nodes
- Firewall rules configured (ports 7000, 7001, 9042, 7199)
- NTP synchronized
- Sufficient disk space (at least equal to failed node)
Step 1: Confirm Node Status
Section titled “Step 1: Confirm Node Status”1.1 Verify Node is Down
Section titled “1.1 Verify Node is Down”# On any live nodenodetool statusExpected output: Dead node shows as DN (Down/Normal):
Datacenter: dc1===============Status=Up/Down|/ State=Normal/Leaving/Joining/Moving-- Address Load Tokens Owns Host ID RackUN 10.0.0.1 256.12 KiB 16 ? 550e8400-e29b-41d4-a716-446655440000 rack1DN 10.0.0.2 267.89 KiB 16 ? 660e8400-e29b-41d4-a716-446655440001 rack1 <-- Dead nodeUN 10.0.0.3 245.34 KiB 16 ? 770e8400-e29b-41d4-a716-446655440002 rack11.2 Record Dead Node Information
Section titled “1.2 Record Dead Node Information”Critical: Note these values from the dead node:
# Get Host ID of dead nodenodetool status | grep DN# Record: Host ID = 660e8400-e29b-41d4-a716-446655440001
# Get IP address# Record: IP = 10.0.0.21.3 Check Hints
Section titled “1.3 Check Hints”# Check if hints exist for the dead nodenodetool getendpoints my_keyspace my_table some_partition_keyStep 2: Prepare Replacement Node
Section titled “Step 2: Prepare Replacement Node”2.1 Install Cassandra
Section titled “2.1 Install Cassandra”# On replacement node (10.0.0.4)sudo apt-get updatesudo apt-get install cassandra# ORsudo yum install cassandra2.2 Verify Version Match
Section titled “2.2 Verify Version Match”# On replacement nodecassandra -v
# On existing nodenodetool versionBoth must match.
2.3 Clear Data Directories
Section titled “2.3 Clear Data Directories”# On replacement node - ensure clean statesudo rm -rf /var/lib/cassandra/data/*sudo rm -rf /var/lib/cassandra/commitlog/*sudo rm -rf /var/lib/cassandra/saved_caches/*sudo rm -rf /var/lib/cassandra/hints/*Step 3: Configure Replacement Node
Section titled “Step 3: Configure Replacement Node”3.1 Edit cassandra.yaml
Section titled “3.1 Edit cassandra.yaml”sudo vi /etc/cassandra/cassandra.yamlCritical settings (must match cluster, except IPs):
cluster_name: 'ProductionCluster' # Must match exactly!
# Set to replacement node's IPlisten_address: 10.0.0.4rpc_address: 10.0.0.4
# Same seeds as cluster (do not include dead node)seed_provider: - class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters: - seeds: "10.0.0.1,10.0.0.3"
# Same snitch as clusterendpoint_snitch: GossipingPropertyFileSnitch3.2 Configure Rack/DC
Section titled “3.2 Configure Rack/DC”sudo vi /etc/cassandra/cassandra-rackdc.propertiesdc=dc1 # Same as dead noderack=rack1 # Same as dead node3.3 Set JVM Options
Section titled “3.3 Set JVM Options”Ensure JVM settings match other nodes in jvm.options or jvm11-server.options.
Step 4: Start Replacement with Replace Flag
Section titled “Step 4: Start Replacement with Replace Flag”4.1 Set Replace Address
Section titled “4.1 Set Replace Address”Option A: Set in JVM options file
sudo vi /etc/cassandra/jvm-server.options# Add this line:-Dcassandra.replace_address_first_boot=10.0.0.2Option B: Set via environment variable
export JVM_OPTS="$JVM_OPTS -Dcassandra.replace_address_first_boot=10.0.0.2"4.2 Start Cassandra
Section titled “4.2 Start Cassandra”sudo systemctl start cassandra4.3 Monitor Bootstrap Progress
Section titled “4.3 Monitor Bootstrap Progress”# Watch the logstail -f /var/log/cassandra/system.log
# Check progressnodetool netstats
# On another node, check statusnodetool statusExpected log messages:
INFO [main] StorageService.java - Replacing a node with token(s): [-9223372036854775808, ...]INFO [main] StorageService.java - Nodes [/10.0.0.2] are marked deadINFO [main] Gossiper.java - Replacing /10.0.0.2 with /10.0.0.4Step 5: Verify Replacement
Section titled “Step 5: Verify Replacement”5.1 Check Node Status
Section titled “5.1 Check Node Status”nodetool statusExpected: New node shows as UN:
Datacenter: dc1===============UN 10.0.0.1 256.12 KiB 16 33.3% 550e8400-e29b-41d4-a716-446655440000 rack1UN 10.0.0.4 267.89 KiB 16 33.3% 880e8400-e29b-41d4-a716-446655440003 rack1 <-- New nodeUN 10.0.0.3 245.34 KiB 16 33.4% 770e8400-e29b-41d4-a716-446655440002 rack1Note: Dead node (10.0.0.2) is no longer listed.
5.2 Verify Data Streaming Complete
Section titled “5.2 Verify Data Streaming Complete”# On new nodenodetool netstatsExpected: No active streams:
Mode: NORMALNot sending any streams.Not receiving any streams.5.3 Check Gossip Info
Section titled “5.3 Check Gossip Info”nodetool gossipinfoVerify new node appears with correct STATUS=NORMAL.
Step 6: Post-Replacement Cleanup
Section titled “Step 6: Post-Replacement Cleanup”6.1 Remove Replace Flag
Section titled “6.1 Remove Replace Flag”Important: Remove the replace flag to prevent issues on restart.
sudo vi /etc/cassandra/jvm-server.options# Remove or comment out:# -Dcassandra.replace_address_first_boot=10.0.0.26.2 Run Repair on New Node
Section titled “6.2 Run Repair on New Node”# Run repair to ensure data consistencynodetool repair -pr6.3 Update Seed List (if applicable)
Section titled “6.3 Update Seed List (if applicable)”If the dead node was a seed, update all nodes:
# On all nodessudo vi /etc/cassandra/cassandra.yaml# Update seeds list to exclude dead node, include new node if desired6.4 Update Monitoring/Alerting
Section titled “6.4 Update Monitoring/Alerting”- Update monitoring to track new node IP
- Remove dead node from monitoring
- Update documentation
Troubleshooting
Section titled “Troubleshooting”Bootstrap Hangs
Section titled “Bootstrap Hangs”Symptom: Node stuck in UJ (Up/Joining) state.
# Check progressnodetool netstats
# Check for errorstail -100 /var/log/cassandra/system.log | grep -i errorSolutions:
- Wait (large datasets take time)
- Check network connectivity to other nodes
- Check disk space on new node
Node Shows Wrong Tokens
Section titled “Node Shows Wrong Tokens”Symptom: Token distribution uneven after replace.
# Check token distributionnodetool ringSolution: Run repair, then consider running nodetool cleanup on other nodes.
Streaming Failures
Section titled “Streaming Failures”Symptom: “Streaming error” in logs.
grep -i "stream" /var/log/cassandra/system.log | tail -50Solutions:
- Check network connectivity
- Increase streaming timeout
- Restart bootstrap (clear data, try again)
Old Node Reappears
Section titled “Old Node Reappears”Symptom: Dead node shows up again after replacement.
# Remove via assassinate (use with caution)nodetool assassinate 10.0.0.2Rollback Procedure
Section titled “Rollback Procedure”If replacement fails and recovery is needed:
-
Stop the replacement node:
Terminal window sudo systemctl stop cassandra -
If original node can be recovered, bring it back:
Terminal window # On original nodesudo systemctl start cassandra -
Clear replacement node data:
Terminal window sudo rm -rf /var/lib/cassandra/data/* -
Run repair on recovered node:
Terminal window nodetool repair
Checklist Summary
Section titled “Checklist Summary”- Confirmed node is dead (DN status)
- Recorded dead node Host ID and IP
- Prepared replacement node hardware
- Installed matching Cassandra version
- Configured cassandra.yaml with replace flag
- Configured rack/DC properties
- Started node and monitored bootstrap
- Verified UN status and data streaming complete
- Removed replace flag from configuration
- Ran repair on new node
- Updated seed list if needed
- Updated monitoring and documentation