Advertisement
Beginner Redis, Redis Replication

How do you configure a Redis instance to become a replica of another Redis instance?

Short answer

You use the REPLICAOF command, specifying the hostname and port of the primary server you want to replicate from, either as a runtime command or as a configuration file setting, after which the replica automatically connects to the primary, performs an initial full…

Save Redis mock interview
Advertisement
AModel answer
You use the REPLICAOF command, specifying the hostname and port of the primary server you want to replicate from, either as a runtime command or as a configuration file setting, after which the replica automatically connects to the primary, performs an initial full synchronization, and then continuously receives ongoing updates.
Example

REPLICAOF 192.168.1.10 6379 -- Or in redis.conf: -- replicaof 192.168.1.10 6379

Real-world example
A team sets up a new replica server by configuring it to replicate from their existing primary, watching it automatically synchronize the entire dataset before beginning to serve read traffic.
Likely follow-ups
  • What happens during the initial full synchronization process?
  • How do you stop a replica from following its current primary?
Related topics