# install keepalived yum install -y keepalived # config keepalived for rotating & high availability virtual ip cat > /etc/keepalived/keepalived.cfg << "EOF" vrrp_script chk_haproxy { script "killall -0 haproxy" # health check script, will force master election when error code is yielded interval 2 weight 5 } vrrp_instance VI_1 { interface eth0 state MASTER # or BACKUP for backup instances virtual_router_id 202 # must be synchronized across instances priority 101 # must vary across instances, highest priority instance is master # must ensure that (priority + health check weight) of lowest priority instance # be high enough to outweight highest priority amongst instances advert_int 1 unicast_src_ip # ip of the instance unicast_peer { # ip of other instances, add more ip as necessary } // must be the same for all instances authentication { auth_type PASS auth_pass password } # virtual ip to bind to master instance virtual_ipaddress { } # call check script defined above track_script { chk_haproxy } } EOF # restart keepalived systemctl restart keepalived