Redis Cluster Tutorial-9
Redis Cluster Tutorial-9
Basically clients connected to the master we are failing over are stopped. At the same
time the master sends its replication offset to the slave, that waits to reach the offset on
its side. When the replication offset is reached, the failover starts, and the old master is
informed about the configuration switch. When the clients are unblocked on the old
master, they are redirected to the new master.
As you can see I used the add-node command specifying the address of the new node
as first argument, and the address of a random existing node in the cluster as second
argument.
In practical terms redis-cli here did very little to help us, it just sent a CLUSTER
MEET message to the node, something that is also possible to accomplish manually.
However redis-cli also checks the state of the cluster before to operate, so it is a good
idea to perform cluster operations always via redis-cli even when you know how the
internals work.
Now we can connect to the new node to see if it really joined the cluster:
f093c80dde814da99c5cf72a7dd01590792b783b :0 myself,master - 0 0 0
connected
Note that since this node is already connected to the cluster it is already able to redirect
client queries correctly and is generally speaking part of the cluster. However it has two
peculiarities compared to the other masters:
Now it is possible to assign hash slots to this node using the resharding feature of redis-
cli.It is basically useless to show this as we already did in a previous section, there is no
difference, it is just a resharding having as a target the empty node.
Note that the command line here is exactly like the one we used to add a new master,
so we are not specifying to which master we want to add the replica. In this case what