xref: /f-stack/app/redis-5.0.5/sentinel.conf (revision 572c4311)
1# Example sentinel.conf
2
3# *** IMPORTANT ***
4#
5# By default Sentinel will not be reachable from interfaces different than
6# localhost, either use the 'bind' directive to bind to a list of network
7# interfaces, or disable protected mode with "protected-mode no" by
8# adding it to this configuration file.
9#
10# Before doing that MAKE SURE the instance is protected from the outside
11# world via firewalling or other means.
12#
13# For example you may use one of the following:
14#
15# bind 127.0.0.1 192.168.1.1
16#
17# protected-mode no
18
19# port <sentinel-port>
20# The port that this sentinel instance will run on
21port 26379
22
23# By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
24# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
25# daemonized.
26daemonize no
27
28# When running daemonized, Redis Sentinel writes a pid file in
29# /var/run/redis-sentinel.pid by default. You can specify a custom pid file
30# location here.
31pidfile /var/run/redis-sentinel.pid
32
33# Specify the log file name. Also the empty string can be used to force
34# Sentinel to log on the standard output. Note that if you use standard
35# output for logging but daemonize, logs will be sent to /dev/null
36logfile ""
37
38# sentinel announce-ip <ip>
39# sentinel announce-port <port>
40#
41# The above two configuration directives are useful in environments where,
42# because of NAT, Sentinel is reachable from outside via a non-local address.
43#
44# When announce-ip is provided, the Sentinel will claim the specified IP address
45# in HELLO messages used to gossip its presence, instead of auto-detecting the
46# local address as it usually does.
47#
48# Similarly when announce-port is provided and is valid and non-zero, Sentinel
49# will announce the specified TCP port.
50#
51# The two options don't need to be used together, if only announce-ip is
52# provided, the Sentinel will announce the specified IP and the server port
53# as specified by the "port" option. If only announce-port is provided, the
54# Sentinel will announce the auto-detected local IP and the specified port.
55#
56# Example:
57#
58# sentinel announce-ip 1.2.3.4
59
60# dir <working-directory>
61# Every long running process should have a well-defined working directory.
62# For Redis Sentinel to chdir to /tmp at startup is the simplest thing
63# for the process to don't interfere with administrative tasks such as
64# unmounting filesystems.
65dir /tmp
66
67# sentinel monitor <master-name> <ip> <redis-port> <quorum>
68#
69# Tells Sentinel to monitor this master, and to consider it in O_DOWN
70# (Objectively Down) state only if at least <quorum> sentinels agree.
71#
72# Note that whatever is the ODOWN quorum, a Sentinel will require to
73# be elected by the majority of the known Sentinels in order to
74# start a failover, so no failover can be performed in minority.
75#
76# Replicas are auto-discovered, so you don't need to specify replicas in
77# any way. Sentinel itself will rewrite this configuration file adding
78# the replicas using additional configuration options.
79# Also note that the configuration file is rewritten when a
80# replica is promoted to master.
81#
82# Note: master name should not include special characters or spaces.
83# The valid charset is A-z 0-9 and the three characters ".-_".
84sentinel monitor mymaster 127.0.0.1 6379 2
85
86# sentinel auth-pass <master-name> <password>
87#
88# Set the password to use to authenticate with the master and replicas.
89# Useful if there is a password set in the Redis instances to monitor.
90#
91# Note that the master password is also used for replicas, so it is not
92# possible to set a different password in masters and replicas instances
93# if you want to be able to monitor these instances with Sentinel.
94#
95# However you can have Redis instances without the authentication enabled
96# mixed with Redis instances requiring the authentication (as long as the
97# password set is the same for all the instances requiring the password) as
98# the AUTH command will have no effect in Redis instances with authentication
99# switched off.
100#
101# Example:
102#
103# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd
104
105# sentinel down-after-milliseconds <master-name> <milliseconds>
106#
107# Number of milliseconds the master (or any attached replica or sentinel) should
108# be unreachable (as in, not acceptable reply to PING, continuously, for the
109# specified period) in order to consider it in S_DOWN state (Subjectively
110# Down).
111#
112# Default is 30 seconds.
113sentinel down-after-milliseconds mymaster 30000
114
115# sentinel parallel-syncs <master-name> <numreplicas>
116#
117# How many replicas we can reconfigure to point to the new replica simultaneously
118# during the failover. Use a low number if you use the replicas to serve query
119# to avoid that all the replicas will be unreachable at about the same
120# time while performing the synchronization with the master.
121sentinel parallel-syncs mymaster 1
122
123# sentinel failover-timeout <master-name> <milliseconds>
124#
125# Specifies the failover timeout in milliseconds. It is used in many ways:
126#
127# - The time needed to re-start a failover after a previous failover was
128#   already tried against the same master by a given Sentinel, is two
129#   times the failover timeout.
130#
131# - The time needed for a replica replicating to a wrong master according
132#   to a Sentinel current configuration, to be forced to replicate
133#   with the right master, is exactly the failover timeout (counting since
134#   the moment a Sentinel detected the misconfiguration).
135#
136# - The time needed to cancel a failover that is already in progress but
137#   did not produced any configuration change (SLAVEOF NO ONE yet not
138#   acknowledged by the promoted replica).
139#
140# - The maximum time a failover in progress waits for all the replicas to be
141#   reconfigured as replicas of the new master. However even after this time
142#   the replicas will be reconfigured by the Sentinels anyway, but not with
143#   the exact parallel-syncs progression as specified.
144#
145# Default is 3 minutes.
146sentinel failover-timeout mymaster 180000
147
148# SCRIPTS EXECUTION
149#
150# sentinel notification-script and sentinel reconfig-script are used in order
151# to configure scripts that are called to notify the system administrator
152# or to reconfigure clients after a failover. The scripts are executed
153# with the following rules for error handling:
154#
155# If script exits with "1" the execution is retried later (up to a maximum
156# number of times currently set to 10).
157#
158# If script exits with "2" (or an higher value) the script execution is
159# not retried.
160#
161# If script terminates because it receives a signal the behavior is the same
162# as exit code 1.
163#
164# A script has a maximum running time of 60 seconds. After this limit is
165# reached the script is terminated with a SIGKILL and the execution retried.
166
167# NOTIFICATION SCRIPT
168#
169# sentinel notification-script <master-name> <script-path>
170#
171# Call the specified notification script for any sentinel event that is
172# generated in the WARNING level (for instance -sdown, -odown, and so forth).
173# This script should notify the system administrator via email, SMS, or any
174# other messaging system, that there is something wrong with the monitored
175# Redis systems.
176#
177# The script is called with just two arguments: the first is the event type
178# and the second the event description.
179#
180# The script must exist and be executable in order for sentinel to start if
181# this option is provided.
182#
183# Example:
184#
185# sentinel notification-script mymaster /var/redis/notify.sh
186
187# CLIENTS RECONFIGURATION SCRIPT
188#
189# sentinel client-reconfig-script <master-name> <script-path>
190#
191# When the master changed because of a failover a script can be called in
192# order to perform application-specific tasks to notify the clients that the
193# configuration has changed and the master is at a different address.
194#
195# The following arguments are passed to the script:
196#
197# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
198#
199# <state> is currently always "failover"
200# <role> is either "leader" or "observer"
201#
202# The arguments from-ip, from-port, to-ip, to-port are used to communicate
203# the old address of the master and the new address of the elected replica
204# (now a master).
205#
206# This script should be resistant to multiple invocations.
207#
208# Example:
209#
210# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
211
212# SECURITY
213#
214# By default SENTINEL SET will not be able to change the notification-script
215# and client-reconfig-script at runtime. This avoids a trivial security issue
216# where clients can set the script to anything and trigger a failover in order
217# to get the program executed.
218
219sentinel deny-scripts-reconfig yes
220
221# REDIS COMMANDS RENAMING
222#
223# Sometimes the Redis server has certain commands, that are needed for Sentinel
224# to work correctly, renamed to unguessable strings. This is often the case
225# of CONFIG and SLAVEOF in the context of providers that provide Redis as
226# a service, and don't want the customers to reconfigure the instances outside
227# of the administration console.
228#
229# In such case it is possible to tell Sentinel to use different command names
230# instead of the normal ones. For example if the master "mymaster", and the
231# associated replicas, have "CONFIG" all renamed to "GUESSME", I could use:
232#
233# SENTINEL rename-command mymaster CONFIG GUESSME
234#
235# After such configuration is set, every time Sentinel would use CONFIG it will
236# use GUESSME instead. Note that there is no actual need to respect the command
237# case, so writing "config guessme" is the same in the example above.
238#
239# SENTINEL SET can also be used in order to perform this configuration at runtime.
240#
241# In order to set a command back to its original name (undo the renaming), it
242# is possible to just rename a command to itsef:
243#
244# SENTINEL rename-command mymaster CONFIG CONFIG
245