2015-08-26 39 views
0

當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
  • 無需包裝腳本

回答

1

是的,你通過使用正確的事件來做到這一點。

「所以只有事件類型(例如+ odown)和事件描述,在+ odown的情況下只是主人,不知何故,我覺得這是缺少重要信息,我們不僅要通知用戶有些事情發生了變化,但它發生了什麼變化。

在+ odown的情況下沒有其他信息。所有+ odown的意思是主服務器故障。此時沒有其他事情發生。如果要更新基於該一些故障轉移(其中後+ odown發生),你需要看相應的事件:開關主switch-master事件是故障轉移完成時發生的事件。

直接從documentation摘自:

開關主<master name> <oldip> <oldport> <newip> <newport> - 主新的IP地址和一個配置改變之後的指定的一個。 這是消息最外部用戶感興趣。

因此,有你的腳本的外觀並作用於開關主事件得到什麼改變的信息。沒有更多的燃燒箍跳過。

+0

我不僅希望在發生故障轉移時進行通知。我也通過+/- odwon/sdown通知。 – udondan

相關問題