Monday 7 December 2015

Writable redis slave

While working with redis, you may have a master redis running on a central server and all of your web application servers are running redis slaves. There may be some instances where you want to make these slaves writable for some testing purposes. Here is how we can accomplish this:

1. Load the data from master redis:
nohup /usr/bin/redis-server --port "slave port" --slaveof "Master Redis Machine IP" "Master Redis Port" > redis.out &

nohup /usr/bin/redis-server --port 7000 --slaveof 137.53.57.37 7000 > redis.out &

2. Kill the above redis process using kill command once the data is loaded.

3. Disconnect slave from master redis:
nohup /usr/bin/redis-server --port "slave port" --slaveof none "Master Redis Port" > redis.out &

nohup /usr/bin/redis-server --port 7000 --slaveof none 7000 > redis.out &

Now your slave is disconnected from master and you can write on it.