虽然如今使用哨兵+主从的方式比较少了,但经过理解 Redis 哨兵,咱们能得到更深刻的分布式的知识。redis
sentinel的做用:shell
sentinel monitor <master-group-name> <ip> <port> <quorum>
quorum 的含义:
(1)表示 sentinel 集群中 quorum 个节点认为 master挂了,那么就可能触发自动故障转移进程。
(2)quorum 仅用于故障检测,不涉及sentinel 集群的其余投票决策。编程
sentinel <option_name> <master_name> <option_value>
(1)判断主master挂机的时间 down-after-milliseconds
master没有回复PING或回复错误,这个持续多久了,sentinel节点就能够认为master挂了服务器
(2)在故障转移后从新配置为使用新Master的副本数 parallel-syncs
此数越小,故障转移速度越快
但须要注意的是当副本也提供服务的时候,可能存在不一致数据微信
(3)失败的超时时间 failover-timeout
failover过时时间,当failover开始后,在此时间内仍然没有触发任何failover操做,当前sentinel将会认为这次failoer失败。分布式
sentinel和其副本的自动发现,采用了 Pub/Sub发布订阅机制实现3d
__sentinel__:hello
宣告本身的 ip port runid __sentinel__:hello
@SvenAugustus(https://www.flysium.xyz/)
更多请关注微信公众号【编程不离宗】,专一于分享服务器开发与编程相关的技术干货:
code