Redis 7.x 系列【24】哨兵模式配置项

有道无术,术尚可求,有术无道,止于术。

本系列Redis 版本 7.2.5

源码地址:https://gitee.com/pearl-organization/study-redis-demo

1. 前言

在解压的源码文件中,可以看到哨兵的配置文件 sentinel.conf

# Example sentinel.conf

# By default protected mode is disabled in sentinel mode. Sentinel is reachable
# from interfaces different than localhost. Make sure the sentinel instance is
# protected from the outside world via firewalling or other means.
protected-mode no

# port <sentinel-port>
# The port that this sentinel instance will run on
port 26379

# By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
# daemonized.
daemonize no

# When running daemonized, Redis Sentinel writes a pid file in
# /var/run/redis-sentinel.pid by default. You can specify a custom pid file
# location here.
pidfile /var/run/redis-sentinel.pid

# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
# nothing (nothing is logged)
loglevel notice

# Specify the log file name. Also the empty string can be used to force
# Sentinel to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile ""

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no

# Specify the syslog identity.
# syslog-ident sentinel

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0

# sentinel announce-ip <ip>
# sentinel announce-port <port>
#
# The above two configuration directives are useful in environments where,
# because of NAT, Sentinel is reachable from outside via a non-local address.
#
# When announce-ip is provided, the Sentinel will claim the specified IP address
# in HELLO messages used to gossip its presence, instead of auto-detecting the
# local address as it usually does.
#
# Similarly when announce-port is provided and is valid and non-zero, Sentinel
# will announce the specified TCP port.
#
# The two options don't need to be used together, if only announce-ip is
# provided, the Sentinel will announce the specified IP and the server port
# as specified by the "port" option. If only announce-port is provided, the
# Sentinel will announce the auto-detected local IP and the specified port.
#
# Example:
#
# sentinel announce-ip 1.2.3.4

# dir <working-directory>
# Every long running process should have a well-defined working directory.
# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
# for the process to don't interfere with administrative tasks such as
# unmounting filesystems.
dir /tmp

# sentinel monitor <master-name> <ip> <redis-port> <quorum>
#
# Tells Sentinel to monitor this master, and to consider it in O_DOWN
# (Objectively Down) state only if at least <quorum> sentinels agree.
#
# Note that whatever is the ODOWN quorum, a Sentinel will require to
# be elected by the majority of the known Sentinels in order to
# start a failover, so no failover can be performed in minority.
#
# Replicas are auto-discovered, so you don't need to specify replicas in
# any way. Sentinel itself will rewrite this configuration file adding
# the replicas using additional configuration options.
# Also note that the configuration file is rewritten when a
# replica is promoted to master.
#
# Note: master name should not include special characters or spaces.
# The valid charset is A-z 0-9 and the three characters ".-_".
sentinel monitor mymaster 127.0.0.1 6379 2

# sentinel auth-pass <master-name> <password>
#
# Set the password to use to authenticate with the master and replicas.
# Useful if there is a password set in the Redis instances to monitor.
#
# Note that the master password is also used for replicas, so it is not
# possible to set a different password in masters and replicas instances
# if you want to be able to monitor these instances with Sentinel.
#
# However you can have Redis instances without the authentication enabled
# mixed with Redis instances requiring the authentication (as long as the
# password set is the same for all the instances requiring the password) as
# the AUTH command will have no effect in Redis instances with authentication
# switched off.
#
# Example:
#
# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd

# sentinel auth-user <master-name> <username>
#
# This is useful in order to authenticate to instances having ACL capabilities,
# that is, running Redis 6.0 or greater. When just auth-pass is provided the
# Sentinel instance will authenticate to Redis using the old "AUTH <pass>"
# method. When also an username is provided, it will use "AUTH <user> <pass>".
# In the Redis servers side, the ACL to provide just minimal access to
# Sentinel instances, should be configured along the following lines:
#
#     user sentinel-user >somepassword +client +subscribe +publish \
#                        +ping +info +multi +slaveof +config +client +exec on

# sentinel down-after-milliseconds <master-name> <milliseconds>
#
# Number of milliseconds the master (or any attached replica 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).
#
# Default is 30 seconds.
sentinel down-after-milliseconds mymaster 30000

# IMPORTANT NOTE: starting with Redis 6.2 ACL capability is supported for
# Sentinel mode, please refer to the Redis website https://redis.io/topics/acl
# for more details.

# Sentinel's ACL users are defined in the following format:
#
#   user <username> ... acl rules ...
#
# For example:
#
#   user worker +@admin +@connection ~* on >ffa9203c493aa99
#
# For more information about ACL configuration please refer to the Redis
# website at https://redis.io/topics/acl and redis server configuration 
# template redis.conf.

# ACL LOG
#
# The ACL Log tracks failed commands and authentication events associated
# with ACLs. The ACL Log is useful to troubleshoot failed commands blocked 
# by ACLs. The ACL Log is stored in memory. You can reclaim memory with 
# ACL LOG RESET. Define the maximum entry length of the ACL Log below.
acllog-max-len 128

# Using an external ACL file
#
# Instead of configuring users here in this file, it is possible to use
# a stand-alone file just listing users. The two methods cannot be mixed:
# if you configure users here and at the same time you activate the external
# ACL file, the server will refuse to start.
#
# The format of the external ACL user file is exactly the same as the
# format that is used inside redis.conf to describe users.
#
# aclfile /etc/redis/sentinel-users.acl

# requirepass <password>
#
# You can configure Sentinel itself to require a password, however when doing
# so Sentinel will try to authenticate with the same password to all the
# other Sentinels. So you need to configure all your Sentinels in a given
# group with the same "requirepass" password. Check the following documentation
# for more info: https://redis.io/topics/sentinel
#
# IMPORTANT NOTE: starting with Redis 6.2 "requirepass" is a compatibility
# layer on top of the ACL system. The option effect will be just setting
# the password for the default user. Clients will still authenticate using
# AUTH <password> as usually, or more explicitly with AUTH default <password>
# if they follow the new protocol: both will work.
#
# New config files are advised to use separate authentication control for
# incoming connections (via ACL), and for outgoing connections (via
# sentinel-user and sentinel-pass) 
#
# The requirepass is not compatible with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.

# sentinel sentinel-user <username>
#
# You can configure Sentinel to authenticate with other Sentinels with specific
# user name. 

# sentinel sentinel-pass <password>
#
# The password for Sentinel to authenticate with other Sentinels. If sentinel-user
# is not configured, Sentinel will use 'default' user with sentinel-pass to authenticate.

# sentinel parallel-syncs <master-name> <numreplicas>
#
# How many replicas we can reconfigure to point to the new replica simultaneously
# during the failover. Use a low number if you use the replicas to serve query
# to avoid that all the replicas will be unreachable at about the same
# time while performing the synchronization with the master.
sentinel parallel-syncs mymaster 1

# 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 needed for a replica 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).
#
# - 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 replica).
#
# - The maximum time a failover in progress waits for all the replicas to be
#   reconfigured as replicas of the new master. However even after this time
#   the replicas will be reconfigured by the Sentinels anyway, but not with
#   the exact parallel-syncs progression as specified.
#
# Default is 3 minutes.
sentinel failover-timeout mymaster 180000

# SCRIPTS EXECUTION
#
# sentinel notification-script and sentinel reconfig-script are used in order
# to configure scripts that are called to notify the system administrator
# or to reconfigure clients after a failover. The scripts are executed
# with the following rules for error handling:
#
# If script exits with "1" the execution is retried later (up to a maximum
# number of times currently set to 10).
#
# If script exits with "2" (or an higher value) the script execution is
# not retried.
#
# If script terminates because it receives a signal the behavior is the same
# as exit code 1.
#
# A script has a maximum running time of 60 seconds. After this limit is
# reached the script is terminated with a SIGKILL and the execution retried.

# NOTIFICATION SCRIPT
#
# sentinel notification-script <master-name> <script-path>
# 
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.
#
# The script must exist and be executable in order for sentinel to start if
# this option is provided.
#
# Example:
#
# sentinel notification-script mymaster /var/redis/notify.sh

# CLIENTS RECONFIGURATION SCRIPT
#
# sentinel client-reconfig-script <master-name> <script-path>
#
# When the master changed because of a failover a script can be called in
# order to perform application-specific tasks to notify the clients that the
# configuration has changed and the master is at a different address.
# 
# The following arguments are passed to the script:
#
# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
#
# <state> is currently always "start"
# <role> is either "leader" or "observer"
# 
# The arguments from-ip, from-port, to-ip, to-port are used to communicate
# the old address of the master and the new address of the elected replica
# (now a master).
#
# This script should be resistant to multiple invocations.
#
# Example:
#
# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh

# SECURITY
#
# By default SENTINEL SET will not be able to change the notification-script
# and client-reconfig-script at runtime. This avoids a trivial security issue
# where clients can set the script to anything and trigger a failover in order
# to get the program executed.

sentinel deny-scripts-reconfig yes

# REDIS COMMANDS RENAMING (DEPRECATED)
#
# WARNING: avoid using this option if possible, instead use ACLs.
#
# Sometimes the Redis server has certain commands, that are needed for Sentinel
# to work correctly, renamed to unguessable strings. This is often the case
# of CONFIG and SLAVEOF in the context of providers that provide Redis as
# a service, and don't want the customers to reconfigure the instances outside
# of the administration console.
#
# In such case it is possible to tell Sentinel to use different command names
# instead of the normal ones. For example if the master "mymaster", and the
# associated replicas, have "CONFIG" all renamed to "GUESSME", I could use:
#
# SENTINEL rename-command mymaster CONFIG GUESSME
#
# After such configuration is set, every time Sentinel would use CONFIG it will
# use GUESSME instead. Note that there is no actual need to respect the command
# case, so writing "config guessme" is the same in the example above.
#
# SENTINEL SET can also be used in order to perform this configuration at runtime.
#
# In order to set a command back to its original name (undo the renaming), it
# is possible to just rename a command to itself:
#
# SENTINEL rename-command mymaster CONFIG CONFIG

# HOSTNAMES SUPPORT
#
# Normally Sentinel uses only IP addresses and requires SENTINEL MONITOR
# to specify an IP address. Also, it requires the Redis replica-announce-ip
# keyword to specify only IP addresses.
#
# You may enable hostnames support by enabling resolve-hostnames. Note
# that you must make sure your DNS is configured properly and that DNS
# resolution does not introduce very long delays.
#
SENTINEL resolve-hostnames no

# When resolve-hostnames is enabled, Sentinel still uses IP addresses
# when exposing instances to users, configuration files, etc. If you want
# to retain the hostnames when announced, enable announce-hostnames below.
#
SENTINEL announce-hostnames no

# When master_reboot_down_after_period is set to 0, Sentinel does not fail over
# when receiving a -LOADING response from a master. This was the only supported
# behavior before version 7.0.
#
# Otherwise, Sentinel will use this value as the time (in ms) it is willing to
# accept a -LOADING response after a master has been rebooted, before failing
# over.

SENTINEL master-reboot-down-after-period mymaster 0

2. 配置项

2.1 protected-mode

配置是否开启保护模式。

protected-mode no

默认为 no ,除了本地主机以外的其他地址也可以访问,在生产环境中,需要通过防火墙或其他方式保护 Sentinel 实例,并禁止外网访问。

2.2 port

配置哨兵节点的运行端口。

port 26379

2.3 daemonize

配置是否允许后台运行(作为守护进程运行),默认为 no ,推荐设置为 yes ,当 Redis Sentinel 作为守护进程运行时,会在/var/run/redis-sentinel.pid中写入一个PID文件。

daemonize no

2.4 pidfile

配置 Redis Sentinel 作为守护进程运行时,PID文件的位置和名称。

pidfile /var/run/redis-sentinel.pid

2.5 loglevel

配置日志级别。

loglevel notice

可配置项:

  • debug:大量信息,对开发/测试有用
  • verbose:许多很少有用的信息,但不像debug级别那样混乱
  • notice:中等详细程度,可能是你在生产环境中想要的
  • warning:仅记录非常重要/关键的消息
  • nothing:不记录任何内容

2.6 logfile

配置日志文件名称。使用空字符串表示强制 Sentinel 在标准输出上记录日志。

logfile ""

2.7 syslog-enabled

配置是否启用系统日志记录。

# syslog-enabled no

2.8 syslog-ident

配置系统日志的身份。

# syslog-ident sentinel

2.9 syslog-facility

指定系统日志的设备。必须是 USERLOCAL0-LOCAL7 之间的一个。

# syslog-facility local0

2.10 sentinel announce-ip、sentinel announce-port

指定当前Sentinel 节点的 IP 地址和端口,这在某些特定的网络配置或部署场景中非常有用,比如当从节点位于 NAT 后面或使用了容器/虚拟化技术时。

sentinel announce-ip <ip>
sentinel announce-port <port>

2.11 dir

配置工作目录,对于Redis Sentinel来说,在启动时切换到 /tmp 目录是最简单的方法,可以避免与其他文件系统等管理任务产生干扰。

dir /tmp

2.12 sentinel monitor

是一个关键配置项,用于定义一个要被 Sentinel 监控的 Redis 主服务器,并且只有在至少 <quorum>Sentinel 同意的情况下,才认为它处于 O_DOWN(客观下线)状态。

# sentinel monitor <master-name> <ip> <redis-port> <quorum>
sentinel monitor mymaster 127.0.0.1 6379 2

参数说明:

  • <master-name>Redis 主节点指定的名字,这个名字在 Sentinel 的配置和通知中会被用到。
  • <ip> :主节点的 IP 地址。
  • <redis-port> :主节点的监听端口。
  • <quorum>: 定义 Sentinel 在认为一个主服务器已经不可用时所需的最小投票数(一般建议为哨兵数量的一半以上)。

例如,想要 Sentinel 监控一个名为 mymasterRedis 主节点,该服务器的 IP 地址是 192.168.1.1,端口是 6379,并且需要至少有两个 Sentinel 同意该主服务器已不可用时才将其标记为客观下线,这样配置:

sentinel monitor mymaster 127.0.0.1 6379 2

注意事项:

  • 从服务器是自动发现的,因此不需要以任何方式指定从节点。Sentinel 本身会重写这个配置文件,通过添加额外的配置选项来包含从节点。
  • 当从节点被提升为主节点时,配置文件也会被重写。
  • 主节点名称不应包含特殊字符或空格。有效的字符集是 A-z 0-9.-_
  • 无论 O_DOWN 的法定人数是多少,都需要被已知 Sentinel 的大多数选举出来,才能开始故障转移,因此在少数派的情况下无法进行故障转移。

2.13 sentinel auth-pass、sentinel auth-user

如果要监控的 Redis 实例设置了密码,sentinel auth-pass 用于设置与主节点和从节点进行身份验证的密码。请注意,主节点的密码也用于从节点,因此,主从节点的密码需要保持一致。如果存在未启用身份验证的 Redis 实例,执行AUTH命令也没啥影响。

sentinel auth-pass <master-name> <password>

还可以配置用户名:

sentinel auth-user <master-name> <username>

为了向 Sentinel 实例提供最小访问权限,应该按照以下方式配置 ACL

user sentinel-user >somepassword +client +subscribe +publish \
+ping +info +multi +slaveof +config +client +exec on

其中 >somepassword 为用户配置的密码,clientsubscribe等是执行 Sentinel 监控所需的最少命令的权限,on关键字表示这些权限将在所有数据库上生效。

2.14 sentinel down-after-milliseconds

Sentinel 向主从节点发送 PING 命令后,多少毫秒内没有响应时,则标记为 S_DOWN 状态(主观下线)。

配置多少毫秒

# sentinel down-after-milliseconds <master-name> <milliseconds>
sentinel down-after-milliseconds mymaster 30000

默认值是 30 秒,如果在这段时间内无法响应,Sentinel会进一步评估是否需要触发故障转移过程。

2.15 user

Redis 6.2 开始, Sentinel 模式支持 ACL访问控制列表)功能,可以配置主从节点的 ACL 用户名和权限。

# user <用户名> ... ACL规则 ...
# user <username> ... acl rules ...
user worker +@admin +@connection ~* on >ffa9203c493aa99

示例中的参数说明:

  • >ffa9203c493aa99 是用户的密码
  • +@admin、+@connection表示赋予用户 worker 对某些命令集的访问权限
  • ~* 表示对所有键的访问权限
  • on 表示这些权限在所有数据库上生效

2.16 acllog-max-len

配置 ACL 日志的最大条目长度。

acllog-max-len 128

ACL 日志跟踪与 ACL(访问控制列表)相关的失败命令和身份验证事件。对于排查被 ACL 阻止的失败命令非常有用。ACL 日志存储在内存中,可以使用 ACL LOG RESET 命令来回收内存。

通过调整日志的最大条目长度,可以控制日志占用的内存量,并在需要时通过重置日志来释放内存。这对于维护 Redis 服务器的性能和安全性非常重要,因为它帮助管理员及时发现和解决潜在的访问控制问题。

2.17 aclfile

除了在 sentinel.conf 文件中配置用户之外,在可以在外部配置某个用户的ACL 文件,这两种方法不能混合使用,否则服务器将拒绝启动。

# aclfile /etc/redis/sentinel-users.acl

外部 ACL 文件的格式与在 redis.conf 文件中使用的格式完全相同。

2.18 requirepass

配置 Sentinel 本身需要验证的密码,配置后 Sentinel 会尝试使用相同的密码与所有其他 Sentinel 进行身份验证。

requirepass <password>

aclfile 配置和 ACL LOAD 命令不兼容,它们会导致 requirepass 被忽略。

2.19 sentinel sentinel-user、sentinel sentinel-pass

配置 Sentinel 与其他 Sentinel 进行身份验证时的用户名、密码。

sentinel sentinel-user <username>
sentinel sentinel-pass <password>

如果未配置 sentinel-user ,将使用 default 用户以及 sentinel-pass 进行身份验证。

2.20 sentinel parallel-syncs

控制当 Redis Sentinel 检测到某个主节点出现故障并需要进行故障转移时,同时允许多少个从节点尝试与新的主节点进行同步。目的是在故障转移过程中,平衡同步新主节点的速度和网络资源的使用。

# sentinel parallel-syncs <master-name> <numreplicas>
sentinel parallel-syncs mymaster 1

在故障转移过程中,选出的新主节点会开始接受写操作,而其他从节点则需要与新主节点进行同步,以更新它们的数据集。如果所有从节点都同时开始同步,可能会给网络和新主节点带来较大的负载。

2.21 sentinel failover-timeout

指定故障转移的超时时间(以毫秒为单位),默认值是 3 分钟(即 180000 毫秒)。

sentinel failover-timeout <master-name> <milliseconds>

如果在指定的时间内,Sentinel 无法完成故障转移的所有必要步骤(如选出新的主节点、更新从节点的复制配置等),则故障转移操作将被视为失败。

2.22 sentinel notification-script

允许用户指定一个脚本,当 Sentinel 节点检测到某些重要事件(如 Redis 实例的主观失效或客观失效等)时,会自动调用这个脚本,用于通知系统管理员或进行自动化的故障处理。

sentinel notification-script <master-name> <script-path>

对于任何在 WARNING 级别生成的 Sentinel 事件(例如,-sdown-odown等),调用指定的通知脚本。此脚本应通过电子邮件、短信或任何其他消息系统通知系统管理员,被监控的 Redis 系统存在问题。

示例:

sentinel notification-script mymaster /var/redis/notify.sh

以上示例表示,对于名为 mymaster 的主服务器,当发生 WARNING 级别的事件时,Sentinel 将调用 /var/redis/notify.sh 脚本,并向其传递事件类型和事件描述作为参数。

通知脚本和其他的脚本的最大运行时间为 60 秒,达到此限制后,脚本将通过 SIGKILL 信号终止,并尝试重新执行。脚本的执行遵循以下错误处理规则:

  • 如果脚本以“1”退出,则稍后将重试执行(目前最大重试次数设置为10次)。
  • 如果脚本以“2”(或更高值)退出,则不会重试脚本执行。
  • 如果脚本因接收到信号而终止,其行为与退出码为1时相同。

2.23 sentinel client-reconfig-script

允许用户指定一个脚本,在 Sentinel 完成对某个主节点的故障转移后自动调用这个脚本,这个脚本可以执行必要的操作来通知客户端配置已经更改。

sentinel client-reconfig-script <master-name> <script-path>

这个脚本的主要作用通常包括:

  • 更新客户端配置,使其能够连接到新的主节点。
  • 执行一些清理工作,如删除旧主节点的相关配置或资源。
  • 发送通知或警报,告知系统管理员故障转移已完成。

Sentinel 调用 sentinel client-reconfig-script 指定的脚本时,会向脚本传递一系列参数,这些参数包含了故障转移的结果信息,通常包括:

  • :主节点的名称。
  • :新主节点的角色。
  • :故障转移的状态或结果。
  • :旧主节点的 IP 地址。
  • :旧主节点的端口号。
  • :新主节点的 IP 地址。
  • :新主节点的端口号。

示例:

sentinel client-reconfig-script mymaster /var/redis/reconfig.sh

以上示例表示,当名为 mymaster 的主服务器因为故障转移而变更时,Sentinel 将调用 /var/redis/reconfig.sh 脚本,并向其传递主服务器的名称、角色、状态、原主服务器的 IP 和端口、新主服务器的 IP 和端口等参数。

2.24 sentinel deny-scripts-reconfig

用于控制是否允许通过 SENTINEL SET 命令修改 notification-scriptclient-reconfig-script 配置。

sentinel deny-scripts-reconfig yes

设置为 yes 时(默认),表示禁止通过 SENTINEL SET 命令修改脚本配置,有助于增加系统的安全性,防止未授权的修改。

2.25 sentinel deny-scripts-reconfig

对命令进行重命名(已弃用)。

SENTINEL rename-command mymaster CONFIG GUESSME

2.26 SENTINEL resolve-hostnames

通常 Sentinel 仅使用 IP 地址,并且要求 SENTINEL MONITOR 指定一个 IP 地址。此外,它还要求 Redisreplica-announce-ip 仅指定 IP 地址。

可以通过启用 resolve-hostnames 来支持主机名(hostname), Sentinel 会尝试解析主机名而不是直接使用 IP 地址来识别 Redis 实例。

SENTINEL resolve-hostnames no

注意,必须确保您的 DNS 配置正确,并且 DNS 解析不会引入非常长的延迟。在使用容器化部署(如 DockerKubernetes)时遇到网络配置问题,并且 Redis 实例的 IP 地址可能会发生变化,启用 SENTINEL resolve-hostnames 可能是一个好的解决方案。

2.27 SENTINEL announce-hostnames

用于控制哨兵在发布通知时是否使用主机名(hostnames)而不是 IP 地址。

SENTINEL announce-hostnames no

当启用 resolve-hostnames 时,Sentinel 在向用户、配置文件等暴露实例时仍然使用 IP 地址。当这个选项被设置为no 时,哨兵在发布主从节点变更通知或其他相关信息时,会使用 IP 地址而不是主机名。

2.28 SENTINEL master-reboot-down-after-period

配置哨兵在认为主节点因为重启而暂时无法访问之前,应该等待的毫秒数,对于处理因系统维护或升级而需要重启 Redis 服务器的场景特别有用。

SENTINEL master-reboot-down-after-period mymaster 0

在某些情况下,比如系统重启或短暂的网络问题,Redis 服务器可能只是暂时无法访问,而不是真正出现了故障。该配置指定 Sentinel 在将主服务器标记为客观下线之前应该等待的时间长度。

相关推荐

  1. Redis 7.x 系列24哨兵模式配置

    2024-07-11 15:26:04       16 阅读
  2. Redis 哨兵模式

    2024-07-11 15:26:04       41 阅读
  3. Redis哨兵模式

    2024-07-11 15:26:04       42 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 15:26:04       53 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 15:26:04       56 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 15:26:04       46 阅读
  4. Python语言-面向对象

    2024-07-11 15:26:04       57 阅读

热门阅读

  1. C语言9 指针

    2024-07-11 15:26:04       21 阅读
  2. 玩转HarmonyOS NEXT之配置文件篇

    2024-07-11 15:26:04       16 阅读
  3. 江苏云服务器适用于哪些场景?

    2024-07-11 15:26:04       18 阅读
  4. 【SQLite3】常用API

    2024-07-11 15:26:04       14 阅读
  5. vue3+ts实现一个表单组件

    2024-07-11 15:26:04       21 阅读
  6. LeetCode K次取反后最大化的数组和(贪心算法)

    2024-07-11 15:26:04       16 阅读
  7. 力扣3148.矩阵中的最大得分

    2024-07-11 15:26:04       18 阅读
  8. AtCoder Beginner Contest 359

    2024-07-11 15:26:04       17 阅读
  9. [NOIP2005 提高组] 篝火晚会(含代码)

    2024-07-11 15:26:04       20 阅读
  10. react获取访问过的路由历史记录

    2024-07-11 15:26:04       20 阅读
  11. 编程范式实现思路介绍

    2024-07-11 15:26:04       18 阅读