#主master配置如下
cat /etc/keepalived/keepalived.conf
global_defs {
notification_email {
[email protected]
}
#notification_email_from [email protected]
#smtp_server 10.168.0.48
#smtp_connect_timeout 10
router_id nginx
}
vrrp_script chk_haproxy {
script "/etc/keepalived/chk_haproxy.sh"
interval 5
weight 2
}
vrrp_instance ha_71 {
state MASTER
interface eth0
virtual_router_id 71
priority 150
advert_int 5
authentication {
auth_type PASS
auth_pass ha8888
}
track_script {
chk_haproxy
}
virtual_ipaddress {
192.168.5.70/24 dev eth0 label eth0:1
}
}
}
#salve配置如下
cat /etc/keepalived/keepalived.conf
global_defs {
notification_email {
[email protected]
}
#notification_email_from [email protected]
#smtp_server 10.168.0.48
#smtp_connect_timeout 10
router_id nginx
}
vrrp_script chk_haproxy {
script "/etc/keepalived/chk_haproxy.sh"
interval 5
weight 2
}
vrrp_instance ha_71 {
state BACKUP
interface eth0
virtual_router_id 71
priority 100
advert_int 5
authentication {
auth_type PASS
auth_pass ha8888
}
track_script {
chk_haproxy
}
virtual_ipaddress {
192.168.5.70/24 dev eth0 label eth0:1
}
}
}