REPLICAOF
REPLICAOF host port REPLICAOF NO ONE
- Group
- Server
- Complexity
- O(1)
- Arity
- 3 (exactly, counting the command name)
- Flags
- admin
- HotKV Cloud
- All plans
- On-Premise
- no license needed
REPLICAOF host port makes the server a replica of the HotKV server at host
and port, its client port. The replica copies the primary’s data, then follows every
write. It replies OK at once and does the copy in the background; until it has
finished, commands that read or write data get LOADING. A replica that already follows
another server switches to the new one. Make it permanent with replicaof host port in the
configuration file. See replication for setting up replicas.
REPLICAOF NO ONE makes a replica stop following its primary and become a primary itself,
keeping its data. On a server that is already a primary it does nothing and replies
OK. NO ONE is matched case-insensitively.
Only a HotKV server can be the primary: a replica pointed at a Redis or Valkey
server stays in master_link_status:down, and the other way round too.
Return value
Section titled “Return value”| Case | Reply (RESP2 and RESP3) |
|---|---|
host port accepted, or NO ONE succeeded, or the server already is a primary |
Simple string OK |
NO ONE failed |
Error ERR Replication could not start as primary, see the server log |
| Cluster mode | Error ERR REPLICAOF not allowed in cluster mode. |
Examples
Section titled “Examples”127.0.0.1:8601> REPLICAOF 127.0.0.1 8600OK127.0.0.1:8601> ROLE1) "slave"2) "127.0.0.1"3) (integer) 86004) "connected"5) (integer) 38127.0.0.1:8601> SET greeting hi(error) READONLY You can't write against a read only replica.127.0.0.1:8601> REPLICAOF NO ONEOK127.0.0.1:8601> SET greeting promotedOK127.0.0.1:8601> ROLE1) "master"2) (integer) 793) (empty array)In HotKV Cloud, the CLI tab of the panel does not run REPLICAOF.
Compatibility
Section titled “Compatibility”Redis 7 and Valkey 8 accept both forms at runtime, and HotKV does too. A HotKV replica cannot follow a Redis or Valkey primary. In cluster mode, use CLUSTER REPLICATE and CLUSTER FAILOVER, as in Redis.
See also
Section titled “See also”SLAVEOF, ROLE, REPLICATION.FAILOVER, FAILOVER, Replication
In a cluster: Replicas and failover
Was this page helpful?
Thanks for the feedback.