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

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

本系列Redis 版本 7.2.5

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

文章目录

    • 1. 前言
    • 2. 配置项
      • 2.1 protected-mode
      • 2.2 port
      • 2.3 daemonize
      • 2.4 pidfile
      • 2.5 loglevel
      • 2.6 logfile
      • 2.7 syslog-enabled
      • 2.8 syslog-ident
      • 2.9 syslog-facility
      • 2.10 sentinel announce-ip、sentinel announce-port
      • 2.11 dir
      • 2.12 sentinel monitor
      • 2.13 sentinel auth-pass、sentinel auth-user
      • 2.14 sentinel down-after-milliseconds
      • 2.15 user
      • 2.16 acllog-max-len
      • 2.17 aclfile
      • 2.18 requirepass
      • 2.19 sentinel sentinel-user、sentinel sentinel-pass
      • 2.20 sentinel parallel-syncs
      • 2.21 sentinel failover-timeout
      • 2.22 sentinel notification-script
      • 2.23 sentinel client-reconfig-script
      • 2.24 sentinel deny-scripts-reconfig
      • 2.25 sentinel deny-scripts-reconfig
      • 2.26 SENTINEL resolve-hostnames
      • 2.27 SENTINEL announce-hostnames
      • 2.28 SENTINEL master-reboot-down-after-period

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 在将主服务器标记为客观下线之前应该等待的时间长度。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/44110.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

i18n、L10n、G11N 和 T9N 的含义

注&#xff1a;机翻&#xff0c;未校对。 Looking into localization for the first time can be terrifying, if only due to all of the abbreviations. But the meaning of i18n, L10n, G11N, and T9N, are all very easy to understand. 第一次研究本地化可能会很可怕&…

深入探索Python Web抓取世界:利用BeautifulSoup与Pandas构建全面的网页数据采集与分析流程

引言 在信息爆炸的时代&#xff0c;网络成为了一个无尽的知识宝库&#xff0c;其中包含了大量有价值的公开数据。Python作为一种灵活多变且具有强大生态系统支持的编程语言&#xff0c;尤其擅长于数据的收集、处理与分析工作。本文将聚焦于Python的两大利器——BeautifulSoup和…

如何做一个迟钝不受伤的打工人?

一、背景 在当前激烈的职场环境中&#xff0c;想要成为一个相对“迟钝”且不易受伤的打工人&#xff0c;以下是一些建议&#xff0c;但请注意&#xff0c;这里的“迟钝”并非指智力上的迟钝&#xff0c;而是指在应对复杂人际关系和压力时展现出的豁达与钝感力&#xff1a; 尊重…

【测开能力提升-fastapi框架】fastapi路由分发

1.7 路由分发 apps/app01.py from fastapi import APIRouterapp01 APIRouter()app01.get("/food") async def shop_food():return {"shop": "food"}app01.get("/bed") async def shop_food():return {"shop": "bed&…

部署stable-diffusion时遇到RuntimeError: Couldn‘t clone Stable Diffusion XL.问题

错误信息如下&#xff1a; venv "E:\AI\stable-diffusion-webui-master\venv\Scripts\Python.exe" fatal: ambiguous argument HEAD: unknown revision or path not in the working tree. Use -- to separate paths from revisions, like this: git <command>…

js前端隐藏列 并且获取值,列表复选框

列表框 <div class"block" id"psi_wh_allocation_m"><table id"result" class"list auto hover fixed" style"width:100%;border-collapse:collapse"><thead><tr><%--<th></th>--%&…

LabVIEW滤波器性能研究

为了研究滤波器的滤波性能&#xff0c;采用LabVIEW设计了一套滤波器性能研究系统。该系统通过LabVIEW中的波形生成函数&#xff0c;输出幅值及频率可调的正弦波和白噪声两种信号&#xff0c;并将白噪声与正弦波叠加&#xff0c;再通过滤波器输出纯净的正弦波信号。系统通过FFT&…

Python从0到100(三十八):json字符串的数据提取

JSON的数据提取 1.学习目标 掌握JSON相关的方法&#xff08;load, loads, dump, dumps&#xff09;了解JSONPath的使用&#xff08;提取JSON中的数据&#xff09; 2 复习什么是JSON JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式&#xff0c;它使得人们很容…

富文本braft-editor插件分享

效果展示 安装插件 npm install braft-editor 或者 yarn add braft-editor 主要代码 import React, { useState, forwardRef } from react //引入富文本编辑器 import BraftEditor from braft-editor // 引入编辑器样式 import braft-editor/dist/index.css import { B…

thinkphp8框架源码精讲

前言 很开心你能看到这个笔记&#xff0c;相信你对thinkphp是有一定兴趣的&#xff0c;正好大家都是志同道合的人。 thinkphp是我入门学习的第一个框架&#xff0c;经过这么多年了&#xff0c;还没好好的研究它&#xff0c;今年利用了空闲的时间狠狠的深入源码学习了一把&…

缺陷检测总结

基于深度学习的缺陷检测方法 1、全监督模型&#xff1a;基于表征学习的缺陷检测模型&#xff0c;基于度量学习的缺陷检测模型 1.1、基于表征学习的缺陷检测模型&#xff1a;分类网络&#xff0c;检测网络&#xff0c;分割网络&#xff1b; 其中分类网络的使用方式主要有三种…

2974. 最小数字游戏 Easy

你有一个下标从 0 开始、长度为 偶数 的整数数组 nums &#xff0c;同时还有一个空数组 arr 。Alice 和 Bob 决定玩一个游戏&#xff0c;游戏中每一轮 Alice 和 Bob 都会各自执行一次操作。游戏规则如下&#xff1a; 每一轮&#xff0c;Alice 先从 nums 中移除一个 最小 元素&a…

硅谷甄选运营平台-vue3组件通信方式

vue3组件通信方式 vue2组件通信方式&#xff1a; props:可以实现父子组件、子父组件、甚至兄弟组件通信自定义事件:可以实现子父组件通信全局事件总线$bus:可以实现任意组件通信pubsub:发布订阅模式实现任意组件通信vuex:集中式状态管理容器&#xff0c;实现任意组件通信ref:父…

camunda最终章-springboot

1.实现并行流子流程 1.画图 2.创建实体 package com.jmj.camunda7test.subProcess.entity;import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor;import java.io.Serializable; import java.util.ArrayList; import java.util.List;Data …

C语言 | Leetcode C语言题解之第230题二叉搜索树中第K小的元素

题目&#xff1a; 题解&#xff1a; /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*/int search_num(struct TreeNode* root, int k, int *result, int num) {if(num k 1){retu…

《Foundation 侧边栏》

《Foundation 侧边栏》 介绍 Foundation 是一个强大的前端框架,它提供了一套丰富的工具和组件,帮助开发者快速构建响应式、移动优先的网站和应用程序。在 Foundation 中,侧边栏是一个常用的组件,用于展示导航链接、菜单或其他相关信息。本文将详细介绍如何在 Foundation …

FastGPT连接OneAI接入网络模型

文章目录 FastGPT连接OneAI接入网络模型1.准备工作2.开始部署2.1下载 docker-compose.yml2.2修改docker-compose.yml里的参数 3.打开FastGPT添加模型3.1打开OneAPI3.2接入网络模型3.3重启服务 FastGPT连接OneAI接入网络模型 1.准备工作 本文档参考FastGPT的官方文档 主机ip接…

JDBC 实例分享——简易图书管理系统

目录 前言 数据表的建立 操作包各个类的实现 增加类 删除类 展示类 借阅与归还类 前言 书接上文 JDBC编程的学习——MYsql版本-CSDN博客 本期我们通过对先前图书管理系统进行改造,是它的数据能保存在数据库中 完整代码我已经保存在github中,能不能给个星呢!!!! call…

记一次若依框架和Springboot常见报错的实战漏洞挖掘

目录 前言 本次测实战利用图​ 1.判段系统框架 2.登录页面功能点测试 2.1 弱口令 2.2 webpack泄露信息判断 2.3 未授权接口信息发现 3.进一步测试发现新的若依测试点 3.1 默认弱口令 3.2 历史漏洞 4.访问8080端口发现spring经典爆粗 4.1 druid弱口令 4.2 SwaggerU…

热键危机:揭秘Memcached中的热键问题及其解决方案

热键危机&#xff1a;揭秘Memcached中的热键问题及其解决方案 Memcached是一种广泛使用的高性能分布式内存缓存系统&#xff0c;它通过缓存数据来减少对后端数据库的访问压力&#xff0c;从而提高应用性能。然而&#xff0c;Memcached也可能遇到热键&#xff08;hot key&#…