Partage de technologie

Série Redis 7.x [24] Éléments de configuration du mode Sentinelle

2024-07-12

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

S'il y a un moyen mais pas de technique, la technique peut toujours être recherchée ; s'il y a une technique mais pas de moyen, on s'arrêtera à la technique.

Redis version 7.2.5 de cette série

Adresse du code source : https://gitee.com/pearl-organization/study-redis-demo

1. Introduction

Dans le fichier de code source décompressé, vous pouvez voir le fichier de configuration 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. Éléments de configuration

2.1 mode protégé

Configurez s'il faut activer le mode protégé.

protected-mode no
  • 1

La valeur par défaut est no , d'autres adresses que l'hôte local sont également accessibles dans un environnement de production, elles doivent être protégées par un pare-feu ou d'autres moyens.Sentinel exemple, et interdire l’accès au réseau externe.

Port 2.2

Configurez le port en cours d'exécution du nœud sentinelle.

port 26379
  • 1

2.3 démoniser

Configurez s'il faut autoriser l'exécution en arrière-plan (en tant que processus démon), la valeur par défaut est no , le réglage recommandé estyes ,quandRedis Sentinel Lorsqu'il est exécuté en tant que démon, le/var/run/redis-sentinel.pidÉcrire unPIDdocument.

daemonize no
  • 1

2.4 fichier pid

Configuration Redis Sentinel Lors de l'exécution en tant que démon,PIDL'emplacement et le nom du fichier.

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

Niveau logarithmique 2,5

Configurez le niveau de journalisation.

loglevel notice
  • 1

Éléments configurables :

  • debug: Des tonnes d'informations, utiles pour le développement/les tests
  • verbose: Beaucoup d'informations rarement utiles, mais pas aussidebugLe niveau est tellement déroutant
  • notice: Verbosité moyenne, probablement ce que vous recherchez dans un environnement de production
  • warning : Enregistrer uniquement les messages très importants/critiques
  • nothing:Ne rien enregistrer

2.6 fichier journal

Configurez le nom du fichier journal.Utilisez une chaîne vide pour forcerSentinel Connectez-vous à la sortie standard.

logfile ""
  • 1

2.7 compatible avec syslog

Configurez s'il faut activer la journalisation du système.

# syslog-enabled no
  • 1

2.8 syslog-ident

Configurez l'identité du journal système.

# syslog-ident sentinel
  • 1

2.9 fonctionnalité syslog

Spécifiez le périphérique pour les journaux système.doit êtreUSER ouLOCAL0-LOCAL7 un entre les deux.

# syslog-facility local0
  • 1

2.10 Sentinel annonce-ip, Sentinel annonce-port

Précisez le courantSentinel NodalIP adresse et port, qui peuvent être utiles dans certaines configurations réseau ou scénarios de déploiement, par exemple lorsque le nœud esclave est localiséNAT Plus tard ou lorsque la technologie de conteneur/virtualisation est utilisée.

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

2.11 dir

Configurez le répertoire de travail, par exempleRedis SentinelPar exemple, passez à /tmp Les répertoires constituent le moyen le plus simple d'éviter d'interférer avec les tâches administratives telles que d'autres systèmes de fichiers.

dir /tmp
  • 1

2.12 moniteur sentinelle

est un élément de configuration clé utilisé pour définir un Sentinel surveilléRedis serveur maître, et seulement si au moins<quorum> individuelSentinel Ce n'est qu'avec le consentement qu'il est réputé être enO_DOWNStatut (Objectif hors ligne).

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

Description du paramètre :

  • <master-name>Redis Le nom spécifié par le nœud maître. Ce nom est dans.Sentinel Sera utilisé dans la configuration et la notification.
  • <ip> : du nœud maîtreIP adresse.
  • <redis-port> : Le port d'écoute du nœud maître.
  • <quorum>: Définition Sentinel Le nombre minimum de votes requis pour considérer un serveur maître indisponible (généralement recommandé est supérieur à la moitié du nombre de sentinelles).

Par exemple, vouloir Sentinel Surveiller un fichier nommé mymaster deRedis nœud maître, le serveurIP L'adresse est192.168.1.1, le port est 6379, et il doit y en avoir au moins deux Sentinel Ce n'est que lorsqu'il sera convenu que le serveur principal est indisponible qu'il sera marqué comme objectivement hors ligne. Configurez-le comme ceci :

sentinel monitor mymaster 127.0.0.1 6379 2
  • 1

Précautions:

  • Les serveurs esclaves sont automatiquement découverts, il n'est donc pas nécessaire de spécifier des nœuds esclaves de quelque manière que ce soit.Sentinel lui-même remplacera ce fichier de configuration pour inclure des nœuds esclaves en ajoutant des options de configuration supplémentaires.
  • Lorsqu'un nœud esclave est promu nœud maître, le fichier de configuration est également réécrit.
  • Le nom du nœud maître ne doit pas contenir de caractères spéciaux ni d'espaces.Les jeux de caractères valides sontA-z 0-9 et.-_
  • indépendamment de O_DOWN Le quorum doit être connuSentinel Le basculement ne peut pas commencer tant qu’une majorité n’est pas élue ; le basculement ne peut donc pas avoir lieu dans le cas d’une minorité.

2.13 Sentinel Auth-Pass, Sentinel Auth-User

Si vous souhaitez surveiller Redis L'instance a un mot de passe défini,sentinel auth-pass Définissez des mots de passe pour l'authentification avec les nœuds maître et esclave. Veuillez noter que le mot de passe du nœud maître est également utilisé pour les nœuds esclaves, les mots de passe des nœuds maître et esclave doivent donc être cohérents.Si aucune authentification n'est activéeRedis instance, exécutionAUTHLa commande n'a aucun effet.

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

Vous pouvez également configurer le nom d'utilisateur :

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

pour Sentinel Les instances fournissent un accès minimal et doivent être configurées comme suitACL

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

dans >somepassword le mot de passe configuré pour l'utilisateur,clientsubscribeAttendre l'exécution Sentinel Autorisations pour les commandes minimales requises pour la surveillance,onLe mot-clé indique que ces autorisations prendront effet sur toutes les bases de données.

2.14 Sentinelle en panne après quelques millisecondes

exister Sentinel Envoyer au nœud maître-esclavePING Après la commande, s'il n'y a pas de réponse dans un certain nombre de millisecondes, elle sera marquée commeS_DOWN Statut (subjectivement hors ligne).

Combien de millisecondes configurer

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

La valeur par défaut est 30 secondes, si vous ne pouvez pas répondre dans ce délai,SentinelIl sera ensuite évalué si un processus de basculement doit être déclenché.

2.15 utilisateur

depuis Redis 6.2 Démarrer, prise en charge du mode SentinelleACLliste de contrôle d'accès), vous pouvez configurer le nœud maître-esclave ACL Nom d'utilisateur et autorisations.

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

Description du paramètre dans l'exemple :

  • >ffa9203c493aa99 est le mot de passe de l'utilisateur
  • +@admin、+@connectionmoyens donnés à l'utilisateur worker Accès à certains jeux de commandes
  • ~* Représente l'accès à toutes les clés
  • on Indique que ces autorisations sont effectives sur toutes les bases de données

2.16 acllog-max-longueur

Configuration ACL La longueur maximale d’entrée du journal.

acllog-max-len 128
  • 1

ACL Suivi des journaux etACL (Liste de contrôle d'accès) commandes échouées et événements d'authentification liés.Pour l'enquêteACL Les commandes bloquées qui ont échoué sont très utiles.ACL Les journaux sont stockés en mémoire et peuvent être utilisésACL LOG RESET commande pour récupérer la mémoire.

En ajustant la longueur maximale d'entrée du journal, vous pouvez contrôler la quantité de mémoire occupée par le journal et libérer de la mémoire en réinitialisant le journal si nécessaire.Ceci est utile pour maintenirRedis Les performances et la sécurité du serveur sont importantes car elles aident les administrateurs à détecter et à résoudre rapidement les problèmes potentiels de contrôle d'accès.

2.17 fichier acl

sauf dans sentinel.conf En plus de configurer des utilisateurs dans des fichiers, vous pouvez configurer un utilisateur en externeACL fichier, ces deux méthodes ne peuvent pas être mélangées sinon le serveur refusera de démarrer.

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

externe ACL Le format du fichier estredis.conf Le format utilisé dans le fichier est exactement le même.

2.18 exiger un laissez-passer

Configuration Sentinel Le mot de passe lui-même doit être vérifié après la configurationSentineJe vais essayer d'utiliser le même mot de passe que tous les autres Sentinel Authentifier.

requirepass <password>
  • 1

et aclfile configuration etACL LOAD Les commandes sont incompatibles, elles provoquentrequirepass Etre ignoré.

2.19 sentinelle sentinelle-utilisateur, sentinelle sentinelle-pass

Configuration Sentinel avec d'autreSentinel Nom d'utilisateur et mot de passe pour l'authentification.

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

s'il n'est pas configuré sentinel-user , utiliseradefault les utilisateurs etsentinel-pass Authentifier.

2.20 synchronisations parallèles sentinelles

contrôler quand Redis Sentinel Lorsqu'une panne de nœud maître est détectée et qu'un basculement est requis, combien de nœuds esclaves sont autorisés à essayer de se synchroniser avec le nouveau nœud maître en même temps. L'objectif est d'équilibrer la vitesse de synchronisation du nouveau nœud principal avec l'utilisation des ressources réseau pendant le processus de basculement.

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

Pendant le processus de basculement, le nouveau nœud maître élu commencera à accepter les opérations d'écriture et les autres nœuds esclaves devront se synchroniser avec le nouveau nœud maître pour mettre à jour leurs ensembles de données. Si tous les nœuds esclaves commencent à se synchroniser en même temps, cela peut imposer une charge importante au réseau et au nouveau nœud maître.

2.21 Délai d'expiration du basculement de sentinelle

Spécifie le délai d'expiration du basculement en millisecondes. La valeur par défaut est 3 minutes (c'est-à-dire180000 milliseconde).

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

Si dans le délai spécifié,Sentinel Si toutes les étapes nécessaires au basculement ne peuvent pas être effectuées (telles que l'élection d'un nouveau nœud maître, la mise à jour de la configuration de réplication du nœud esclave, etc.), l'opération de basculement sera considérée comme ayant échoué.

2.22 script de notification sentinelle

Permet à l'utilisateur de spécifier un script lorsque Sentinel Le nœud détecte un événement important (par ex.Redis Lorsqu'une instance subit un échec subjectif ou objectif, etc.), ce script sera automatiquement appelé pour avertir l'administrateur système ou effectuer une gestion automatisée des erreurs.

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

pour n'importe qui dans WARNING niveau généréSentinel événement (par exemple,-sdown-odown etc.), appelez le script de notification spécifié.Ce script doit informer l'administrateur système par e-mail, SMS ou tout autre système de messagerie que le système surveilléRedis Il y a un problème avec le système.

Exemple:

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

L'exemple ci-dessus montre que pour un fichier nommé mymaster du serveur principal, lorsqueWARNING événement de niveau,Sentinel appellera/var/redis/notify.sh script, en lui passant le type d'événement et la description de l'événement comme paramètres.

La durée d'exécution maximale des scripts de notification et autres scripts est 60 secondes, une fois cette limite atteinte, le script passeraSIGKILL Le signal se termine et tente de s'exécuter à nouveau. L'exécution du script suit les règles de gestion des erreurs suivantes :

  • Si le script se termine par "1" pour quitter, l'exécution sera retentée plus tard (le nombre maximum de tentatives est actuellement fixé à10de second ordre).
  • Si le script se termine par "2" (ou supérieur), l'exécution du script ne sera pas réessayée.
  • Si le script se termine suite à la réception d'un signal, son comportement et son code de sortie sont1En même temps.

2.23 script de reconfiguration du client sentinelle

Permet à l'utilisateur de spécifier un script, dans Sentinel Ce script est automatiquement appelé une fois le basculement d'un nœud maître terminé. Ce script peut effectuer les opérations nécessaires pour informer les clients que la configuration a changé.

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

Les principales fonctions de ce script incluent généralement :

  • Mettez à jour la configuration du client afin qu'il puisse se connecter au nouveau nœud maître.
  • Effectuez des travaux de nettoyage, tels que la suppression des configurations ou des ressources associées de l'ancien nœud maître.
  • Envoie une notification ou une alerte pour informer l'administrateur système que le basculement est terminé.

quand SentineJ'appelle sentinel client-reconfig-script Lors de la spécification d'un script, une série de paramètres sont transmis au script. Ces paramètres contiennent des informations sur les résultats du basculement, comprenant généralement :

  • : Le nom du nœud maître.
  • : Le rôle du nouveau nœud maître.
  •  : l'état ou le résultat du basculement.
  • : de l'ancien nœud maître IP adresse.
  • : Le numéro de port de l'ancien nœud maître.
  • : du nouveau nœud maître IP adresse.
  • : Le numéro de port du nouveau nœud maître.

Exemple:

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

L'exemple ci-dessus montre que lorsque le nom est mymaster Lorsque le serveur principal de est modifié en raison d'un basculement,Sentinel appellera/var/redis/reconfig.sh script, en lui transmettant le nom, le rôle, le statut du serveur maître ainsi que le nom du serveur maître d'origine.IP et port, nouveau serveur maîtreIP et les paramètres du port.

2.24 scripts de refus de sentinelle-reconfiguration

Utilisé pour contrôler s'il faut autoriser le passage SENTINEL SET Modification de commandenotification-script etclient-reconfig-script configuration.

sentinel deny-scripts-reconfig yes
  • 1

Définir comme yes (par défaut), indiquant que le dépassement est interditSENTINEL SET Les commandes permettant de modifier les configurations de script contribuent à accroître la sécurité du système et à empêcher les modifications non autorisées.

2.25 scripts de refus de sentinelle-reconfiguration

Renommez la commande (obsolète).

SENTINEL rename-command mymaster CONFIG GUESSME
  • 1

2.26 SENTINEL résout les noms d'hôtes

généralement Sentinel Utilisez uniquement des adresses IP et exigezSENTINEL MONITOR préciser unIP adresse.De plus, cela nécessiteRedis dereplica-announce-ip Préciser seulementIP adresse.

Peut être activé par resolve-hostnames pour prendre en charge les noms d'hôtes (hostname), Sentinel va essayer de résoudre le nom d'hôte au lieu de l'utiliser directementIP adresse à identifierRedis Exemple.

SENTINEL resolve-hostnames no
  • 1

Notez que vous devez vous assurer que votre DNS configuré correctement, etDNS L'analyse n'introduit pas de très longs délais.Lors de l'utilisation de déploiements conteneurisés tels queDocker ouKubernetes), et Redis exempleIP L'adresse peut changer, activerSENTINEL resolve-hostnames Cela pourrait être une bonne solution.

2.27 Annonce des noms d'hôtes SENTINEL

Utilisé pour contrôler si Sentinel utilise le nom d'hôte (hostnames) au lieu de IP adresse.

SENTINEL announce-hostnames no
  • 1

Lorsqu'il est activé resolve-hostnames heure,Sentinel Toujours utilisé lors de l'exposition d'instances à des utilisateurs, des profils, etc.IP adresse.Lorsque cette option est définie surno Lorsque Sentinel publie une notification de changement de nœud maître-esclave ou d'autres informations connexes, il utiliseIP adresse au lieu du nom d'hôte.

2.28 SENTINEL master-reboot-down-après-période

Configurez le nombre de millisecondes pendant lesquelles la sentinelle doit attendre avant de considérer que le nœud maître est temporairement inaccessible en raison d'un redémarrage. Ceci est utile pour gérer le besoin de redémarrage en raison de la maintenance ou des mises à niveau du système. Redis Ceci est particulièrement utile dans les scénarios de serveur.

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

Dans certaines situations, telles que des redémarrages du système ou de brefs problèmes de réseau,Redis Le serveur peut être temporairement inaccessible plutôt que de fonctionner correctement.Cette configuration spécifieSentinel Le temps qu'il faut attendre avant de marquer le serveur maître comme objectivement hors ligne.