CLUSTER-REPLICATE(3valkey)
π CLUSTER-REPLICATE β valkey command manual, but make it make sense
okay bestie, sit down, we're doing cluster surgery today π©Ίβ¨
β¨ NAME β¨
cluster-replicate β the glow-up (or the un-glow-up) command: it makes a node become a replica of a primary node, or detaches a replica from its primary. it's giving "you're with me now" energy. π«Ά
πΈ SYNOPSIS πΈ
CLUSTER REPLICATE node-id
CLUSTER REPLICATE NO ONE
two moods, one command. pick your fighter. π
π DESCRIPTION π
so basically, this command reconfigures a node as a replica of the primary you specified. and here's the little plot twist: if the node receiving the command is an empty primary, then as a side effect of the command, that node's role gets changed from primary to replica. not me casually demoting myself π
once a node has been turned into the replica of another primary node, there is genuinely no need to go tell all the other cluster nodes about it β the heartbeat packets that nodes exchange between each other will propagate the new configuration automatically. no group chat announcement needed, the gossip handles it. periodt. π¦
a replica will always accept the command, assuming that:
- The specified node ID exists in its nodes table.
- The specified node ID does not identify the instance we are sending the command to.
- The specified node ID is a primary.
(so likeβ¦ the node ID has to be real, it can't be you, and it has to be a primary. three boxes, check them all bestie β )
now, if the node receiving the command is not already a replica but is a primary, then the command will only succeed β and the node will only get converted into a replica β if these additional conditions are also met:
- The node is not serving any hash slots.
- The node is empty, no keys are stored at all in the key space.
β οΈ okay this is the important part, lowkey highkey: a primary with slots or with keys in it will NOT be converted. it's empty-or-nothing. no cap. π
if the command succeeds, the new replica will immediately try to contact its primary in order to replicate from it. bestie is already on the phone, calling its new primary. πβ¨
π REPLY π
valkey-protocol(7) Simple string reply: OK if the command was successful. otherwise, an error is returned. that's it, that's the vibe check. π
π₯ COMPLEXITY π₯
O(1) β constant time, queen. no scrolling required. π
π ACL CATEGORIES π
@admin @dangerous @slow
π¨ read that again:@admin,@dangerous,@slow. this is main character energy but also main character responsibility. be careful who you hand this power to.
β HISTORY β
- Available since: 3.0.0
- Changed in 9.0.0: Added support of
NO ONEarg instead of resulting into detaching replica from primary node.
(it literally grew up. glow-up era. π§)
π SEE ALSO π
asking(3valkey), cluster(3valkey), cluster-addslots(3valkey), cluster-addslotsrange(3valkey), cluster-bumpepoch(3valkey), cluster-cancelslotmigrations(3valkey), cluster-count-failure-reports(3valkey), cluster-countkeysinslot(3valkey), cluster-delslots(3valkey), cluster-delslotsrange(3valkey), cluster-failover(3valkey), cluster-flushslots(3valkey), cluster-forget(3valkey), cluster-getkeysinslot(3valkey), cluster-getslotmigrations(3valkey), cluster-help(3valkey), cluster-info(3valkey), cluster-keyslot(3valkey), cluster-links(3valkey), cluster-meet(3valkey), cluster-migrateslots(3valkey), cluster-myid(3valkey), cluster-myshardid(3valkey), cluster-nodes(3valkey), cluster-replicas(3valkey), cluster-reset(3valkey), cluster-saveconfig(3valkey), cluster-set-config-epoch(3valkey), cluster-setslot(3valkey), cluster-shards(3valkey), cluster-slot-stats(3valkey), cluster-slots(3valkey), cluster-syncslots(3valkey), readonly(3valkey), readwrite(3valkey)
and that's the whole page bestie π this little diva is from 9.0.0, dated 2025-10-21 β CLUSTER-REPLICATE(3valkey), the valkey command manual. now go forth and replicate responsibly, iykyk π«Άβ¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms