一、概述
# VRRP配置段
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.200.16
}
notify_master "/usr/local/bin/vrrp.mast arg1 arg2"
notify_backup "/usr/local/bin/vrrp.back arg1 arg2"
notify_fault "/usr/local/bin/vrrp.fault arg1 arg2"
notify_stop "/usr/local/bin/vrrp.stop arg1 arg2"
}
notify_master、notify_backup、notify_fault和notify_stop四个选项,这是Keepalived配置中的一个通知机制,也是Keepalived包含的四种状态。
下面介绍每个选项的含义:
notify_master :指定当Keepalived进入MASTER状态时要执行的脚本,这个脚本可以是一个状态报警脚本,也可以是一个服务管理脚本。Keepalived允许脚本传入参数,因此灵活性很强。
notify_backup : 指定当Keepalived进入BACKUP状态时要执行的脚本,同理,这个脚本可以是一个状态报警脚本,也可以是一个脚本管理脚本。
notify_fault :指定当Keepalived进入FAULT状态时要执行的脚本,脚本功能与前两个类似。
notify_stop : 指定当Keepalived程序终止时需要执行的脚本。