The command reconfigures a node as a slave of the specified master. If the node receiving the command is an empty master, as a side effect of the command, the node role is changed from master to slave.

Once a node is turned into the slave of another master node, there is no need to inform the other cluster nodes about the change: heartbeat packets exchanged between nodes will propagate the new configuration automatically.

A slave will always accept the command, assuming that:

  1. The specified node ID exists in its nodes table.
  2. The specified node ID does not identify the instance we are sending the command to.
  3. The specified node ID is a master.

If the node receiving the command is not already a slave, but is a master, the command will only succeed, and the node will be converted into a slave, only if the following additional conditions are met:

  1. The node is not serving any hash slots.
  2. The node is empty, no keys are stored at all in the key space.

If the command succeeds the new slave will immediately try to contact its master in order to replicate from it.

@return

@simple-string-reply: OK if the command was executed successfully, otherwise an error is returned.

相关命令

返回命令列表

版权及转载说明

本站原创、转载文章欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区

本站转载文章版权归原作者所有,如发现本站文章涉嫌侵权请点击「联系我们」反馈,本站将给予删除

本教程数据来源「http://www.redis.cn/documentation.html」