Redis基础知识(学习笔记19--Redis Sentinel)

 优化配置参数

1.down-after-milliseconds

# sentinel down-after-milliseconds <master-name> <milliseconds>
#
# Number of milliseconds the master (or any attached【所依附的】 slave or sentinel) should
# be unreachable (as in, not acceptable reply to PING, continuously, for the
# specified period) in order to consider it in S_DOWN state (Subjectively
# Down).
# 这段的意思是sentinel在和master【注意:不仅仅是master,还有slave、sentinel】失联多少毫秒后,可以做出主节点S_DOWN的判断。
# 此参数的作用范围不仅仅是 sentinel到master的连接;还有sentinel到slave的连接;sentinel到sentinel的连接。
# Default is 30 seconds.

sentinel down-after-milliseconds mymaster 30000

换句话说

down-after-milliseconds is the time in milliseconds an instance should not be reachable (either does not reply to our PINGs or it is replying with an error) for a Sentinel starting to think it is down.

2. parallel-syncs

# sentinel parallel-syncs <master-name> <numslaves>
#
# How many slaves we can reconfigure to point to the new slave simultaneously【同时】
# during the failover. Use a low number if you use the slaves to serve query
# to avoid that all the slaves will be unreachable at about the same
# time while performing the synchronization with the master.
##如果想在failover期间,slave同步新master的这个过程中,仍然想有部分slave 可以提供查询服务,那么可以将这个
##值设置小一点。【需要注意的是,这样带来的坏处就是:提供的查询服务,不保证数据的一致性,和主节点是有数据差异的;
##此外,faiover的master 和 所有slave的数据同步过程被拉长了】 sentinel parallel
-syncs mymaster 1

parallel-syncs sets the number of replicas that can be reconfigured to use the new master after a failover at the same time. The lower the number, the more time it will take for the failover process to complete, however if the replicas are configured to serve old data, you may not want all the replicas to re-synchronize with the master at the same time. While the replication process is mostly non blocking for a replica, there is a moment when it stops to load the bulk data from the master. You may want to make sure only one replica at a time is not reachable by setting this option to the value of 1. 

 3.failover-timeout

# sentinel failover-timeout <master-name> <milliseconds>
#
# Specifies the failover timeout in milliseconds. It is used in many ways: ##【注意:这个时间有多个用途】
#
# - The time needed to re-start a failover after a previous failover was
# already tried against the same master by a given Sentinel, is two
# times the failover timeout. ---定语比较多,比较复杂,
# 抽出核心主谓宾:The time is two times the failover timeout. # #
- The time needed for a slave replicating to a wrong master according # to a Sentinel current configuration, to be forced to replicate # with the right master, is exactly【确切地;恰好】 the failover timeout (counting since # the moment a Sentinel detected the misconfiguration).##【从sentinel发现配置信息不准确时开始计时】
# 抽出核心主谓宾:The time is exactly the failover timeout. # #
- The time needed to cancel a failover that is already in progress but # did not produced any configuration change (SLAVEOF NO ONE yet not # acknowledged by the promoted slave).
# 抽出核心主谓宾:The time needed to cancel a failover. # #
- The maximum time a failover in progress waits for all the slaves to be # reconfigured as slaves of the new master. However even after this time # the slaves will be reconfigured by the Sentinels anyway, but not with # the exact parallel-syncs progression as specified. # 【however后面的意思是说:然而,不管怎么样,即是超过了这个定义的最大阈值,sentinel还是可以修改配置的;
# 但是,不是严格按照前面定义的parallel-syncs的方式,例如,不再是前面默认的一个一个slave节点处理了。】 # Default is
3 minutes. sentinel failover-timeout mymaster 180000

 Moreover Sentinels have a rule: if a Sentinel voted another Sentinel for the failover of a given master, it will wait some time to try to failover the same master again. This delay is the 2 * failover-timeout you can configure in sentinel.conf. This means that Sentinels will not try to failover the same master at the same time, the first to ask to be authorized will try, if it fails another will try after some time, and so forth.

 指定故障转移的超时时间,默认时间为3分钟。该超时时间的用途有很多:

  • 由于第一次故障转移失败,在同一个master上进行第二次故障转移尝试的时间为gai值的两倍。
  • 新master晋升完毕,slave从老master强制移到新master进行数据同步的时间阈值。
  • 取消正在进行的故障转移所需的时间阈值。
  • 新master晋升完毕,所有的replicas的配置文件更新为新master的时间阈值。

 

《High availability with Redis Sentinel》

https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/

热门相关:最强神话帝皇   重生田园贵媛:名门暖婚   美女总裁之贴身高手   强宠头号鲜妻:陆少,滚!   明尊