VRRP is a neat way to make your setup redundant the right way and balance over an IP from one machine to another. I have touched on IPVS last week in a simple setup, here is now another way to do a neater more robust setup. If you recall last week’s example, we had a reachable IP of 192.168.66.6 which we routed http traffic on. For this to work you also need a static IP within the same subnet like 192.168.66.5. Once configured you can check your setup with ip addr (sadly ifconfig is too broken to show the second IP to you as I discovered lately…).
Here is the keepalived.conf file:
global_defs { router_id My_LB_1 } vrrp_instance lb_network { state BACKUP interface eth0 track_interface { eth0 } lvs_sync_daemon_interface eth0 virtual_router_id 100 priority 150 authentication { auth_type PASS auth_pass superfancysecretpass } virtual_ipaddress { 192.168.66.6 } nopreempt } virtual_server 192.168.66.6 80 { delay_loop 30 lb_algo wrr lb_kind NAT protocol TCP real_server 10.10.1.101 80 { weight 10 TCP_CHECK { connect_timeout 3 } } real_server 10.10.1.102 80 { weight 10 TCP_CHECK { connect_timeout 3 } } }
And this is the config for the second box:
global_defs { router_id My_LB_2 } vrrp_instance lb_network { state BACKUP interface eth0 track_interface { eth0 } lvs_sync_daemon_interface eth0 virtual_router_id 100 priority 100 authentication { auth_type PASS auth_pass superfancysecretpass } virtual_ipaddress { 192.168.66.6 } nopreempt } virtual_server 192.168.66.6 80 { delay_loop 30 lb_algo wrr lb_kind NAT protocol TCP real_server 10.10.1.101 80 { weight 10 TCP_CHECK { connect_timeout 3 } } real_server 10.10.1.102 80 { weight 10 TCP_CHECK { connect_timeout 3 } } }
There you are, redundant setup with keepalived 🙂