In the Master Node:
- Download the redis package and install or use the command to install the redis server.
- Now open the redis.conf file in /etc/redis folder.
- Search for the “bind 127.0.0.1” and replace it with “bind <public_ip_of_master_node>” .
- Also to enhance the security of the master node you can also set the password by setting “requirepass <your_password>” in the same file. After all the changes save the file and run the server.
In the Slave Nodes:
- Similar to master node, install the redis and change the conf file as above. Bind Ip here should also be the same public ip of the master node.
- And in addition to those changes, we have to change “slaveof” property to make this node act as a slave. So insert the proper values in the following commented line in the conf file,
# slaveof <masterip> <masterport>
- If you have set password for master, you have to substitute the master password in the following commented line in the file.
# masterauth <master-password>
- Now start the service. This node will act as the slave node for the master.
Check the Master Slave configuration by setting a value for a key in the master node and get the value for the same key and check whether they are same. Similarly you can add many slave nodes to a master.