####BACKUP和MASTER一样
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 22222
}
virtual_ipaddress {
192.168.0.104/24
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
###notify.sh
#!/bin/bash
smail(){
to=$1
subject=$2
body=$3
/usr/local/bin/sendEmail -f ronghedai_server@sina.com -t "$to" -s smtp.sina.com -u "$subject" -o message-content-type=html -o message-charset=utf8 -xu sender@sina.com -xp feng123.123 -m "$body" >> /tmp/keepalived_mail.log
}
notify(){
content="`hostname` has been $1"
smail reciver@qq.com `hostname` "$content"
}
case $1 in
master)
notify $1
;;
backup)
notify $1
;;
fault)
notify $1
;;
*)
echo "usage master | backup | falt"
;;
esac