--------------------------------------master-------------------------------------------------------
wget http://www.keepalived.org/software/keepalived-2.0.9.tar.gz
tar zxvf keepalived-2.0.9.tar.gz
cd keepalived-2.0.9
./configure --perfix=/ --mandir=/usr/local/share/man
make &&make install
cp keepalived/etc/init.d/keepalived.rh.init /etc/init.d/keepalived
chmod +x /etc/init.d/keepalived
cp keepalived/etc/init.d/keepalived.sysconfig /etc/sysconfig/keepalived
chkconfig --add keepalived
chkconfig --level 345 keepalived on
编辑
vi /etc/sysconfig/keepalived
global_defs {
notification_email {
finalsd@gmail.com
}
notification_email_from finaxx@gmail.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id haproxy-ha
}
vrrp_sync_group VG1 {
group {
VI1
}
}
vrrp_instance VI1 {
state BACKUP
smtp_alert
notify_fault "/root/script/notify_mail.sh fault"
notify_master "/root/script/notify_mail.sh master"
nopreempt
insterface eth1
track_interface {
eth 0
eth 1
}
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass abc123..
}
virtual_ipaddress {
192.168.1.1/24 dev eth1 scope global
}
}
service keepalived start
--------------------------------------backup-----------------------------------------------------
wget http://www.keepalived.org/software/keepalived-2.0.9.tar.gz
tar zxvf keepalived-2.0.9.tar.gz
cd keepalived-2.0.9
./configure --perfix=/ --mandir=/usr/local/share/man
make &&make install
cp keepalived/etc/init.d/keepalived.rh.init /etc/init.d/keepalived
chmod +x /etc/init.d/keepalived
cp keepalived/etc/init.d/keepalived.sysconfig /etc/sysconfig/keepalived
chkconfig --add keepalived
chkconfig --level 345 keepalived on
编辑
vi /etc/sysconfig/keepalived
global_defs {
notification_email {
finalsd@gmail.com
}
notification_email_from finaxx@gmail.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id haproxy-ha
}
vrrp_sync_group VG1 {
group {
VI1
}
}
vrrp_instance VI1 {
state BACKUP
smtp_alert
notify_fault "/root/script/notify_mail.sh fault"
notify_master "/root/script/notify_mail.sh master"
insterface eth1
track_interface {
eth 0
eth 1
}
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass abc123..
}
virtual_ipaddress {
192.168.1.1/24 dev eth1 scope global
}
}
service keepalived start
/root/script/notify_mail.sh ##发送邮件给xxxx