當Redis Sentinel通知事件時,它不提供Redis主設備的名稱。Redis Sentinel:通知中的主名稱
從配置的摘錄:
# sentinel notification-script <master-name> <script-path>
#
# Call the specified notification script for any sentinel event that is
# generated in the WARNING level (for instance -sdown, -odown, and so forth).
# This script should notify the system administrator via email, SMS, or any
# other messaging system, that there is something wrong with the monitored
# Redis systems.
#
# The script is called with just two arguments: the first is the event type
# and the second the event description.
所以有僅是事件類型(例如+odown
)和事件的描述,它的情況下+odown
簡單地是master
。不知何故,我覺得這是缺乏重要的信息。我們不僅希望通知用戶有所變化,但其中它已更改。
您無法使用其他參數註冊腳本,例如,
sentinel notification-script <master-name> "<script-path> <master-name>"
Redis將使用該值作爲一個整體並檢查它是否存在並且是可執行的。
我們通過創建小包裝腳本解決了這個問題,每個主包實例一個。
$ cat /some/path/notify-master42.sh
#!/bin/sh
/some/path/notify.sh master42 $1 $2
此包裝腳本,然後連接到主:
sentinel notification-script <master-name> notification-script /some/path/notify-<master-name>.sh
這是一個有點不舒服,但不是太糟糕,只要你有大師的一個固定的數字,而沒有對創建它們飛過網。
您可以通過簡單地與網上的哨兵交互來註冊新的主人。 (redis-cli -h <host> -p <port> sentinel whatever...
)但是創建這些包裝腳本更復雜。這並不是說這是不可能的,但感覺就像跳過燃燒的籃球一樣沒有任何意義。
有沒有辦法來通知,包括主姓名:
- 沒有打補丁的Redis
- 無需包裝腳本
?
我不僅希望在發生故障轉移時進行通知。我也通過+/- odwon/sdown通知。 – udondan