[Redis]-強制Redis Sentinel Failover順序

Redis建置學習心得

先前有提到, 在進行Redis master-slave replication並且搭配Sentinelfailover的配置下, 期許是能指定主要的failover順序, 例如下圖中就是讓原本在192.168.127.101上的master能以先移轉到192.168.127.103為設定.

 

 

因此, 若要符合上述的配置, 那麼就在192.168.127.103, Redis的設定檔 (/etc/redis/6379.conf) 中的slave-priority指定數字設定小一些, 但不要設定為0 (不移轉)

# The slave priority is an integer number published by Redis in the INFO output.

# It is used by Redis Sentinel in order to select a slave to promote into a

# master if the master is no longer working correctly.

#

# A slave with a low priority number is considered better for promotion, so

# for instance if there are three slaves with priority 10, 100, 25 Sentinel will

# pick the one with priority 10, that is the lowest.

#

# However a special priority of 0 marks the slave as not able to perform the

# role of master, so a slave with priority of 0 will never be selected by

# Redis Sentinel for promotion.

#

# By default the priority is 100.

slave-priority 10