[root@Haproxy_Keepalived_Master ~]
! Configuration File
for
keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id HAproxy237
}
vrrp_script chk_haproxy {
script
"/etc/keepalived/check_haproxy.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_haproxy
}
virtual_ipaddress {
182.148.15.239
}
notify_master
"/etc/keepalived/clean_arp.sh 182.148.15.239"
}
vrrp_instance VI_2 {
state BACKUP
interface eth0
virtual_router_id 52
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
182.148.15.235
}
notify_master
"/etc/keepalived/clean_arp.sh 182.148.15.235"
}
3)Haproxy_Keepalived_Backup服务器上的Keepalived配置如下:
[root@Haproxy_Keepalived_Backup ~]
[root@Haproxy_Keepalived_Backup ~]
! Configuration File
for
keepalived
global_defs {
notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id HAproxy236
}
vrrp_script chk_haproxy {
script
"/etc/keepalived/check_haproxy.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
track_script {
chk_haproxy
}
virtual_ipaddress {
182.148.15.239
}
notify_master
"/etc/keepalived/clean_arp.sh 182.148.15.239"
}
vrrp_instance VI_2 {
state MASTER
interface eth0
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
182.148.15.235
}
notify_master
"/etc/keepalived/clean_arp.sh 182.148.15.235"
}