[Redis]-監控多個Redis Master

Redis建置學習心得

以本次的需求, 最終是有三套Redis Instance在三台機器上, 並且相互為master-slave replication, 相互透過Sentinel監控.

 

 

因為, sentinel configure, 只要將先前說明的設定, 同時設定多份即可以監控多個master的狀況, 不過依照上圖的配置, 由於同時會有三個sentinel, 所以設定上有調整為 同時二個sentinel檢查確認失敗才failover”

 

# Note: master name should not include special characters or spaces.

# The valid charset is A-z 0-9 and the three characters ".-_".

sentinel monitor apgp1 192.168.127.101 6379 2

sentinel monitor apgp2 192.168.127.103 6380 2

sentinel monitor apgp2 192.168.127.102 6381 2

 

# Number of milliseconds the master (or any attached slave or sentinel) should

# be unreachable (as in, not acceptable reply to PING, continuously, for the

# specified period) in order to consider it in S_DOWN state (Subjectively

# Down).

#

# Default is 30 seconds.

sentinel down-after-milliseconds apgp1 5000

sentinel down-after-milliseconds apgp2 5000

sentinel down-after-milliseconds apgp3 5000

 

# How many slaves we can reconfigure to point to the new slave simultaneously

# during the failover. Use a low number if you use the slaves to serve query

# to avoid that all the slaves will be unreachable at about the same

# time while performing the synchronization with the master.

sentinel parallel-syncs apgp1 1

sentinel parallel-syncs apgp2 1

sentinel parallel-syncs apgp3 1

 

# Default is 3 minutes.

sentinel failover-timeout apgp1 180000

sentinel failover-timeout apgp2 180000

sentinel failover-timeout apgp3 180000

 

 

 

完成後重啟sentinel, 再次檢查就可以看到在此節點上有三個masters.

192.168.127.103:26379> sentinel masters

1)  1) "name"

    2) "apgp2"

    3) "ip"

    4) "192.168.127.103"

    5) "port"

    6) "6380"

    7) "runid"

 

2)  1) "name"

    2) "apgp3"

    3) "ip"

    4) "192.168.127.102"

    5) "port"

    6) "6381"

    7) "runid"

 

3)  1) "name"

    2) "apgp1"

    3) "ip"

    4) "192.168.127.101"

    5) "port"

    6) "6379"

    7) "runid"

 

最後以相同的方式, 設定各台上的sentinel, 即可以建立相互監控的機制 (在此測試需求中, 另二台上指定的sentinel port分別為26380, 26381)