This book covers the use of Redis, an in-memory database/data structure server.

open all | close all

4.2.1 Configuring Redis for replication

As I mentioned in section 4.1.1, when a slave connects to the master, the master will
start a BGSAVE operation. To configure replication on the master side of things, we
only need to ensure that the path and filename listed under the dir and dbfilename
configuration options shown in listing 4.1 are to a path and file that are writable by
the Redis process.

Though a variety of options control behavior of the slave itself, only one option is
really necessary to enable slaving: slaveof. If we were to set slaveof host port in
our configuration file, the Redis that’s started with that configuration will use the
provided host and port as the master Redis server it should connect to. If we have an
already running system, we can tell a Redis server to stop slaving, or even to slave to a
new or different master. To connect to a new master, we can use the SLAVEOF host
command, or if we want to stop updating data from the master, we can use
SLAVEOF no one.

There’s not a lot to configuring Redis for master/slave operation, but what’s interesting
and useful to know is what happens to Redis when it becomes a master or slave.