The Keepalived Solution
Keepalived provides a strong and robust health checking for LVS clusters. It implements a framework of health checking on multiple layers for server failover, and VRRPv2 stack to handle director failover.
Configuation example
Now we're going to using keepalived to contruct a highly-available VS/NAT web cluster with two load balancers and three web servers. The topology is illustrated in the following figure. In the example, virtual IP address and gateway IP address are 10.23.8.80 and 172.18.1.254, which are floating between the two load balancers (LD1 and LD2), and the ip addresses of three real servers are 172.18.1.11, 172.18.1.12 and 172.18.1.13 respectively.
In our example, the keepalived configuration file (/etc/keepalived/keepalived.conf) at the LD1 looks like:
vrrp_sync_group VG1 { group { VI_1 VI_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 } virtual_ipaddress { 10.23.8.80 } } vrrp_instance VI_2 { state MASTER interface eth1 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 172.18.1.254 } } virtual_server 10.23.8.80 80 { delay_loop 6 lb_algo wlc lb_kind NAT persistence_timeout 600 protocol TCP real_server 172.18.1.11 80 { weight 100 TCP_CHECK { connect_timeout 3 } } real_server 172.18.1.12 80 { weight 100 TCP_CHECK { connect_timeout 3 } } real_server 172.18.1.13 80 { weight 100 TCP_CHECK { connect_timeout 3 } } }
The Keepalived configuration file at LD2 is similar to that of LD1, except to change the state of VI_1 and VI_2 from MASTER to BACKUP.