在MASTER,BACKUP切换后可以执行定制的脚本:
配置实例:
! Configuration File for keepalived
global_defs {
notification_email {
oscersong007@gmail.com
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_sync_group VGM {
group {
VI_1
}
notify_master /path/to/to_master.sh #表示当切换到master状态时,要执行的脚本
notify_backup /path_to/to_backup.sh #表示当切换到backup状态时,要执行的脚本
notify_fault "/path/fault.sh VG_1" #表示切换出现故障时要执行的脚本
}
vrrp_script chk_http_port {
script "killall -0 httpd"
interval 1
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass westos
}
track_interface {
eth0
eth1
}
virtual_ipaddress {
192.168.0.150/24 dev eth0
10.0.0.150/24 dev eth1
}
track_script {
chk_http_port
}
}
转载于:https://my.oschina.net/sharelinux/blog/119607