Redis Slaveof Command

Redis Server

The Redis Slaveof command can convert the current server into a slave server of the specified server.

If the current server is already a slave server of some master server, then executing SLAVEOF host port will cause the current server to stop synchronizing with the old master, discard the old dataset, and instead begin synchronizing with the new master.

In addition, executing the command SLAVEOF NO ONE on a slave server will cause the slave to disable replication and change back from a slave server to a master server, and the dataset originally obtained through synchronization will not be discarded.

Using the feature that 'SLAVEOF NO ONE does not discard the synchronized dataset', when the master server fails, the slave server can be used as the new master server, thereby achieving uninterrupted operation.

Syntax

The basic syntax of 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.

Examples

redis 127.0.0.1:6379> SLAVEOF 127.0.0.1 6379
OK

redis 127.0.0.1:6379> SLAVEOF NO ONE
OK

Redis Server

Other extensions