sentinel.conf 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. # requirepass <password>
  116. #
  117. # You can configure Sentinel itself to require a password, however when doing
  118. # so Sentinel will try to authenticate with the same password to all the
  119. # other Sentinels. So you need to configure all your Sentinels in a given
  120. # group with the same "requirepass" password. Check the following documentation
  121. # for more info: https://redis.io/topics/sentinel
  122. # sentinel parallel-syncs <master-name> <numreplicas>
  123. #
  124. # How many replicas we can reconfigure to point to the new replica simultaneously
  125. # during the failover. Use a low number if you use the replicas to serve query
  126. # to avoid that all the replicas will be unreachable at about the same
  127. # time while performing the synchronization with the master.
  128. sentinel parallel-syncs mymaster 1
  129. # sentinel failover-timeout <master-name> <milliseconds>
  130. #
  131. # Specifies the failover timeout in milliseconds. It is used in many ways:
  132. #
  133. # - The time needed to re-start a failover after a previous failover was
  134. # already tried against the same master by a given Sentinel, is two
  135. # times the failover timeout.
  136. #
  137. # - The time needed for a replica replicating to a wrong master according
  138. # to a Sentinel current configuration, to be forced to replicate
  139. # with the right master, is exactly the failover timeout (counting since
  140. # the moment a Sentinel detected the misconfiguration).
  141. #
  142. # - The time needed to cancel a failover that is already in progress but
  143. # did not produced any configuration change (SLAVEOF NO ONE yet not
  144. # acknowledged by the promoted replica).
  145. #
  146. # - The maximum time a failover in progress waits for all the replicas to be
  147. # reconfigured as replicas of the new master. However even after this time
  148. # the replicas will be reconfigured by the Sentinels anyway, but not with
  149. # the exact parallel-syncs progression as specified.
  150. #
  151. # Default is 3 minutes.
  152. sentinel failover-timeout mymaster 180000
  153. # SCRIPTS EXECUTION
  154. #
  155. # sentinel notification-script and sentinel reconfig-script are used in order
  156. # to configure scripts that are called to notify the system administrator
  157. # or to reconfigure clients after a failover. The scripts are executed
  158. # with the following rules for error handling:
  159. #
  160. # If script exits with "1" the execution is retried later (up to a maximum
  161. # number of times currently set to 10).
  162. #
  163. # If script exits with "2" (or an higher value) the script execution is
  164. # not retried.
  165. #
  166. # If script terminates because it receives a signal the behavior is the same
  167. # as exit code 1.
  168. #
  169. # A script has a maximum running time of 60 seconds. After this limit is
  170. # reached the script is terminated with a SIGKILL and the execution retried.
  171. # NOTIFICATION SCRIPT
  172. #
  173. # sentinel notification-script <master-name> <script-path>
  174. #
  175. # Call the specified notification script for any sentinel event that is
  176. # generated in the WARNING level (for instance -sdown, -odown, and so forth).
  177. # This script should notify the system administrator via email, SMS, or any
  178. # other messaging system, that there is something wrong with the monitored
  179. # Redis systems.
  180. #
  181. # The script is called with just two arguments: the first is the event type
  182. # and the second the event description.
  183. #
  184. # The script must exist and be executable in order for sentinel to start if
  185. # this option is provided.
  186. #
  187. # Example:
  188. #
  189. # sentinel notification-script mymaster /var/redis/notify.sh
  190. # CLIENTS RECONFIGURATION SCRIPT
  191. #
  192. # sentinel client-reconfig-script <master-name> <script-path>
  193. #
  194. # When the master changed because of a failover a script can be called in
  195. # order to perform application-specific tasks to notify the clients that the
  196. # configuration has changed and the master is at a different address.
  197. #
  198. # The following arguments are passed to the script:
  199. #
  200. # <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
  201. #
  202. # <state> is currently always "failover"
  203. # <role> is either "leader" or "observer"
  204. #
  205. # The arguments from-ip, from-port, to-ip, to-port are used to communicate
  206. # the old address of the master and the new address of the elected replica
  207. # (now a master).
  208. #
  209. # This script should be resistant to multiple invocations.
  210. #
  211. # Example:
  212. #
  213. # sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
  214. # SECURITY
  215. #
  216. # By default SENTINEL SET will not be able to change the notification-script
  217. # and client-reconfig-script at runtime. This avoids a trivial security issue
  218. # where clients can set the script to anything and trigger a failover in order
  219. # to get the program executed.
  220. sentinel deny-scripts-reconfig yes
  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 itself:
  243. #
  244. # SENTINEL rename-command mymaster CONFIG CONFIG