2
0

sentinel.conf 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. # Example sentinel.conf
  2. # *** IMPORTANT ***
  3. #
  4. # By default Sentinel will not be reachable from interfaces different than
  5. # localhost, either use the 'bind' directive to bind to a list of network
  6. # interfaces, or disable protected mode with "protected-mode no" by
  7. # adding it to this configuration file.
  8. #
  9. # Before doing that MAKE SURE the instance is protected from the outside
  10. # world via firewalling or other means.
  11. #
  12. # For example you may use one of the following:
  13. #
  14. # bind 127.0.0.1 192.168.1.1
  15. #
  16. # protected-mode no
  17. # port <sentinel-port>
  18. # The port that this sentinel instance will run on
  19. port 26379
  20. # By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
  21. # Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
  22. # daemonized.
  23. daemonize no
  24. # When running daemonized, Redis Sentinel writes a pid file in
  25. # /var/run/redis-sentinel.pid by default. You can specify a custom pid file
  26. # location here.
  27. pidfile /var/run/redis-sentinel.pid
  28. # Specify the log file name. Also the empty string can be used to force
  29. # Sentinel to log on the standard output. Note that if you use standard
  30. # output for logging but daemonize, logs will be sent to /dev/null
  31. logfile ""
  32. # sentinel announce-ip <ip>
  33. # sentinel announce-port <port>
  34. #
  35. # The above two configuration directives are useful in environments where,
  36. # because of NAT, Sentinel is reachable from outside via a non-local address.
  37. #
  38. # When announce-ip is provided, the Sentinel will claim the specified IP address
  39. # in HELLO messages used to gossip its presence, instead of auto-detecting the
  40. # local address as it usually does.
  41. #
  42. # Similarly when announce-port is provided and is valid and non-zero, Sentinel
  43. # will announce the specified TCP port.
  44. #
  45. # The two options don't need to be used together, if only announce-ip is
  46. # provided, the Sentinel will announce the specified IP and the server port
  47. # as specified by the "port" option. If only announce-port is provided, the
  48. # Sentinel will announce the auto-detected local IP and the specified port.
  49. #
  50. # Example:
  51. #
  52. # sentinel announce-ip 1.2.3.4
  53. # dir <working-directory>
  54. # Every long running process should have a well-defined working directory.
  55. # For Redis Sentinel to chdir to /tmp at startup is the simplest thing
  56. # for the process to don't interfere with administrative tasks such as
  57. # unmounting filesystems.
  58. dir /tmp
  59. # sentinel monitor <master-name> <ip> <redis-port> <quorum>
  60. #
  61. # Tells Sentinel to monitor this master, and to consider it in O_DOWN
  62. # (Objectively Down) state only if at least <quorum> sentinels agree.
  63. #
  64. # Note that whatever is the ODOWN quorum, a Sentinel will require to
  65. # be elected by the majority of the known Sentinels in order to
  66. # start a failover, so no failover can be performed in minority.
  67. #
  68. # Replicas are auto-discovered, so you don't need to specify replicas in
  69. # any way. Sentinel itself will rewrite this configuration file adding
  70. # the replicas using additional configuration options.
  71. # Also note that the configuration file is rewritten when a
  72. # replica is promoted to master.
  73. #
  74. # Note: master name should not include special characters or spaces.
  75. # The valid charset is A-z 0-9 and the three characters ".-_".
  76. sentinel monitor mymaster 127.0.0.1 6379 2
  77. # sentinel auth-pass <master-name> <password>
  78. #
  79. # Set the password to use to authenticate with the master and replicas.
  80. # Useful if there is a password set in the Redis instances to monitor.
  81. #
  82. # Note that the master password is also used for replicas, so it is not
  83. # possible to set a different password in masters and replicas instances
  84. # if you want to be able to monitor these instances with Sentinel.
  85. #
  86. # However you can have Redis instances without the authentication enabled
  87. # mixed with Redis instances requiring the authentication (as long as the
  88. # password set is the same for all the instances requiring the password) as
  89. # the AUTH command will have no effect in Redis instances with authentication
  90. # switched off.
  91. #
  92. # Example:
  93. #
  94. # sentinel auth-pass mymaster MySUPER--secret-0123passw0rd
  95. # sentinel auth-user <master-name> <username>
  96. #
  97. # This is useful in order to authenticate to instances having ACL capabilities,
  98. # that is, running Redis 6.0 or greater. When just auth-pass is provided the
  99. # Sentinel instance will authenticate to Redis using the old "AUTH <pass>"
  100. # method. When also an username is provided, it will use "AUTH <user> <pass>".
  101. # In the Redis servers side, the ACL to provide just minimal access to
  102. # Sentinel instances, should be configured along the following lines:
  103. #
  104. # user sentinel-user >somepassword +client +subscribe +publish \
  105. # +ping +info +multi +slaveof +config +client +exec on
  106. # sentinel down-after-milliseconds <master-name> <milliseconds>
  107. #
  108. # Number of milliseconds the master (or any attached replica or sentinel) should
  109. # be unreachable (as in, not acceptable reply to PING, continuously, for the
  110. # specified period) in order to consider it in S_DOWN state (Subjectively
  111. # Down).
  112. #
  113. # Default is 30 seconds.
  114. sentinel down-after-milliseconds mymaster 30000
  115. # IMPORTANT NOTE: starting with Redis 6.2 ACL capability is supported for
  116. # Sentinel mode, please refer to the Redis website https://redis.io/topics/acl
  117. # for more details.
  118. # Sentinel's ACL users are defined in the following format:
  119. #
  120. # user <username> ... acl rules ...
  121. #
  122. # For example:
  123. #
  124. # user worker +@admin +@connection ~* on >ffa9203c493aa99
  125. #
  126. # For more information about ACL configuration please refer to the Redis
  127. # website at https://redis.io/topics/acl and redis server configuration
  128. # template redis.conf.
  129. # ACL LOG
  130. #
  131. # The ACL Log tracks failed commands and authentication events associated
  132. # with ACLs. The ACL Log is useful to troubleshoot failed commands blocked
  133. # by ACLs. The ACL Log is stored in memory. You can reclaim memory with
  134. # ACL LOG RESET. Define the maximum entry length of the ACL Log below.
  135. acllog-max-len 128
  136. # Using an external ACL file
  137. #
  138. # Instead of configuring users here in this file, it is possible to use
  139. # a stand-alone file just listing users. The two methods cannot be mixed:
  140. # if you configure users here and at the same time you activate the external
  141. # ACL file, the server will refuse to start.
  142. #
  143. # The format of the external ACL user file is exactly the same as the
  144. # format that is used inside redis.conf to describe users.
  145. #
  146. # aclfile /etc/redis/sentinel-users.acl
  147. # requirepass <password>
  148. #
  149. # You can configure Sentinel itself to require a password, however when doing
  150. # so Sentinel will try to authenticate with the same password to all the
  151. # other Sentinels. So you need to configure all your Sentinels in a given
  152. # group with the same "requirepass" password. Check the following documentation
  153. # for more info: https://redis.io/topics/sentinel
  154. #
  155. # IMPORTANT NOTE: starting with Redis 6.2 "requirepass" is a compatibility
  156. # layer on top of the ACL system. The option effect will be just setting
  157. # the password for the default user. Clients will still authenticate using
  158. # AUTH <password> as usually, or more explicitly with AUTH default <password>
  159. # if they follow the new protocol: both will work.
  160. #
  161. # New config files are advised to use separate authentication control for
  162. # incoming connections (via ACL), and for outgoing connections (via
  163. # sentinel-user and sentinel-pass)
  164. #
  165. # The requirepass is not compatible with aclfile option and the ACL LOAD
  166. # command, these will cause requirepass to be ignored.
  167. # sentinel sentinel-user <username>
  168. #
  169. # You can configure Sentinel to authenticate with other Sentinels with specific
  170. # user name.
  171. # sentinel sentinel-pass <password>
  172. #
  173. # The password for Sentinel to authenticate with other Sentinels. If sentinel-user
  174. # is not configured, Sentinel will use 'default' user with sentinel-pass to authenticate.
  175. # sentinel parallel-syncs <master-name> <numreplicas>
  176. #
  177. # How many replicas we can reconfigure to point to the new replica simultaneously
  178. # during the failover. Use a low number if you use the replicas to serve query
  179. # to avoid that all the replicas will be unreachable at about the same
  180. # time while performing the synchronization with the master.
  181. sentinel parallel-syncs mymaster 1
  182. # sentinel failover-timeout <master-name> <milliseconds>
  183. #
  184. # Specifies the failover timeout in milliseconds. It is used in many ways:
  185. #
  186. # - The time needed to re-start a failover after a previous failover was
  187. # already tried against the same master by a given Sentinel, is two
  188. # times the failover timeout.
  189. #
  190. # - The time needed for a replica replicating to a wrong master according
  191. # to a Sentinel current configuration, to be forced to replicate
  192. # with the right master, is exactly the failover timeout (counting since
  193. # the moment a Sentinel detected the misconfiguration).
  194. #
  195. # - The time needed to cancel a failover that is already in progress but
  196. # did not produced any configuration change (SLAVEOF NO ONE yet not
  197. # acknowledged by the promoted replica).
  198. #
  199. # - The maximum time a failover in progress waits for all the replicas to be
  200. # reconfigured as replicas of the new master. However even after this time
  201. # the replicas will be reconfigured by the Sentinels anyway, but not with
  202. # the exact parallel-syncs progression as specified.
  203. #
  204. # Default is 3 minutes.
  205. sentinel failover-timeout mymaster 180000
  206. # SCRIPTS EXECUTION
  207. #
  208. # sentinel notification-script and sentinel reconfig-script are used in order
  209. # to configure scripts that are called to notify the system administrator
  210. # or to reconfigure clients after a failover. The scripts are executed
  211. # with the following rules for error handling:
  212. #
  213. # If script exits with "1" the execution is retried later (up to a maximum
  214. # number of times currently set to 10).
  215. #
  216. # If script exits with "2" (or an higher value) the script execution is
  217. # not retried.
  218. #
  219. # If script terminates because it receives a signal the behavior is the same
  220. # as exit code 1.
  221. #
  222. # A script has a maximum running time of 60 seconds. After this limit is
  223. # reached the script is terminated with a SIGKILL and the execution retried.
  224. # NOTIFICATION SCRIPT
  225. #
  226. # sentinel notification-script <master-name> <script-path>
  227. #
  228. # Call the specified notification script for any sentinel event that is
  229. # generated in the WARNING level (for instance -sdown, -odown, and so forth).
  230. # This script should notify the system administrator via email, SMS, or any
  231. # other messaging system, that there is something wrong with the monitored
  232. # Redis systems.
  233. #
  234. # The script is called with just two arguments: the first is the event type
  235. # and the second the event description.
  236. #
  237. # The script must exist and be executable in order for sentinel to start if
  238. # this option is provided.
  239. #
  240. # Example:
  241. #
  242. # sentinel notification-script mymaster /var/redis/notify.sh
  243. # CLIENTS RECONFIGURATION SCRIPT
  244. #
  245. # sentinel client-reconfig-script <master-name> <script-path>
  246. #
  247. # When the master changed because of a failover a script can be called in
  248. # order to perform application-specific tasks to notify the clients that the
  249. # configuration has changed and the master is at a different address.
  250. #
  251. # The following arguments are passed to the script:
  252. #
  253. # <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
  254. #
  255. # <state> is currently always "start"
  256. # <role> is either "leader" or "observer"
  257. #
  258. # The arguments from-ip, from-port, to-ip, to-port are used to communicate
  259. # the old address of the master and the new address of the elected replica
  260. # (now a master).
  261. #
  262. # This script should be resistant to multiple invocations.
  263. #
  264. # Example:
  265. #
  266. # sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
  267. # SECURITY
  268. #
  269. # By default SENTINEL SET will not be able to change the notification-script
  270. # and client-reconfig-script at runtime. This avoids a trivial security issue
  271. # where clients can set the script to anything and trigger a failover in order
  272. # to get the program executed.
  273. sentinel deny-scripts-reconfig yes
  274. # REDIS COMMANDS RENAMING
  275. #
  276. # Sometimes the Redis server has certain commands, that are needed for Sentinel
  277. # to work correctly, renamed to unguessable strings. This is often the case
  278. # of CONFIG and SLAVEOF in the context of providers that provide Redis as
  279. # a service, and don't want the customers to reconfigure the instances outside
  280. # of the administration console.
  281. #
  282. # In such case it is possible to tell Sentinel to use different command names
  283. # instead of the normal ones. For example if the master "mymaster", and the
  284. # associated replicas, have "CONFIG" all renamed to "GUESSME", I could use:
  285. #
  286. # SENTINEL rename-command mymaster CONFIG GUESSME
  287. #
  288. # After such configuration is set, every time Sentinel would use CONFIG it will
  289. # use GUESSME instead. Note that there is no actual need to respect the command
  290. # case, so writing "config guessme" is the same in the example above.
  291. #
  292. # SENTINEL SET can also be used in order to perform this configuration at runtime.
  293. #
  294. # In order to set a command back to its original name (undo the renaming), it
  295. # is possible to just rename a command to itself:
  296. #
  297. # SENTINEL rename-command mymaster CONFIG CONFIG
  298. # HOSTNAMES SUPPORT
  299. #
  300. # Normally Sentinel uses only IP addresses and requires SENTINEL MONITOR
  301. # to specify an IP address. Also, it requires the Redis replica-announce-ip
  302. # keyword to specify only IP addresses.
  303. #
  304. # You may enable hostnames support by enabling resolve-hostnames. Note
  305. # that you must make sure your DNS is configured properly and that DNS
  306. # resolution does not introduce very long delays.
  307. #
  308. SENTINEL resolve-hostnames no
  309. # When resolve-hostnames is enabled, Sentinel still uses IP addresses
  310. # when exposing instances to users, configuration files, etc. If you want
  311. # to retain the hostnames when announced, enable announce-hostnames below.
  312. #
  313. SENTINEL announce-hostnames no