Cassandra Removing Nodes

Removing a node from a Cassandra cluster is a controlled operation that safely redistributes the departing node's data to remaining nodes before it leaves. Cassandra provides two commands depending on whether the node is alive or dead: decommission for a healthy node and removenode for a node that cannot be started.

When to Remove a Node

Scenario                              Command to Use
──────────────────────────────────────────────────────────────
Node is running and reachable         nodetool decommission
                                      (run on the node itself)
Node is dead / unreachable            nodetool removenode
                                      (run from any other node)
Replacing dead node at new IP         nodetool removenode +
                                      add new node with replace_address
Shrinking cluster after low traffic   nodetool decommission
  period                              (one node at a time)

Decommissioning a Live Node

Log into the node you want to remove and run decommission. Cassandra streams all of that node's data to the remaining nodes before the node leaves the ring.

# Run ON the node you want to remove:
nodetool decommission

What Happens During Decommission

Step 1: Node announces LEAVING status via gossip
        → other nodes stop routing new writes to it

Step 2: Node streams its data to replacement nodes
        → each token range it owns is transferred

Step 3: Node announces LEFT status
        → removed from the ring completely

Step 4: Node shuts down Cassandra process

Monitor Decommission Progress

# From another node, watch the status:
nodetool status

--  Address    Tokens  State
UN  10.0.0.1   256     Normal
UN  10.0.0.2   256     Normal
DL  10.0.0.3   256     Leaving   ← currently decommissioning
UN  10.0.0.4   256     Normal

# Watch streaming progress from the leaving node:
nodetool netstats

Abort a Decommission

nodetool assassinate 10.0.0.3  # force-remove from gossip ring
# OR
# Cancel in progress:
nodetool decommission --cancel  # (Cassandra 4.0+)

Removing a Dead Node

When a node crashes permanently and cannot be restarted, use nodetool removenode from any other running node. This tells the cluster to redistribute the dead node's token ranges to the remaining nodes.

# Get the dead node's Host ID:
nodetool status

--  Address    HostID                                Tokens  Status
DN  10.0.0.3   a1b2c3d4-e5f6-7890-abcd-ef1234567890  256    Down

# Remove by Host ID (from any running node):
nodetool removenode a1b2c3d4-e5f6-7890-abcd-ef1234567890

Force Remove a Stuck Node

If removenode appears to stall, you can force it to complete after confirming the node is truly dead.

nodetool removenode force a1b2c3d4-e5f6-7890-abcd-ef1234567890

Run Repair After Removal

After any node removal, run repair across the cluster to ensure the remaining nodes hold complete data for all token ranges that moved.

# Run on each remaining node (one at a time):
nodetool repair

How Many Nodes Can You Safely Remove?

You should not reduce the cluster below the number of nodes needed to satisfy your keyspace's replication factor. With RF=3, you need at least 3 nodes. Removing nodes below the replication factor causes data loss.

RF = 3, safe minimum cluster size = 3 nodes

6-node cluster → can reduce to 3 nodes safely
3-node cluster → cannot remove any more nodes safely

If you must reduce below RF nodes, reduce the replication factor first:
  ALTER KEYSPACE ecommerce WITH replication = {
    'class': 'NetworkTopologyStrategy',
    'us_east': 2
  };
  THEN remove a node.

Data Center Removal

To remove an entire data center, decommission all nodes in that data center one by one. Before decommissioning, alter the keyspace to remove that data center from the replication strategy, or Cassandra will try to stream data to the departing nodes.

-- Step 1: Remove the DC from keyspace replication:
ALTER KEYSPACE ecommerce
  WITH replication = {
    'class': 'NetworkTopologyStrategy',
    'us_east': 3
    -- 'eu_west': 3  ← removed
  };

-- Step 2: Decommission each EU-West node one at a time:
nodetool decommission   # run on each eu-west node

Node Removal Checklist

Before Removing:
  ✓ Replication factor allows one fewer node
  ✓ Remaining nodes have enough disk for redistributed data
  ✓ Confirm the node to remove is correct (check IP + Host ID)

During Removal:
  ✓ Monitor with nodetool status and nodetool netstats
  ✓ Do not remove a second node until the first finishes
  ✓ Check system log for errors on remaining nodes

After Removal:
  ✓ Run nodetool repair on all remaining nodes
  ✓ Verify nodetool status shows all nodes UN (Up Normal)
  ✓ Confirm data counts in affected keyspaces are correct

Summary

Use nodetool decommission to remove a live node gracefully — it streams its data out before leaving. Use nodetool removenode with the dead node's Host ID to remove an unreachable node from any other running node. Always run repair after a removal. Never reduce the cluster below the number of nodes required by the highest replication factor in use. Remove one node at a time to avoid data availability gaps during the process.

Leave a Comment

Your email address will not be published. Required fields are marked *