CLUSTER REPLICATE
CLUSTER REPLICATE node-id CLUSTER REPLICATE NO ONE
- Group
- Cluster
- Complexity
- O(1)
- Arity
- -3 (at least 3 words, counting the command name)
- HotKV Cloud
- Not available
- On-Premise
- no license needed
CLUSTER REPLICATE node-id turns the receiving node into a replica of the primary
with the given ID. The node starts copying the primary’s data, saves its new
role to nodes.conf, and tells the other nodes. A replica that already
follows another primary switches to the new one. While the first copy runs, the
replica answers commands that read or write data with LOADING.
A primary can become a replica only while it is empty: it must serve no slots and hold no keys (HotKV’s AI feature data counts as keys here). Move its slots away and empty it first.
CLUSTER REPLICATE NO ONE goes the other way. A replica stops following its primary and
becomes the primary of a shard of its own, with a new shard ID, no slots and no data: it
drops everything it had copied. Give it slots with
CLUSTER ADDSLOTS, or move slots to it
(see Scaling a cluster), or make it a replica again
with CLUSTER REPLICATE node-id. On a primary, NO ONE replies OK and changes
nothing.
In a cluster, use CLUSTER REPLICATE to set up replicas; REPLICAOF
belongs to non-cluster replication and is refused in cluster mode with ERR REPLICAOF not allowed in cluster mode.
Return value
Section titled “Return value”Simple string OK in RESP2 and RESP3, or one of these errors:
| Case | Error |
|---|---|
| Unknown node ID | ERR Unknown node <node-id> |
| The node’s own ID | ERR Can't replicate myself |
| The target is a replica | ERR I can only replicate a master, not a replica. |
| This node is a primary with slots or keys | ERR To set a master the node must be empty and without assigned slots. |
| Cluster mode is off | ERR This instance has cluster support disabled |
Examples
Section titled “Examples”127.0.0.1:7003> CLUSTER REPLICATE c5bcbe648892246dde31b5d78443297b493afb63OK127.0.0.1:7003> ROLE1) "slave"2) "127.0.0.1"3) (integer) 70004) "connected"5) (integer) 105127.0.0.1:7003> CLUSTER REPLICATE NO ONEOK127.0.0.1:7003> ROLE1) "master"2) (integer) 1233) (empty array)Refused:
127.0.0.1:7000> CLUSTER REPLICATE ba074e3f3b7c3f622d2dc797baacec7229cb94ac(error) ERR To set a master the node must be empty and without assigned slots.127.0.0.1:7004> CLUSTER REPLICATE e7217a7e5c27c9b884f9edd0014a7b8c0a8f7056(error) ERR I can only replicate a master, not a replica.127.0.0.1:7001> CLUSTER REPLICATE e7217a7e5c27c9b884f9edd0014a7b8c0a8f7056(error) ERR Can't replicate myselfCompatibility
Section titled “Compatibility”Same checks, replies and error strings as Redis 7 and Valkey 8. NO ONE is Valkey 9’s
form.
See also
Section titled “See also”CLUSTER FAILOVER, CLUSTER REPLICAS, CLUSTER NODES, CLUSTER RESET, Replicas and failover
Was this page helpful?
Thanks for the feedback.