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.pswp.cn/web/44110.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/44110.shtml
英文地址,請注明出處:http://en.pswp.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&#…