1be2be3d9Santirez# Example sentinel.conf 26b5daa2dSantirez 323023fc6Smrb# port <sentinel-port> 423023fc6Smrb# The port that this sentinel instance will run on 523023fc6Smrbport 26379 623023fc6Smrb 7c9437fe5Santirez# sentinel announce-ip <ip> 8c9437fe5Santirez# sentinel announce-port <port> 9c9437fe5Santirez# 10c9437fe5Santirez# The above two configuration directives are useful in environments where, 11c9437fe5Santirez# because of NAT, Sentinel is reachable from outside via a non-local address. 12c9437fe5Santirez# 13c9437fe5Santirez# When announce-ip is provided, the Sentinel will claim the specified IP address 14c9437fe5Santirez# in HELLO messages used to gossip its presence, instead of auto-detecting the 15c9437fe5Santirez# local address as it usually does. 16c9437fe5Santirez# 17c9437fe5Santirez# Similarly when announce-port is provided and is valid and non-zero, Sentinel 18c9437fe5Santirez# will announce the specified TCP port. 19c9437fe5Santirez# 20c9437fe5Santirez# The two options don't need to be used together, if only announce-ip is 21c9437fe5Santirez# provided, the Sentinel will announce the specified IP and the server port 22c9437fe5Santirez# as specified by the "port" option. If only announce-port is provided, the 23c9437fe5Santirez# Sentinel will announce the auto-detected local IP and the specified port. 243d939266SDara Kong# 253d939266SDara Kong# Example: 263d939266SDara Kong# 27c9437fe5Santirez# sentinel announce-ip 1.2.3.4 283d939266SDara Kong 2963d1f9e5Santirez# dir <working-directory> 3063d1f9e5Santirez# Every long running process should have a well-defined working directory. 3163d1f9e5Santirez# For Redis Sentinel to chdir to /tmp at startup is the simplest thing 32*cf737ff1SJan-Erik Rediger# for the process to don't interfere with administrative tasks such as 3363d1f9e5Santirez# unmounting filesystems. 3463d1f9e5Santirezdir /tmp 3563d1f9e5Santirez 36baace5fcSantirez# sentinel monitor <master-name> <ip> <redis-port> <quorum> 37baace5fcSantirez# 386d5fa2e0SYubao Liu# Tells Sentinel to monitor this master, and to consider it in O_DOWN 3923023fc6Smrb# (Objectively Down) state only if at least <quorum> sentinels agree. 406b5daa2dSantirez# 4137b43c8aSantirez# Note that whatever is the ODOWN quorum, a Sentinel will require to 4237b43c8aSantirez# be elected by the majority of the known Sentinels in order to 4337b43c8aSantirez# start a failover, so no failover can be performed in minority. 4437b43c8aSantirez# 4569fa133eSantirez# Slaves are auto-discovered, so you don't need to specify slaves in 4669fa133eSantirez# any way. Sentinel itself will rewrite this configuration file adding 4769fa133eSantirez# the slaves using additional configuration options. 4869fa133eSantirez# Also note that the configuration file is rewritten when a 4969fa133eSantirez# slave is promoted to master. 5069fa133eSantirez# 516b5daa2dSantirez# Note: master name should not include special characters or spaces. 526b5daa2dSantirez# The valid charset is A-z 0-9 and the three characters ".-_". 536b5daa2dSantirezsentinel monitor mymaster 127.0.0.1 6379 2 546b5daa2dSantirez 55db100c46Santirez# sentinel auth-pass <master-name> <password> 56db100c46Santirez# 57db100c46Santirez# Set the password to use to authenticate with the master and slaves. 58db100c46Santirez# Useful if there is a password set in the Redis instances to monitor. 59db100c46Santirez# 60db100c46Santirez# Note that the master password is also used for slaves, so it is not 61db100c46Santirez# possible to set a different password in masters and slaves instances 62db100c46Santirez# if you want to be able to monitor these instances with Sentinel. 63db100c46Santirez# 64db100c46Santirez# However you can have Redis instances without the authentication enabled 65db100c46Santirez# mixed with Redis instances requiring the authentication (as long as the 66db100c46Santirez# password set is the same for all the instances requiring the password) as 67db100c46Santirez# the AUTH command will have no effect in Redis instances with authentication 68db100c46Santirez# switched off. 69db100c46Santirez# 70db100c46Santirez# Example: 71db100c46Santirez# 72db100c46Santirez# sentinel auth-pass mymaster MySUPER--secret-0123passw0rd 73db100c46Santirez 74baace5fcSantirez# sentinel down-after-milliseconds <master-name> <milliseconds> 75baace5fcSantirez# 766b5daa2dSantirez# Number of milliseconds the master (or any attached slave or sentinel) should 776b5daa2dSantirez# be unreachable (as in, not acceptable reply to PING, continuously, for the 786b5daa2dSantirez# specified period) in order to consider it in S_DOWN state (Subjectively 796b5daa2dSantirez# Down). 806b5daa2dSantirez# 816b5daa2dSantirez# Default is 30 seconds. 826b5daa2dSantirezsentinel down-after-milliseconds mymaster 30000 836b5daa2dSantirez 84baace5fcSantirez# sentinel parallel-syncs <master-name> <numslaves> 85baace5fcSantirez# 866b5daa2dSantirez# How many slaves we can reconfigure to point to the new slave simultaneously 876b5daa2dSantirez# during the failover. Use a low number if you use the slaves to serve query 886b5daa2dSantirez# to avoid that all the slaves will be unreachable at about the same 896b5daa2dSantirez# time while performing the synchronization with the master. 906b5daa2dSantirezsentinel parallel-syncs mymaster 1 916b5daa2dSantirez 92baace5fcSantirez# sentinel failover-timeout <master-name> <milliseconds> 93baace5fcSantirez# 9437b43c8aSantirez# Specifies the failover timeout in milliseconds. It is used in many ways: 956b5daa2dSantirez# 9637b43c8aSantirez# - The time needed to re-start a failover after a previous failover was 9737b43c8aSantirez# already tried against the same master by a given Sentinel, is two 9837b43c8aSantirez# times the failover timeout. 996b5daa2dSantirez# 10037b43c8aSantirez# - The time needed for a slave replicating to a wrong master according 1016d5fa2e0SYubao Liu# to a Sentinel current configuration, to be forced to replicate 10237b43c8aSantirez# with the right master, is exactly the failover timeout (counting since 10337b43c8aSantirez# the moment a Sentinel detected the misconfiguration). 10437b43c8aSantirez# 10537b43c8aSantirez# - The time needed to cancel a failover that is already in progress but 10637b43c8aSantirez# did not produced any configuration change (SLAVEOF NO ONE yet not 10737b43c8aSantirez# acknowledged by the promoted slave). 10837b43c8aSantirez# 10937b43c8aSantirez# - The maximum time a failover in progress waits for all the slaves to be 11037b43c8aSantirez# reconfigured as slaves of the new master. However even after this time 11137b43c8aSantirez# the slaves will be reconfigured by the Sentinels anyway, but not with 11237b43c8aSantirez# the exact parallel-syncs progression as specified. 11337b43c8aSantirez# 11437b43c8aSantirez# Default is 3 minutes. 11537b43c8aSantirezsentinel failover-timeout mymaster 180000 1166b5daa2dSantirez 1179d09ce39Sguiquanz# SCRIPTS EXECUTION 118ed2a691aSantirez# 119ed2a691aSantirez# sentinel notification-script and sentinel reconfig-script are used in order 120ed2a691aSantirez# to configure scripts that are called to notify the system administrator 121ed2a691aSantirez# or to reconfigure clients after a failover. The scripts are executed 122ed2a691aSantirez# with the following rules for error handling: 123ed2a691aSantirez# 1240f259709Santirez# If script exits with "1" the execution is retried later (up to a maximum 125ed2a691aSantirez# number of times currently set to 10). 126ed2a691aSantirez# 1270f259709Santirez# If script exits with "2" (or an higher value) the script execution is 128ed2a691aSantirez# not retried. 129ed2a691aSantirez# 130ed2a691aSantirez# If script terminates because it receives a signal the behavior is the same 131ed2a691aSantirez# as exit code 1. 132ed2a691aSantirez# 133ed2a691aSantirez# A script has a maximum running time of 60 seconds. After this limit is 134ed2a691aSantirez# reached the script is terminated with a SIGKILL and the execution retried. 135ed2a691aSantirez 136ed2a691aSantirez# NOTIFICATION SCRIPT 137ed2a691aSantirez# 138baace5fcSantirez# sentinel notification-script <master-name> <script-path> 139baace5fcSantirez# 1406d5fa2e0SYubao Liu# Call the specified notification script for any sentinel event that is 141baace5fcSantirez# generated in the WARNING level (for instance -sdown, -odown, and so forth). 142baace5fcSantirez# This script should notify the system administrator via email, SMS, or any 143baace5fcSantirez# other messaging system, that there is something wrong with the monitored 144baace5fcSantirez# Redis systems. 145baace5fcSantirez# 146baace5fcSantirez# The script is called with just two arguments: the first is the event type 147baace5fcSantirez# and the second the event description. 148baace5fcSantirez# 14978b606acSJeremy Zawodny# The script must exist and be executable in order for sentinel to start if 150baace5fcSantirez# this option is provided. 151baace5fcSantirez# 152baace5fcSantirez# Example: 153baace5fcSantirez# 154baace5fcSantirez# sentinel notification-script mymaster /var/redis/notify.sh 155baace5fcSantirez 1566275004cSantirez# CLIENTS RECONFIGURATION SCRIPT 1576275004cSantirez# 1586275004cSantirez# sentinel client-reconfig-script <master-name> <script-path> 1596275004cSantirez# 16037b43c8aSantirez# When the master changed because of a failover a script can be called in 1616275004cSantirez# order to perform application-specific tasks to notify the clients that the 1626275004cSantirez# configuration has changed and the master is at a different address. 1636275004cSantirez# 1646275004cSantirez# The following arguments are passed to the script: 1656275004cSantirez# 1666275004cSantirez# <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port> 1676275004cSantirez# 16837b43c8aSantirez# <state> is currently always "failover" 1696275004cSantirez# <role> is either "leader" or "observer" 1706275004cSantirez# 1716275004cSantirez# The arguments from-ip, from-port, to-ip, to-port are used to communicate 1726275004cSantirez# the old address of the master and the new address of the elected slave 17337b43c8aSantirez# (now a master). 1746275004cSantirez# 1756275004cSantirez# This script should be resistant to multiple invocations. 1766275004cSantirez# 1776275004cSantirez# Example: 1786275004cSantirez# 1796275004cSantirez# sentinel client-reconfig-script mymaster /var/redis/reconfig.sh 1806275004cSantirez 181baace5fcSantirez 182