【发布时间】:2011-09-22 06:34:30
【问题描述】:
我一直在从事一个项目,该项目将建立一组高度可用的负载平衡器。负载平衡和高可用性软件似乎工作得很好(我使用 Crossroads 进行负载平衡,并使用 Keepalived 使负载平衡服务器具有高可用性,并使用 Conntrackd 对负载平衡器进行健康检查)但我在设置配置时遇到问题状态转换发生时 Keepalived 发送电子邮件的文件(master->backup/backup->master)。我已按照手册页 (man keepalived.conf) 上的说明告诉我如何设置电子邮件通知,但我未能在预期时间收到电子邮件。我很容易出现拼写检查和简单的错误,但是在查看了这个问题近 10 个小时之后,我似乎找不到任何东西,而且我已经没有东西可以尝试了。
我正在使用的其中一个服务器(我将其命名为 loadbalance1)有时会在发生更改时使用 smtp_alert 发送电子邮件,但它只会在它从备份转换到主服务器(而不是主服务器到备份)时通知我)。当它不起作用时,日志文件(/var/log/messages 和 /var/log/syslog)会通知我出现 SMTP 错误状态 550。我理解这些问题与配置文件中指定的错误电子邮件地址有关,但据我所知,它们是正确的。我唯一认为keepalived或我的配置文件有误的事情是系统管理员通过电子邮件向人们发送有关“{”是不正确的邮件收件人的消息。我在计算机上打开了 smtp 端口。发生的另一件奇怪的事情是,当keepalived 尝试联系邮件服务器时,它想在本地机器不存在时查看它。我将邮件服务器指定为在其他地方,但出于某种原因它想在本地查看。
另一台服务器 loadbalance2 永远不会发送 smtp_alert 来发送电子邮件,无论它进行什么状态转换。我可以在 keepalived 的日志文件(/var/log/messages 和 /var/log/syslog)中看到备份服务器 loadbalance2 确实转换到 MASTER 状态,但它从不发送电子邮件。它给出了与 loadbalance1 相同的错误,但它永远不会在这里工作。它与 loadbalance1 具有相同的配置文件。
下面是配置文件keepalived.conf
global_defs
{
notification_email
{
fakeemail@example.com
}
notification_email_from sysamin@example.com
##Mail server below##
smtp_server www.xxx.yyy.zzz
smtp_connect_timeout 30
lvs_id NLB_MASTER
vrrp_sync_group
{
group
{
loadbalance1
loadbalance2
}
##The following scripts don't seem to work properly either##
##The scripts are not executed at expected times ##
notify_master "/path/to/script.sh master"
notify_backup "/path/to/script.sh backup"
notify_fault "/path/to/script.sh fault"
notify "/path/to/script.sh"
smtp_alert
}
vrrp_instance loadbalance1
{
state MASTER
interface eth0
virtual_router_id 20
priority 100
#In some examples online smtp_alert is here
virtual_ipaddress
{
www.xxx.yyy.zzz/24 brd www.xxx.yyy.255 dev eth0
}
##Not entirely sure if this is correct##
notify_master "/path/to/script.sh master"
notify_backup "/path/to/script.sh backup"
notify_fault "/path/to/script.sh fault"
notify "/path/to/script.sh"
smtp_alert
}
vrrp_instance loadbalance2
{
state MASTER
interface eth0
virtual_router_id 30
priority 100
#In some examples online smpt_alert is here
virtual_ipaddress
{
www.xxx.yyy.zzz/24 brd www.xxx.yyy.255 dev eth1
}
##Not entirely sure if this is correct##
notify_master "/path/to/script.sh master"
notify_backup "/path/to/script.sh backup"
notify_fault "/path/to/script.sh fault"
notify "/path/to/script.sh"
smtp_alert
}
如果配置文件中存在一些不一致之处,我深表歉意。任何建议,帮助或意见表示赞赏。如果您需要更多信息,我很乐意提供帮助。
【问题讨论】:
-
电子邮件发送与不发送的任何模式?
标签: linux smtp load-balancing keep-alive