redis-sentinel --- Sentry mode

1, Sentinel Profile: Redis Sentinel

Sentinel (Sentinel) is a tool for monitoring redis clusters in the Master state , which has been integrated in redis2.4 + Redis official version is recommended for high availability (HA) solutions.

2, the role of

. 1): Master state detection
2): If an abnormal Master, Master-Slave will perform handover, in which as a Master and a Slave, the Slave as the previous Master
. 3): the Master-Slave handover monitoring target will sentinel.conf will exchange

3, operating mode

1): Each Sentinel frequency of once per second, it is known to the Master, Slave, and other examples of transmitting a PING command Sentinel

2): if an instance (instance) from the last valid reply time exceeds the value of the PING command down-after-milliseconds specified by the option, then the instance is marked subjective Sentinel offline.

3): If a Master is marked as subjective offline, all this is being monitored to be sure the Master Sentinel Master indeed entered a subjective offline state once per second.

4): Sentinel when a sufficient number of (not less than the value specified profiles) Master does confirm the subjective offline state entered, the Master will be marked offline objective within a specified time frame.

4, subjective and objective offline offline

Subjective offline: Subjectively Down, referred SDOWN, referring to a Sentinel offline determine the current instance of the server made a redis.
Objective offline: Objectively Down, referred ODOWN, refers to a plurality of instances Sentinel SDOWN making judgment on Master Server, and interact with each other by a SENTINEL is-master-down-by -addr command later, offline derived Master Server Analyzing and open failover

5, the configuration mode Sentinel

1.每台机器上修改redis主配置文件redis.conf文件设置:bind 0.0.0.0   ---已经操作
做主从同步
2.每台机器上修改sentinel.conf配置文件:修改如下配置
[root@redis-master src]# cd ..
[root@redis-master redis]# vim sentinel.conf
sentinel monitor mymaster 10.0.0.137 6379 2 #当集群中有2个sentinel认为master死了时,才能真正认为该master已经不可用了。 (slave上面写的是master的ip,master写自己ip)
sentinel down-after-milliseconds mymaster 3000   #单位毫秒  ping 3000毫秒没有响应 认为他不可用
sentinel failover-timeout mymaster 10000   #若sentinel在该配置值内未能完成failover(故障转移)操作(即故障时master/slave自动切换),则认为本次failover失败。
protected-mode no  #关闭加密模式--新添加到sentinel配置文件中
3.每台机器启动哨兵服务:
[root@redis-master redis]# ./src/redis-sentinel sentinel.conf  &
注意:在生产环境下将哨兵模式启动放到后台执行:     ./src/redis-sentinel sentinel.conf &

src/redis-cli 进去后 info  replication  可以查看状态

Here Insert Picture Description
Here Insert Picture Description

将master的哨兵模式退出(Crtl+c),再将redis服务stop了,在两台slave上面查看其中一台是否切换为master:(没有优先级,为随机切换)

Here Insert Picture Description

Published 48 original articles · won praise 18 · views 3631

Guess you like

Origin blog.csdn.net/wx912820/article/details/105167910