我一直在做一个项目,该项目将建立一组高度可用的负载均衡器。负载平衡和高可用性软件似乎工作得很好(我使用Crossroads进行负载平衡,Keepalived使负载平衡服务器高度可用,Conntrackd用于负载均衡器的健康检查),但我在设置Keepalived的配置文件以在发生状态转换时发送电子邮件时遇到问题(master->backup/backup->master)。我遵循手册页(man keepalived.conf)上的说明,告诉我如何设置电子邮件通知,但我无法在预期时间收到电子邮件。我倾向于拼写检查和简单的错误,但在检查这个问题近10个小时后,我似乎什么也找不到,并且没有什么可以尝试的东西。
我使用的其中一台服务器(我将其命名为loadbalance1)有时会在发生更改时使用smtp_alert发送电子邮件,但它只会在从备份服务器转换到主服务器(而不是主服务器到备份服务器)时通知我。当它不工作时,日志文件(/var/ log /messages和/var/log/syslog)会通知我发生了SMTP错误状态550。我理解这些问题是与配置文件中指定的错误电子邮件地址有关的,但据我所知,它们是正确的。我唯一认为keepalived或我的配置文件是错误的是,sysadmin会给人们发电子邮件,告诉他们'{‘是一个不正确的邮件收件人。我在计算机上打开了smtp端口。另一件奇怪的事情是,当keepalived试图联系邮件服务器时,它想要在本地机器不在的时候查看它。我将邮件服务器指定为在别处,但由于某些原因,它希望在本地查看。
另一台服务器loadbalance2永远不会发送smtp_alert来发送电子邮件,无论它进行什么状态转换。我可以在keepalived的日志文件(/var/ log /messages和/var/log/syslog)中看到,备份服务器loadbalance2确实会转换为主状态,但它从不发送电子邮件。它给出了与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
}如果配置文件中有一些不一致之处,我深表歉意。感谢您的任何建议、帮助或意见。如果您需要更多的信息,我很乐意为您效劳。
发布于 2011-06-28 04:22:22
对于那些可能面临同样问题的人,我设法解决了这个问题。我不确定这是否是解决方案,但它可能起到了作用。
-I不得不将机器的日期和时间更改为当前时间(其中一台机器由于是克隆机器,因此关闭了几年)。由于系统时间的差距,电子邮件服务器可能一直在阻止后端服务器的电子邮件?
-Date -s hh:mm:ss
-Date -s年-月-日
-Had来解决在两台计算机上具有相同主机名的问题。正如我所说的,它是另一个的克隆,我从来没有无意中改变过它。我可能一直收到来自后端服务器的通知,但没有区分这两者,因为我收到了来自相同主机名的电子邮件
-Made对配置文件的微小更改,应该可以忽略不计
global_defs
{
notification_email {
user@domain.com
}
}我不确定这是不是造成了不同,但是well...it现在可以工作了
发布于 2015-08-13 22:56:51
我能够解决我在keepalived.log中看到的一个类似的问题:
SMTP connection ERROR to [0.0.0.0]:25我的keepalived.conf看起来像这样:
global_defs {
notification_email {
....
}
notification_email_from somplace@somewhere.com
smtp_server smtp.somehwere.com
smtp_connect_timeout 30
...
}我更新了smtp配置,以便对smtp服务器使用IP地址而不是主机名:
smtp_server xxx.xxx.xxx.xxx在重新启动keepalived后,导致新的输出和成功的邮件通知:
Remote SMTP server [xxx.xxx.xxx.xxx]:25 connected.https://stackoverflow.com/questions/6472326
复制相似问题