2
votes

I started to work on redis with master slave set up. Master and slave is set in same machine with different port. For handling Master/slave fail over, seems redis had sentinel. I am trying to implement the sentinel.

My redis.conf for Master:

bind 127.0.0.1(local Machine)
Port 6379

My redis1.conf for Slave:

bind 127.0.0.1
port 6380
slaveof 127.0.0.1 6379

My sentinel.conf has:

sentinel monitor mymaster 127.0.0.1 6379 1
sentinel down-after-milliseconds mymaster 30000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1

sentinel monitor resque 127.0.0.1 6380 1
sentinel down-after-milliseconds resque 10000
sentinel failover-timeout resque 180000
sentinel parallel-syncs resque 5

I am using https://www.npmjs.org/package/redis-sentinel-client for sentinel client.

Only one sentinel.conf file I am using for both master and slave. I ran both servers and checked by kill the master server. Slave become master as expected. From http://redis.io/topics/sentinel-old, under Resurrecting master section it is mentioned that the master which goes down will be added as slave of new elected master. But when I bring my master down, slave become master. But old master is still not slave of the new one. Is it the right way of using sentinel..?

Any suggestions to find how sentinel can be used to handle failover.? Or any other sentinel-client package for node..?

4

4 Answers

1
votes

As far as I am concerned(a newbie of redis),sentinel can acquire the info of slave form master.So for convenience, you can do as follows:

  1. master-slave set up;
  2. sentinel monitor master, which means slave's info is not in sentinel.conf.(or by connecting to the sentinel, and exec the command "sentinel monitor mymaster 127.0.0.1 6379 2")
  3. "redis-cli" to sentinel, exec the command "sentinel failover mymaster"(as you know, "mymaster" is the name of master), then you can see that the master and slave are switched.

What's more, you have to make sure the number of sentinels is enough. e.g. if the quonum is 2, make sure the number of sentinels is at least 3. Connect to any of the sentinel, exec "SENTINEL sentinels< master name>", or exec "SENTINEL ckquorum < master name>" to check it.

0
votes

There is no proper support for redis and sentinel in windows. When I am checking the same in virtual ubuntu with latest redis-stable version, every thing works fine.

0
votes

Use the 2.8 version of redis (available for Windowws 64-bit), because the 2.6 version of the sentinel does not resurrect masters.

0
votes

Besides using 2.8, your sentinel configuration should only be monitoring the master node. Any slaves will be auto-detected.

So the only thing in your sentinel config should be

sentinel monitor mymaster 127.0.0.1 6379 1
sentinel down-after-milliseconds mymaster 30000
sentinel failover-timeout mymaster 180000
sentinel parallel-syncs mymaster 1