Keepalived Master and Backup for Haproxy

Simple master – slave config, depends on haproxy service running.

Master:

global_defs {
notification_email {
[email protected]
}

notification_email_from [email protected]
smtp_server [email protected]
smtp_connect_timeout 30
router_id LVS_SERVER_1
}

vrrp_script chk_haproxy { # Requires keepalived-1.1.13
    script "killall -0 haproxy" # widely used idiom
    interval 2 # check every 2 seconds
    weight 2 # add 2 points of prio if OK
}

vrrp_instance D1 {
   state MASTER
   smtp_alert
   interface eth0
   virtual_router_id 51
   priority 101
   advert_int 1
authentication {
   auth_type PASS
   auth_pass 111111
}
virtual_ipaddress {
   10.0.1.2/8 label eth0:2
   10.0.1.3/8 label eth0:3
}

track_script {
    chk_haproxy
   }
}

Backup

global_defs {
notification_email {
[email protected]
}

notification_email_from [email protected]
smtp_server [email protected]
smtp_connect_timeout 30
router_id LVS_SERVER_2
}

vrrp_script chk_haproxy { # Requires keepalived-1.1.13
    script "killall -0 haproxy" # widely used idiom
    interval 2 # check every 2 seconds
    weight 2 # add 2 points of prio if OK
}

vrrp_instance D1 {
   state BACKUP
   smtp_alert
   interface eth0
   virtual_router_id 51
   priority 100
   advert_int 1
authentication {
   auth_type PASS
   auth_pass 111111
}
virtual_ipaddress {
   10.0.1.2/8 label eth0:2
   10.0.1.3/8 label eth0:3
}

track_script {
   chk_haproxy
   }
}

Hint: on master good practice to use -V(dont-release-vrrp) and -I(dont-release-ipvs) options for keepalived.

vim /etc/sysconfig/keepalived

KEEPALIVED_OPTIONS="-V -I -D"


原文链接: http://huinn.wordpress.com/2012/02/04/keepalived-master-and-backup-for-haproxy/


你可能感兴趣的:(Keepalived Master and Backup for Haproxy)