0
0
Redisquery~10 mins

Adding and removing nodes in Redis - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Adding and removing nodes
Start Cluster
Add Node Command
Cluster Updates Node List
Node Joins Cluster
Cluster Balances Slots
Node Added Successfully
Remove Node Command
Cluster Removes Node
Cluster Rebalances Slots
Node Removed Successfully
End
This flow shows how nodes are added or removed from a Redis cluster, updating the cluster state and slot distribution.
Execution Sample
Redis
redis-cli --cluster add-node 192.168.1.2:7003 192.168.1.1:7000
redis-cli --cluster del-node 192.168.1.1:7000 <node-id>
Commands to add a new node to the cluster and then remove a node by its ID.
Execution Table
StepCommandCluster State ChangeSlots RebalancedResult
1add-node 192.168.1.2:7003 192.168.1.1:7000Node 7003 added to cluster node listNo slots yetNode joins cluster
2cluster updateCluster updates slot allocationSlots redistributed to include new nodeSlots balanced
3add-node completeCluster stable with new nodeSlots balancedNode added successfully
4del-node <node-id>Node removed from cluster node listSlots from removed node reassignedNode leaves cluster
5cluster updateCluster updates slot allocationSlots redistributed among remaining nodesSlots balanced
6del-node completeCluster stable without removed nodeSlots balancedNode removed successfully
7endNo further changesNo changesProcess complete
💡 Process ends after node is successfully added and then removed, cluster is stable.
Variable Tracker
VariableStartAfter Add 1After Add 2After Remove 1After Remove 2Final
Cluster Nodes[7000,7001,7002][7000,7001,7002,7003][7000,7001,7002,7003][7000,7001,7002,7003][7000,7001,7002][7000,7001,7002]
Slot AllocationBalanced among 3 nodesUnbalanced (new node no slots)Balanced among 4 nodesUnbalanced (removed node slots unassigned)Balanced among 3 nodesBalanced among 3 nodes
Key Moments - 3 Insights
Why does the cluster need to rebalance slots after adding a node?
Because slots must be distributed evenly among all nodes to balance the data load, as shown in execution_table rows 2 and 3.
What happens to the slots of a node when it is removed?
The slots assigned to the removed node are reassigned to remaining nodes to keep the cluster balanced, as seen in execution_table rows 4 and 5.
Can a node join the cluster without slots assigned initially?
Yes, initially the new node has no slots until the cluster rebalances, as shown in execution_table row 1.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step are slots first redistributed to include the new node?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Check the 'Slots Rebalanced' column for when slots are redistributed.
According to variable_tracker, how many nodes are in the cluster after the node is removed?
A2 nodes
B4 nodes
C3 nodes
D1 node
💡 Hint
Look at 'Cluster Nodes' variable after 'After Remove 2' column.
If the cluster did not rebalance slots after removing a node, what would happen?
ASome slots would be unassigned
BNew nodes would be added automatically
CSlots would remain balanced
DCluster would shut down
💡 Hint
Refer to key_moments about slot reassignment after node removal.
Concept Snapshot
Redis Cluster node management:
- Add node with 'redis-cli --cluster add-node <new-node> <existing-node>'
- Remove node with 'redis-cli --cluster del-node <existing-node> <node-id>'
- Cluster updates node list and slot allocation after changes
- Slots must be balanced among nodes for data distribution
- Rebalancing happens automatically after add/remove
Full Transcript
This visual execution shows how Redis cluster nodes are added and removed. First, a new node is added using the add-node command, which updates the cluster's node list. Initially, the new node has no slots assigned. Then the cluster rebalances slots to distribute data evenly among all nodes. After the node is successfully added, a node can be removed using the del-node command by specifying its ID. The cluster removes the node from its list and reassigns the slots that belonged to the removed node to remaining nodes. This keeps the cluster balanced and stable. The variable tracker shows how the cluster nodes and slot allocation change step-by-step. Key moments clarify why rebalancing is necessary and what happens to slots during node removal. The quiz questions help reinforce understanding by referencing the execution steps and variable changes.