--------------------------------------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
}
}
virtual_server 192.168.1.1 80 {
delay_loop 3
lb_algo wlc #rr wrr
lb_kind DR
persistence_timeout 1200
protocol TCP
ha_suspend
real_server 192.168.1.11 80 {
weight 3
TCP_CHECK {
connect_timeout 3
connect_port 80
}
}
real_server 192.168.1.12 80 {
weight 3
TCP_CHECK {
connect_timeout 3
connect_port 80
}
}
}
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
}
}
virtual_server 192.168.1.1 80 {
delay_loop 3
lb_algo wlc #rr wrr
lb_kind DR
persistence_timeout 1200
protocol TCP
ha_suspend
real_server 192.168.1.11 80 {
weight 3
TCP_CHECK {
connect_timeout 3
connect_port 80
}
}
real_server 192.168.1.12 80 {
weight 3
TCP_CHECK {
connect_timeout 3
connect_port 80
}
}
}