connection sync suggestions with HAproxy and keepalived

I managed to get HAproxy working in a failover configuration as suggested on the architecture.txt document using keepalived.

I used CentOS 5.5, HAproxy rpm (haproxy-1.3.25-1.el5) from epel repo, and keepalived rpm (keepalived-1.1.15-0.el5.centos) from CentOS testing repo.

This is my keepalived configuration

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

vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 101                    # 101 on master, 100 on backup
    virtual_ipaddress {
    10.0.0.30            
    10.0.0.31            
    }
    track_script {
        chk_haproxy
    }
}

What I would like now is having my backup node being able to take over the actual connections open when the master is failing.

I heard this can be done in multiple ways (conntrackd), using LVS features, etc... I'd like to have suggestions on the simplest and more robust way to achieve it, using available rpms would be best.

Thanks G


Solution 1:

lvs_sync_daemon_inteface option enables the MASTER to save the connection state and sync it with the BACKUP. Try this:

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    lvs_sync_daemon_interface eth0
    virtual_router_id 51
    priority 101                    # 101 on master, 100 on backup
    virtual_ipaddress {
    10.0.0.30            
    10.0.0.31            
    }
    track_script {
        chk_haproxy
    }
}