Configuring Replication in Redis
Let’s discuss how to configure replication in Redis.
We'll cover the following...
In the previous lesson, we discussed the concept of replication in Redis. Now it is time to see how replication can be configured in Redis. There are two ways to configure a Redis server as a slave.
- Provide the
slaveof
property in theredis.conf
file. This property takes two parameters, i.e., the host and the port of the master. An example of how this can be written in the conf file is shown below.
slaveof
127.0.0.1 6379
When this Redis instance is started, it will automatically connect to the master server.
- We can use the
REPLICAOF
command to convert a Redis instance into a slave. Here are a few important points about this command:
- REPLICAOF hostname port will make