Redis Slaveof Command
The Redis Slaveof command can turn the current server into a slave server of the specified server.
If the current server is already a slave of a master server, executing SLAVEOF host port will cause the current server to stop synchronizing with the old master server, discard the old dataset, and start synchronizing with the new master server.
Additionally, executing the command SLAVEOF NO ONE on a slave server will disable the replication feature and turn the slave server back into a master server, without discarding the dataset obtained through synchronization.
By leveraging the feature that "SLAVEOF NO ONE does not discard the synchronized dataset," a slave server can be used as a new master server in the event of a master server failure, thereby achieving uninterrupted operation.
Syntax
The basic syntax for the redis Slaveof command is as follows:
redis 127.0.0.1:6379> SLAVEOF host port
Available Versions
= 1.0.0
Return Value
Always returns OK.
Example
redis 127.0.0.1:6379> SLAVEOF 127.0.0.1 6379
OK
redis 127.0.0.1:6379> SLAVEOF NO ONE
OK