We can take a node out of the cluster with nodetool decommission to a live node, or nodetool removenode (to any other machine) to remove a dead one. This will assign the ranges the old node was responsible for to other nodes, and replicate the appropriate data there.
If decommission is used, the data will stream from the decommissioned node. If removenode is used, the data will stream from the remaining replicas.
Table of Contents
Difference Between Removenode and Decommission
The nodetool removenode command can only be run on a node in the Down state. Nodetool Decommission can remove a live node in Up state.
Nodetool decommission has the same effect as Nodetool remove, but is more efficient because the node leaving the cluster helps calculate and transmit the data that will need to be moved to other nodes before leaving.
Depending on the amount of data in our cluster, this operation can take a long time. The machine first anti-compacts the data it has and then streams the data to the node that will now be responsible for that data. Use nodetool ring over time and the decommissioned host will eventually vanish from our list. Review the logs of the nodes to see how the compaction and streaming are progressing. We can also use nodetool compactionstats and nodetool streams to view the progress.
The host nodetool connects to with nodetool decommission will be the one removed. With removenode, the node with the specified node id will be removed.
Example of Nodetool decommission
- Any data owned by this node will have been streamed to the nodes now responsible for its token ranges
- The Cassandra process will still be running on this node but it will be out of the cluster
- At this point, the process can be killed or the instance can safely be shut down
Example of Nodetool Removenode
We can safely Ctrl + C back to a Command Prompt after invoking the removenode process. The process will continue to run in the background. During this time, data will be streamed to the new token ranges from other live replicas in the cluster. Once that completes, the node will be removed from gossip as well.
nodetool removenode 38782ca0-5dee-4576-b0f9-5c54ab6fef6b
nodetool removenode status
nodetool removenode force