Master-Slave configuration in Redis

 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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s