directory search
Cluster cluster addslots(集群 槽位) cluster count failure reports(集群计数失败报告) cluster countkeysinslot cluster delslots cluster failover cluster forget cluster getkeysinslot cluster info cluster keyslot(集群键槽) cluster meet cluster nodes(集群节点) cluster replicate(集群复制) cluster reset(集群重置) cluster saveconfig cluster set config epoch cluster setslot cluster slaves cluster slots readonly readwrite Connection auth echo ping quit select swapdb Geo geoadd geodist geohash geopos georadius georadiusbymember Hashes hdel hexists hget hgetall hincrby hincrbyfloat hkeys hlen hmget hmset hscan hset hsetnx hstrlen hvals HyperLogLog pfadd pfcount pfmerge Keys del dump exists expire expireat keys migrate move object persist pexpire pexpireat pttl randomkey rename renamenx restore scan sort touch ttl type unlink wait Lists blpop brpop brpoplpush lindex linsert llen lpop lpush lpushx lrange lrem lset ltrim rpop rpoplpush rpush rpushx Pub/Sub psubscribe publish pubsub punsubscribe subscribe unsubscribe Scripting eval evalsha script debug script exists script flush script kill script load Server bgrewriteaof bgsave client getname client kill client list client pause client reply client setname command command count command getkeys command info config get config resetstat config rewrite config set dbsize debug object debug segfault flushall flushdb info lastsave monitor role save shutdown slaveof slowlog time Sets sadd scard sdiff sdiffstore sinter sinterstore sismember smembers smove spop srandmember srem sscan sunion sunionstore Sorted Sets zadd zcard zcount zincrby zinterstore zlexcount zrange zrangebylex zrangebyscore zrank zrem zremrangebylex zremrangebyrank zremrangebyscore zrevrange zrevrangebylex zrevrangebyscore zrevrank zscan zscore zunionstore Strings append bitcount bitfield bitop bitpos decr decrby get getbit getrange getset incr incrby incrbyfloat mget mset msetnx psetex set setbit setex setnx setrange strlen Transactions discard exec multi unwatch watch
characters

CLUSTER REPLICATE node-id

自3.0.0起可用。

时间复杂度: O(1)

该命令将节点重新配置为指定主站的从站。如果接收命令的节点是空主节点,作为该命令的副作用,则节点角色将从主节点更改为从节点。

一旦一个节点变成另一个主节点的从属节点,就不需要通知其他集群节点有关更改:节点之间交换的心跳包会自动传播新配置。

假设奴隶总是接受命令:

1. 指定的节点ID存在于其节点表中。

2. 指定的节点ID不标识我们发送命令的实例。

3. 指定的节点ID是一个主节点。

如果接收到该命令的节点不是从属节点,而是主节点,则只有满足以下附加条件时,该命令才会成功,并且该节点将转换为从节点:

1. 该节点不提供任何散列槽。

2. 该节点是空的,在密钥空间中根本不存储任何密钥。

如果命令成功,新的从站将立即尝试联系其主站以便从其复制。

返回值

简单的字符串回复:OK如果命令执行成功,否则返回错误。

Previous article: Next article: