기술나눔

Redis 7.x 시리즈 [24] Sentinel 모드 구성 항목

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

방법이 있어도 기술이 없으면 기술을 찾을 수 있고, 기술이 있지만 방법이 없으면 기술에서 멈출 것입니다.

이 시리즈의 Redis 버전 7.2.5

소스 코드 주소: https://gitee.com/pearl-organization/study-redis-demo

1. 소개

압축을 푼 소스 코드 파일에서 Sentinel 구성 파일을 볼 수 있습니다. 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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362

2. 구성 항목

2.1 보호 모드

보호 모드 활성화 여부를 구성합니다.

protected-mode no
  • 1

기본값은 no , 프로덕션 환경에서는 로컬 호스트 이외의 다른 주소에도 액세스할 수 있으므로 방화벽이나 기타 수단으로 보호해야 합니다.Sentinel 인스턴스를 생성하고 외부 네트워크 액세스를 금지합니다.

2.2포트

Sentinel 노드의 실행 포트를 구성합니다.

port 26379
  • 1

2.3 데몬화

백그라운드 실행(데몬 프로세스로 실행)을 허용할지 여부를 구성합니다. 기본값은 no , 권장 설정은 다음과 같습니다.yes ,언제Redis Sentinel 데몬으로 실행하면/var/run/redis-sentinel.pid쓰기PID문서.

daemonize no
  • 1

2.4 pid파일

구성 Redis Sentinel 데몬으로 실행할 때,PID파일의 위치와 이름입니다.

pidfile /var/run/redis-sentinel.pid
  • 1

2.5 로그레벨

로그 수준을 구성합니다.

loglevel notice
  • 1

구성 가능한 항목:

  • debug: 개발/테스트에 유용한 수많은 정보
  • verbose: 드물게 유용한 정보가 많이 있지만, 그다지 유용한 정보는 아닙니다.debug레벨이 너무 헷갈리네요
  • notice: 중간 정도의 장황함, 아마도 프로덕션 환경에서 원하는 것일 것입니다.
  • warning:매우 중요/중요한 메시지만 기록합니다.
  • nothing:아무것도 기록하지 마세요

2.6 로그파일

로그 파일 이름을 구성합니다.강제로 사용하려면 빈 문자열을 사용하세요.Sentinel 표준 출력에 로그온합니다.

logfile ""
  • 1

2.7 syslog 활성화

시스템 로깅 활성화 여부를 구성합니다.

# syslog-enabled no
  • 1

2.8 syslog-ident

시스템 로그의 ID를 구성합니다.

# syslog-ident sentinel
  • 1

2.9 syslog 기능

시스템 로그용 장치를 지정합니다.이어야 한다USER 또는LOCAL0-LOCAL7 그 사이에 하나.

# syslog-facility local0
  • 1

2.10 센티넬 아나운스-ip、센티넬 아나운스-포트

현재를 지정Sentinel 노드IP 슬레이브 노드가 있는 경우와 같은 특정 네트워크 구성 또는 배포 시나리오에서 유용할 수 있는 주소 및 포트NAT 나중에 또는 컨테이너/가상화 기술이 사용되는 경우.

sentinel announce-ip <ip>
sentinel announce-port <port>
  • 1
  • 2

2.11 방향

작업 디렉터리를 구성합니다.Redis Sentinel예를 들어 다음으로 전환합니다. /tmp 디렉터리는 다른 파일 시스템과 같은 관리 작업을 방해하지 않는 가장 간단한 방법입니다.

dir /tmp
  • 1

2.12 센티넬 모니터

정의하는 데 사용되는 주요 구성 항목입니다. Sentinel 모니터링됨Redis 마스터 서버, 그리고 최소한<quorum> 개인Sentinel 동의를 받은 경우에만 해당되는 것으로 간주됩니다.O_DOWN(목표 오프라인) 상태.

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

매개변수 설명:

  • <master-name>Redis 마스터 노드에서 지정한 이름입니다.Sentinel 구성 및 알림에 사용됩니다.
  • <ip> : 마스터 노드의IP 주소.
  • <redis-port> : 마스터 노드의 수신 포트입니다.
  • <quorum>: 정의 Sentinel 마스터 서버를 사용할 수 없는 것으로 간주하는 데 필요한 최소 투표 수(일반적으로 센티널 수의 절반 이상을 권장함)

예를 들어, 원하는 Sentinel 이름이 지정된 파일을 모니터링합니다. mymaster ~의Redis 마스터 노드, 서버의IP 주소는192.168.1.1, 포트는 6379, 최소 2개 이상 있어야 합니다. Sentinel 기본 서버를 사용할 수 없다고 합의한 경우에만 객관적으로 오프라인으로 표시됩니다.

sentinel monitor mymaster 127.0.0.1 6379 2
  • 1

지침:

  • 슬레이브는 자동으로 검색되므로 어떤 방식으로든 슬레이브 노드를 지정할 필요가 없습니다.Sentinel 자체적으로는 추가 구성 옵션을 추가하여 슬레이브 노드를 포함하도록 이 구성 파일을 재정의합니다.
  • 슬레이브 노드가 마스터 노드로 승격되면 구성 파일도 다시 작성됩니다.
  • 마스터 노드 이름에는 특수 문자나 공백이 포함되어서는 안 됩니다.유효한 문자 집합은 다음과 같습니다.A-z 0-9 그리고.-_
  • ~에 관계없이 O_DOWN 정족수를 알아야합니다Sentinel 장애 조치는 다수가 선출될 때까지 시작할 수 없으므로 소수의 경우 장애 조치가 발생할 수 없습니다.

2.13 센티넬 인증 패스、센티넬 인증 사용자

모니터링하고 싶다면 Redis 인스턴스에 비밀번호가 설정되어 있습니다.sentinel auth-pass 마스터 및 슬레이브 노드 인증을 위한 비밀번호를 설정합니다. 마스터 노드의 비밀번호는 슬레이브 노드에도 사용되므로 마스터 노드와 슬레이브 노드의 비밀번호는 일관되어야 합니다.활성화된 인증이 없는 경우Redis 인스턴스, 실행AUTH명령은 효과가 없습니다.

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

사용자 이름을 구성할 수도 있습니다.

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

~하기 위해 Sentinel 인스턴스는 최소한의 액세스를 제공하며 다음과 같이 구성되어야 합니다.ACL

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

~에 >somepassword 사용자에 대해 구성된 비밀번호,clientsubscribe실행을 기다립니다 Sentinel 모니터링에 필요한 최소한의 명령어에 대한 권한,on키워드는 이러한 권한이 모든 데이터베이스에 적용됨을 나타냅니다.

2.14 센티넬 다운-애프터-밀리초

존재하다 Sentinel 마스터-슬레이브 노드로 보내기PING 명령 후 밀리초 이내에 응답이 없으면 다음과 같이 표시됩니다.S_DOWN 상태(주관적으로 오프라인).

구성할 시간은 몇 밀리초입니까?

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

기본값은 다음과 같습니다. 30 초, 이 시간 내에 응답할 수 없는 경우Sentinel장애 조치 프로세스를 트리거해야 하는지 여부는 추가로 평가됩니다.

2.15 사용자

~에서 Redis 6.2 시작, 센티넬 모드 지원ACL액세스 제어 목록) 기능을 사용하면 마스터-슬레이브 노드를 구성할 수 있습니다. ACL 사용자 이름 및 권한.

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

예제의 매개변수 설명:

  • >ffa9203c493aa99 사용자의 비밀번호입니다
  • +@admin、+@connection사용자에게 부여되는 수단 worker 특정 명령 세트에 대한 액세스
  • ~* 모든 키에 대한 액세스를 나타냅니다.
  • on 이러한 권한이 모든 데이터베이스에 적용됨을 나타냅니다.

2.16 acllog-최대-길이

구성 ACL 로그의 최대 항목 길이입니다.

acllog-max-len 128
  • 1

ACL 로그 추적 및ACL (액세스 제어 목록) 관련 실패한 명령 및 인증 이벤트입니다.조사를 위해ACL 차단된 실패한 명령은 매우 유용합니다.ACL 로그는 메모리에 저장되어 사용할 수 있습니다.ACL LOG RESET 메모리를 회수하라는 명령입니다.

로그의 최대 항목 길이를 조정하여 로그가 차지하는 메모리 양을 제어하고 필요할 때 로그를 재설정하여 메모리를 확보할 수 있습니다.이는 유지 관리에 유용합니다.Redis 서버 성능과 보안은 관리자가 적시에 잠재적인 액세스 제어 문제를 감지하고 해결하는 데 도움이 되기 때문에 중요합니다.

2.17 acl파일

제외하고 sentinel.conf 파일에서 사용자를 구성하는 것 외에도 외부에서도 사용자를 구성할 수 있습니다.ACL 파일을 사용하는 경우 이 두 가지 방법을 혼합할 수 없습니다. 그렇지 않으면 서버가 시작을 거부합니다.

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

외부 ACL 파일 형식은 다음과 같습니다.redis.conf 파일에 사용된 형식은 완전히 동일합니다.

2.18 리퀘스트패스

구성 Sentinel 구성 후 비밀번호 자체를 확인해야 합니다.Sentine다른 모든 비밀번호와 동일한 비밀번호를 사용해 보겠습니다. Sentinel 인증합니다.

requirepass <password>
  • 1

그리고 aclfile 구성 및ACL LOAD 명령이 호환되지 않습니다.requirepass 무시당하다.

2.19 센티넬 센티넬 사용자、센티넬 센티넬 패스

구성 Sentinel 서로Sentinel 인증을 위한 사용자 이름과 비밀번호입니다.

sentinel sentinel-user <username>
sentinel sentinel-pass <password>
  • 1
  • 2

구성되지 않은 경우 sentinel-user , 사용할 것입니다default 사용자와sentinel-pass 인증합니다.

2.20 센티넬 병렬 동기

언제 제어 Redis Sentinel 마스터 노드 장애가 감지되고 장애 조치가 필요한 경우 동시에 새 마스터 노드와 동기화를 시도할 수 있는 슬레이브 노드 수입니다. 그 목적은 장애 조치 프로세스 중 네트워크 리소스 사용과 새 기본 노드 동기화 속도의 균형을 맞추는 것입니다.

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

장애 조치 프로세스 중에 선출된 새 마스터 노드는 쓰기 작업을 수락하기 시작하고 다른 슬레이브 노드는 데이터 세트를 업데이트하기 위해 새 마스터 노드와 동기화해야 합니다. 모든 슬레이브 노드가 동시에 동기화를 시작하면 네트워크와 새로운 마스터 노드에 큰 부하가 걸릴 수 있습니다.

2.21 센티넬 페일오버 시간 초과

장애 조치 시간 초과를 밀리초 단위로 지정합니다. 기본값은 3 분(예:180000 밀리초).

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

지정된 시간 내에 있는 경우,Sentinel 장애 조치에 필요한 모든 단계(예: 새 마스터 노드 선택, 슬레이브 노드의 복제 구성 업데이트 등)를 완료할 수 없는 경우 장애 조치 작업은 실패한 것으로 간주됩니다.

2.22 센티넬 알림 스크립트

사용자가 다음과 같은 경우 스크립트를 지정할 수 있습니다. Sentinel 노드는 몇 가지 중요한 이벤트(예:Redis 인스턴스가 주관적 실패 또는 객관적 실패 등을 경험하는 경우 이 스크립트가 자동으로 호출되어 시스템 관리자에게 알리거나 자동화된 오류 처리를 수행합니다.

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

누구에게나 WARNING 생성된 레벨Sentinel 이벤트(예:-sdown-odown 등), 지정된 알림 스크립트를 호출합니다.이 스크립트는 이메일, SMS 또는 모니터링되는 기타 메시징 시스템을 통해 시스템 관리자에게 알려야 합니다.Redis 시스템에 문제가 있습니다.

예:

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

위의 예는 다음과 같은 파일 이름을 보여줍니다. mymaster 메인 서버의 경우WARNING 레벨 이벤트,Sentinel 전화할 것이다/var/redis/notify.sh 스크립트를 실행하여 이벤트 유형과 이벤트 설명을 매개변수로 전달합니다.

알림 스크립트 및 기타 스크립트의 최대 실행 시간은 다음과 같습니다. 60 초 후에 이 제한에 도달하면 스크립트가 통과됩니다.SIGKILL 신호가 종료되고 다시 실행을 시도합니다. 스크립트 실행은 다음 오류 처리 규칙을 따릅니다.

  • 스크립트가 "1”를 종료하면 실행이 나중에 다시 시도됩니다(현재 최대 재시도 횟수는 다음으로 설정되어 있습니다).10이류).
  • 스크립트가 "2” (또는 그 이상)이면 스크립트 실행이 재시도되지 않습니다.
  • 신호 수신으로 인해 스크립트가 종료되면 해당 동작과 종료 코드는 다음과 같습니다.1같은 시간.

2.23 센티넬 클라이언트 재구성 스크립트

사용자가 스크립트를 지정할 수 있습니다. Sentinel 이 스크립트는 마스터 노드의 장애 조치가 완료된 후 자동으로 호출되어 클라이언트에 구성이 변경되었음을 알리는 데 필요한 작업을 수행할 수 있습니다.

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

이 스크립트의 주요 기능은 일반적으로 다음과 같습니다.

  • 새 마스터 노드에 연결할 수 있도록 클라이언트 구성을 업데이트합니다.
  • 이전 마스터 노드의 관련 구성이나 리소스를 삭제하는 등 일부 정리 작업을 수행합니다.
  • 장애 조치가 완료되었음을 시스템 관리자에게 알리기 위해 알림 또는 경고를 보냅니다.

언제 Sentine내가 전화해 sentinel client-reconfig-script 스크립트를 지정할 때 일련의 매개변수가 스크립트에 전달됩니다. 이러한 매개변수에는 일반적으로 다음을 포함한 장애 조치 결과 정보가 포함됩니다.

  • : 마스터 노드의 이름입니다.
  • : 새로운 마스터 노드의 역할입니다.
  • : 장애 조치의 상태 또는 결과입니다.
  • : 이전 마스터 노드의 IP 주소.
  • : 이전 마스터 노드의 포트 번호입니다.
  • : 새로운 마스터 노드의 IP 주소.
  • : 새 마스터 노드의 포트 번호입니다.

예:

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

위의 예는 이름이 mymaster Failover로 인해 Primary 서버가 변경되는 경우,Sentinel 전화할 것이다/var/redis/reconfig.sh 스크립트를 마스터 서버의 이름, 역할, 상태 및 원래 마스터 서버의 이름으로 전달합니다.IP 포트, 새로운 마스터 서버IP 및 포트 매개변수.

2.24 센티넬 거부 스크립트 재구성

통과 허용 여부를 제어하는 ​​데 사용됩니다. SENTINEL SET 명령 수정notification-script 그리고client-reconfig-script 구성.

sentinel deny-scripts-reconfig yes
  • 1

로 설정 yes (기본값), 추월이 금지됨을 나타냅니다.SENTINEL SET 스크립트 구성을 수정하는 명령은 시스템 보안을 강화하고 무단 수정을 방지하는 데 도움이 됩니다.

2.25 센티넬 거부 스크립트 재구성

명령 이름을 바꿉니다(더 이상 사용되지 않음).

SENTINEL rename-command mymaster CONFIG GUESSME
  • 1

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
  • 1

다음 사항을 확인해야 합니다. DNS 올바르게 구성되었으며DNS 구문 분석은 매우 긴 지연을 발생시키지 않습니다.다음과 같은 컨테이너화된 배포를 사용하는 경우Docker 또는Kubernetes), 그리고 Redis 사례IP 주소가 변경될 수 있습니다. 활성화SENTINEL resolve-hostnames 좋은 해결책이 될 수도 있습니다.

2.27 SENTINEL 발표 호스트 이름

Sentinel이 호스트 이름(hostnames) 대신에 IP 주소.

SENTINEL announce-hostnames no
  • 1

활성화된 경우 resolve-hostnames 시간,Sentinel 인스턴스를 사용자, 프로필 등에 노출할 때 계속 사용됩니다.IP 주소.이 옵션이 다음으로 설정되면no Sentinel은 마스터-슬레이브 노드 변경 알림 또는 기타 관련 정보를 게시할 때 다음을 사용합니다.IP 호스트 이름 대신 주소.

2.28 SENTINEL 마스터 재부팅 다운 기간 이후

다시 시작으로 인해 마스터 노드에 일시적으로 연결할 수 없는 것으로 간주하기 전에 센티널이 기다려야 하는 시간(밀리초)을 구성합니다. 이는 시스템 유지 관리 또는 업그레이드로 인해 다시 시작해야 하는 경우를 처리하는 데 유용합니다. Redis 이는 서버 시나리오에서 특히 유용합니다.

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

시스템 재부팅이나 일시적인 네트워크 문제 등 특정 상황에서는Redis 서버가 실제로 오작동하는 것이 아니라 일시적으로 접속할 수 없는 것일 수 있습니다.이 구성은 다음을 지정합니다.Sentinel 마스터 서버를 객관적으로 오프라인으로 표시하기 전에 기다려야 하는 시간입니다.