Configures a server as replica of another, or promotes it to a primary.
REPLICAOF
host
port
REPLICAOF
NO
ONE
The REPLICAOF
command can change the replication
settings of a replica on the fly.
If a Valkey server is already acting as replica, the command
REPLICAOF
NO ONE will turn off the replication, turning the
Valkey server into a PRIMARY. In the proper form REPLICAOF
hostname port will make the server a replica of another server listening
at the specified hostname and port.
If a server is already a replica of some primary,
REPLICAOF
hostname port will stop the replication against
the old server and start the synchronization against the new one,
discarding the old dataset.
The form REPLICAOF
NO ONE will stop replication, turning
the server into a MASTER, but will not discard the replication. So, if
the old primary stops working, it is possible to turn the replica into a
primary and set the application to use this new primary in read/write.
Later when the other Valkey server is fixed, it can be reconfigured to
work as a replica.
Simple string
reply: OK
.
O(1)
@admin @dangerous @slow
> REPLICAOF NO ONE
"OK"
> REPLICAOF 127.0.0.1 6799
"OK"
ACL, ACL CAT, ACL DELUSER, ACL DRYRUN, ACL GENPASS, ACL GETUSER, ACL HELP, ACL LIST, ACL LOAD, ACL LOG, ACL SAVE, ACL SETUSER, ACL USERS, ACL WHOAMI, BGREWRITEAOF, BGSAVE, COMMAND, COMMAND COUNT, COMMAND DOCS, COMMAND GETKEYS, COMMAND GETKEYSANDFLAGS, COMMAND HELP, COMMAND INFO, COMMAND LIST, CONFIG, CONFIG GET, CONFIG HELP, CONFIG RESETSTAT, CONFIG REWRITE, CONFIG SET, DBSIZE, DEBUG, FAILOVER, FLUSHALL, FLUSHDB, INFO, LASTSAVE, LATENCY, LATENCY DOCTOR, LATENCY GRAPH, LATENCY HELP, LATENCY HISTOGRAM, LATENCY HISTORY, LATENCY LATEST, LATENCY RESET, LOLWUT, MEMORY, MEMORY DOCTOR, MEMORY HELP, MEMORY MALLOC-STATS, MEMORY PURGE, MEMORY STATS, MEMORY USAGE, MODULE, MODULE HELP, MODULE LIST, MODULE LOAD, MODULE LOADEX, MODULE UNLOAD, MONITOR, PSYNC, REPLCONF, RESTORE-ASKING, ROLE, SAVE, SHUTDOWN, SLOWLOG, SLOWLOG GET, SLOWLOG HELP, SLOWLOG LEN, SLOWLOG RESET, SWAPDB, SYNC, TIME.