Description of redis-sentinel.conf configuration items

1.port 26379

Sentinel listening port, the default is 26379, can be modified.

 

2.sentinel monitor <master-name> <ip> <redis-port> <quorum>

Tell sentinel to listen to a master whose address is ip:port. The master-name here can be customized, and quorum is a number that indicates how many sentinels think a master is invalid. The master is truly invalid. The master-name can only contain English letters, numbers, and the three characters ".-_". It should be noted that the master-ip should write the real ip address instead of the loopback address (127.0.0.1).

Configuration example:

sentinel monitor mymaster 192.168.0.5 6379 2

 

3.sentinel auth-pass <master-name> <password>

Set the password when connecting the master and slave. Note that sentinel cannot set different passwords for master and slave respectively, so the passwords of master and slave should be set the same.

Configuration example:

sentinel auth-pass mymaster 0123passw0rd

 

4.sentinel down-after-milliseconds <master-name> <milliseconds> 

This configuration item specifies how much failure time is required before a master is subjectively considered unavailable by the sentinel. The unit is milliseconds, the default is 30 seconds

Configuration example:

sentinel down-after-milliseconds mymaster 30000

 

5.sentinel parallel-syncs <master-name> <numslaves> 

This configuration item specifies how many slaves can synchronize the new master at the same time when failover master/slave switchover occurs. The smaller the number, the longer it takes to complete the failover, but if the number is larger, it means The more slaves are unavailable due to replication. By setting this value to 1, you can ensure that only one slave is in a state that cannot process command requests at a time.

Configuration example:

sentinel parallel-syncs mymaster 1

 

6. sentinel failover-timeout <master-name> <milliseconds>

failover-timeout can be used in the following ways: 

      1. The interval between two failovers of the same sentinel to the same master.

      2. Time is calculated when a slave synchronizes data from a wrong master. Until the slave is corrected to synchronize data to the correct master.

      3. The time required to cancel an ongoing failover.  

      4. When performing failover, configure the maximum time required for all slaves to point to the new master. However, even after this timeout, the slaves will still be correctly configured to point to the master, but not according to the rules configured by parallel-syncs.

Configuration example:

sentinel failover-timeout mymaster1 20000

 

7. Sentinel's notification-script and reconfig-script are used to configure the script that needs to be executed when an event occurs. The script can be used to notify the administrator, such as sending an email to notify the relevant personnel when the system is not running normally. There are the following rules for the running result of the script:

        If the script returns 1 after execution, the script will be executed again later, and the number of repetitions currently defaults to 10

        If the script returns 2 after execution, or a return value higher than 2, the script will not be executed repeatedly.

        If the script is terminated due to receiving a system interrupt signal during execution, the behavior is the same as when the return value is 1.

        The maximum execution time of a script is 60s. If this time is exceeded, the script will be terminated by a SIGKILL signal and then re-executed.

1).sentinel notification-script <master-name> <script-path> 

Notification script: When sentinel has any warning level event (such as subjective failure and objective failure of redis instance, etc.), this script will be called. At this time, the script should notify the system by email, SMS, etc. Information for administrators about system malfunctions. When calling the script, two parameters will be passed to the script, one is the type of the event and the other is the description of the event. If the script path is configured in the sentinel.conf configuration file, it must be ensured that the script exists in this path and is executable, otherwise sentinel cannot start successfully.

  Configuration example:

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

 

2).sentinel client-reconfig-script <master-name> <script-path>

 When a master changes due to failover, this script will be called to notify relevant clients that the master address has changed. The following parameters will be passed to the script when it is called:

       <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>

Currently <state> is always "failover" and <role> is either "leader" or "observer". The parameters from-ip, from-port, to-ip, to-port are used to communicate with the old master and the new master (ie the old slave). This script should be generic and can be called multiple times, not targeted.

   Configuration example:

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326274372&siteId=291194637