防止主人失败后回到主人

我使用keepalived来build立一个指向主服务器的虚拟IP地址。 当发生故障转移时,应该将虚拟IP指向备份,并且IP应该保持在那里直到我手动启用(修复)主设备。

这很重要的原因是我在服务器上运行mysql复制,写入只能在主服务器上。 当我失败时,我促使奴隶掌握。

主服务器:

global_defs { ! this is who emails will go to on alerts notification_email { [email protected] ! add a few more email addresses here if you would like } notification_email_from [email protected] ! I use the local machine to relay mail smtp_server 127.0.0.1 smtp_connect_timeout 30 ! each load balancer should have a different ID ! this will be used in SMTP alerts, so you should make ! each router easily identifiable lvs_id APP1 } vrrp_instance APP1 { interface eth0 state EQUAL virtual_router_id 61 priority 999 nopreempt virtual_ipaddress { 217.xx129 } smtp_alert } 

备份服务器:

  global_defs { ! this is who emails will go to on alerts notification_email { [email protected] ! add a few more email addresses here if you would like } notification_email_from [email protected] ! I use the local machine to relay mail smtp_server 127.0.0.1 smtp_connect_timeout 30 ! each load balancer should have a different ID ! this will be used in SMTP alerts, so you should make ! each router easily identifiable lvs_id APP2 } vrrp_instance APP2 { interface eth0 state EQUAL virtual_router_id 61 priority 100 virtual_ipaddress { 217.xx.xx.129 } notify_master "/etc/keepalived/notify.sh del app2" notify_backup "/etc/keepalived/notify.sh add app2" notify_fault "/etc/keepalived/notify.sh add app2” smtp_alert } 

我和你有同样的问题。 通过在两个keepalived服务器上设置nopreempt来解决这个问题,同时(根据http://article.gmane.org/gmane.linux.keepalived.devel/1537 )设置两个服务器处于BACKUP状态(具有不同的优先级) 。

太棒了! 🙂

这可能不是最优雅的解决scheme,但是不能阻止keepalived在master上的notify_backupnotify_fault脚本中吗? 这样,你将不得不重新启动它,以再次获得控制权。

类似的东西:

 notify_backup "/etc/init.d/keepalived stop" notify_fault "/etc/init.d/keepalived stop"