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
指定系统日志的设备。必须是 USER
或 LOCAL0-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
在认为一个主服务器已经不可用时所需的最小投票数(一般建议为哨兵数量的一半以上)。
例如,想要 Sentine
l 监控一个名为 mymaster
的 Redis
主节点,该服务器的 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
为用户配置的密码,client
、subscribe
等是执行 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
本身需要验证的密码,配置后 Sentine
l 会尝试使用相同的密码与所有其他 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>
这个脚本的主要作用通常包括:
- 更新客户端配置,使其能够连接到新的主节点。
- 执行一些清理工作,如删除旧主节点的相关配置或资源。
- 发送通知或警报,告知系统管理员故障转移已完成。
当 Sentine
l 调用 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-script
和 client-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
地址。此外,它还要求 Redis
的 replica-announce-ip
仅指定 IP
地址。
可以通过启用 resolve-hostnames
来支持主机名(hostname
), Sentinel
会尝试解析主机名而不是直接使用 IP
地址来识别 Redis
实例。
SENTINEL resolve-hostnames no
注意,必须确保您的 DNS
配置正确,并且 DNS
解析不会引入非常长的延迟。在使用容器化部署(如 Docker
或 Kubernetes
)时遇到网络配置问题,并且 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
在将主服务器标记为客观下线之前应该等待的时间长度。
相关文章:
Redis 7.x 系列【24】哨兵模式配置项
有道无术,术尚可求,有术无道,止于术。 本系列Redis 版本 7.2.5 源码地址:https://gitee.com/pearl-organization/study-redis-demo 文章目录 1. 前言2. 配置项2.1 protected-mode2.2 port2.3 daemonize2.4 pidfile2.5 loglevel2.…...
SpringBoot+Vue实现简单的文件上传(策略模式)
SpringBootVue实现简单的文件上传 1 环境 SpringBoot 3.2.1,Vue 2,ElementUI 2 问题 前两篇文章,我们上传了txt、Excel文件,其实文件类型有很多种,如果我们的upload组件没有上传文件类型的限制,那么同一个…...

软考中级科目包含哪些?应该考哪个?
软考中级包含5个专业方向,分别是:计算机软件、计算机网络、计算机应用技术、信息系统、信息服务。这5个方向又对应15个软考中级科目。 信息系统包括:系统集成项目管理工程师、信息系统监理师、信息安全工程师、数据库系统工程师、信息系统管…...

ArcGIS Enterprise 命令行组件创建配置
1. 创建ArcGIS Server站点 使用 createsite工具 命令行直接执行 createsite.sh [-u <arg>] [-p <arg>] [-d <arg>] [-c <arg>]执行文件 createsite.sh [-f <FILE>]安装目录下会有类似的创建站点文件: 修改其中的内容,…...
Web组成架构
网站源码:分脚本类型,分应用方向操作系统:windows,linux中间件(搭建平台):apche、IIS、tomcat、nginx等数据库:mssql、oracle、sybase、db2、access等 WEB相关安全漏洞 WEB源码类对…...

「Pytorch」roLabelImg 图像异常旋转 bug
在进行Yolo-obb 模型训练的时候需要标注旋转框,roLabelImg 是比较推荐的一款旋转框标注工具,既可以标注正常的矩形框,还可以标注旋转框 roLabelImg Github 地址:https://github.com/HumanSignal/labelImg 但是在使用过程中遇到了…...

java.sql.SQLException: Unknown system variable ‘query_cache_size‘【Pyspark】
1、问题描述 学习SparkSql中,将spark中dataframe数据结构保存为jdbc的格式并提交到本地的mysql中,相关代码见文章末尾。 运行代码时报出相关配置文件错误,如下。 根据该报错,发现网络上多数解决方都是基于java开发的解决方案&a…...

汽车连接器革新!中国星坤产品在汽车安全与效率中的卓越表现!
随着汽车行业的快速发展,车载电子系统的复杂性不断增加,对连接器的性能要求也越来越高。中国星坤推出的汽车连接器,以其卓越的设计和性能,为汽车行业带来了一场技术革新。这些连接器不仅能够适应极端的工作环境,还确保…...

DHCP服务、FTP服务
一、DHCP 1.1 DHCP是什么 DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一种网络协议,用于自动分配 IP 地址和其他网络配置信息给网络中的设备 1.2 DHCP的好处 自动化: 减少了手动配置 IP 地址和网络参数的工…...
AWS云计算实战:电商平台发卡机器人开发指南
在当今数字化时代,电商平台的自动化运营变得尤为重要。本文将深入探讨如何利用AWS云计算平台开发一款高效的发卡机器人,旨在提高电商平台的自动化水平和用户体验。 关键词 AWS云计算, 电商平台, 发卡机器人 1. 引言 随着电商行业的蓬勃发展ÿ…...

虚拟机及其Debian(kali)安装
本机电脑为Windows10系统专业版,在此基础上安装VMware和系统(Kali) 步骤如下 一、安装 VMware Workstation Pro v16.2.4 安装步骤可参照网上博客,该步骤较简单,此处不做讲解。文件中共计两个,其中一个是激活…...

Linux部署禅道(无脑复制版)
目录 环境部署1、下载,解压2、启动3、设置开机自启 登录禅道登录数据库1、设置账号2、网页登录数据库 环境 Linux系统 Centos7 《Linux一键安装包安装禅道》视频链接: https://www.zentao.net/zentao-install/zentao-linux-install-80523.html 部署 …...

C# .net6使用Hangfire
首先我们先来了解什么是Hangfire? Hangfire 是一个用于 .NET 的任务调度库,允许你在后台运行任务,而不需要依赖外部的任务队列服务或复杂的基础设施。它简化了后台任务的创建、调度和管理过程,使得在 .NET 应用程序中处理长期运行…...
NaiveUI与ElementUI 比较分析
前言 在前端开发的广阔领域中,Vue.js作为最流行的前端框架之一,为开发者提供了丰富的组件库,其中NaiveUI和ElementUI是两个备受瞩目的选择。本文将深入分析这两个组件库的特点、优劣势以及适用场景,帮助开发者在项目中做出更合适…...
使用ChatGPT来撰写和润色学术论文的教程(含最新升级开桶ChatGpt4教程)
现在有了ChatGPT4o更加方便了, 但次数太少了 想要增加次数可以考虑升级开桶ChatGpt4 一、引言 在学术研究中,撰写高质量的论文是一项重要的技能。本教程将介绍如何利用ChatGPT来辅助完成从论文构思到润色的全过程。 二、使用ChatGPT写论文 1. 写标题 Title/T…...

matine组件库踩坑日记 --- react
Mantine实践 一 禁忌核心css样式二 添加轮播图扩展组件 一 禁忌核心css样式 import React from react import ReactDOM from react-dom/client import { BrowserRouter } from react-router-dom; import App from ./App.jsx import ./index.css import mantine/core/styles.cs…...
爬虫学习前记----Python
引言 1.语言:python 2.学习资源:【Python爬虫】 3.爬虫日记: python内容 1.字符串输出 (1)引号问题 print("python") 输出:pythonprint(python) 输出:pythonprint(python"学习") 输出&…...
详解Go语言中的Goroutine组(Group)在项目中的使用
背景(Why) Go语言通过其内置的goroutine和通道(channel)机制,提供了强大的并发支持。goroutine的开销非常低,一个goroutine仅占用几KB的内存,可以轻松创建成千上万个goroutine来处理并发任务。然而,随着并…...

Linux桌面环境手动编译安装librime、librime-lua以及ibus-rime,提升中文输入法体验
Linux上的输入法有很多,大体都使用了Fcitx或者iBus作为输入法的引擎。相当于有了一个很不错的“地基”,你可以在这个“地基”上盖上自己的“小别墅”。而rime输入法,就是一个“毛坯别墅”,你可以在rime的基础上,再装修…...

一文入门【NestJs】Providers
Nest学习系列 ✈️一文入门【NestJS】 ✈️一文入门【NestJs】Controllers 控制器 🚩 前言 在NestJS的世界里,理解“Providers”是构建健壮、可维护的后端服务的关键。NestJS,作为Node.js的一个现代框架,采用了Angular的一些核…...

深度学习在微纳光子学中的应用
深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向: 逆向设计 通过神经网络快速预测微纳结构的光学响应,替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…...
【网络】每天掌握一个Linux命令 - iftop
在Linux系统中,iftop是网络管理的得力助手,能实时监控网络流量、连接情况等,帮助排查网络异常。接下来从多方面详细介绍它。 目录 【网络】每天掌握一个Linux命令 - iftop工具概述安装方式核心功能基础用法进阶操作实战案例面试题场景生产场景…...

iOS 26 携众系统重磅更新,但“苹果智能”仍与国行无缘
美国西海岸的夏天,再次被苹果点燃。一年一度的全球开发者大会 WWDC25 如期而至,这不仅是开发者的盛宴,更是全球数亿苹果用户翘首以盼的科技春晚。今年,苹果依旧为我们带来了全家桶式的系统更新,包括 iOS 26、iPadOS 26…...

51c自动驾驶~合集58
我自己的原文哦~ https://blog.51cto.com/whaosoft/13967107 #CCA-Attention 全局池化局部保留,CCA-Attention为LLM长文本建模带来突破性进展 琶洲实验室、华南理工大学联合推出关键上下文感知注意力机制(CCA-Attention),…...

《Qt C++ 与 OpenCV:解锁视频播放程序设计的奥秘》
引言:探索视频播放程序设计之旅 在当今数字化时代,多媒体应用已渗透到我们生活的方方面面,从日常的视频娱乐到专业的视频监控、视频会议系统,视频播放程序作为多媒体应用的核心组成部分,扮演着至关重要的角色。无论是在个人电脑、移动设备还是智能电视等平台上,用户都期望…...

从零实现STL哈希容器:unordered_map/unordered_set封装详解
本篇文章是对C学习的STL哈希容器自主实现部分的学习分享 希望也能为你带来些帮助~ 那咱们废话不多说,直接开始吧! 一、源码结构分析 1. SGISTL30实现剖析 // hash_set核心结构 template <class Value, class HashFcn, ...> class hash_set {ty…...
Swagger和OpenApi的前世今生
Swagger与OpenAPI的关系演进是API标准化进程中的重要篇章,二者共同塑造了现代RESTful API的开发范式。 本期就扒一扒其技术演进的关键节点与核心逻辑: 🔄 一、起源与初创期:Swagger的诞生(2010-2014) 核心…...
A2A JS SDK 完整教程:快速入门指南
目录 什么是 A2A JS SDK?A2A JS 安装与设置A2A JS 核心概念创建你的第一个 A2A JS 代理A2A JS 服务端开发A2A JS 客户端使用A2A JS 高级特性A2A JS 最佳实践A2A JS 故障排除 什么是 A2A JS SDK? A2A JS SDK 是一个专为 JavaScript/TypeScript 开发者设计的强大库ÿ…...
C#中的CLR属性、依赖属性与附加属性
CLR属性的主要特征 封装性: 隐藏字段的实现细节 提供对字段的受控访问 访问控制: 可单独设置get/set访问器的可见性 可创建只读或只写属性 计算属性: 可以在getter中执行计算逻辑 不需要直接对应一个字段 验证逻辑: 可以…...

阿里云Ubuntu 22.04 64位搭建Flask流程(亲测)
cd /home 进入home盘 安装虚拟环境: 1、安装virtualenv pip install virtualenv 2.创建新的虚拟环境: virtualenv myenv 3、激活虚拟环境(激活环境可以在当前环境下安装包) source myenv/bin/activate 此时,终端…...