Dragonfly Cloud is now available on the AWS Marketplace - Learn More

Question: How can you remove a node from a Redis cluster?

Answer

Removing a node from a Redis Cluster involves two primary steps: migrating data from the node to be removed to another node and then removing the node itself. Here's how you can do it:

  1. Migrate Data from Node: Before removing a node from a Redis Cluster, you should first migrate the data from that node to another node in the cluster. This ensures that no data is lost when the node is removed. In Redis, this can be accomplished using the CLUSTER SETSLOT command.
redis-cli --cluster reshard [target-node-host]:[target-node-port]

You will be asked for the ID of the node that you want to remove, as well as how many hash slots to move.

  1. Remove Node: After the data has been migrated, the node can be safely removed from the Redis Cluster. This can be accomplished using the CLUSTER FORGET command.
redis-cli --cluster del-node [node-host]:[node-port] [node-id]

Where [node-host]:[node-port] is the address of any node still in the cluster (not necessarily the one being removed) and [node-id] is the ID of the node you want to remove.

By following these steps, you should be able to successfully remove a node from a Redis Cluster without losing data or causing disruptions. Note that the actual process can contain more steps depending on your specific use-case and setup. Be sure to take precautions like backing up data and monitoring the cluster during the removal process to ensure everything goes smoothly.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost