I know some people are using keepalived and heartbeat for active/standby but what action is taken if the haproxy process were to die?
What would be nice is if the virtual IP would switch servers if the haproxy process were to die and/or a networking issue were to occur. We are currently investigating heartbeat and corosync with pacemaker. Can anyone explain their solution to this issue in depth?
UPDATE: Thanks Kyle, see answer and links therein.
I would say that
heartbeat
is what you're looking for.If the monitored service (
haproxy
in your case) has an lsb-compliant init-script - heartbeat will runinitscript status
. If it says that the service is down, it will attempt to start it. If it fail at starting it a couple of times - it will perform a fail over to the other node. As long as the nodes have a way to communicate with each other, this will be performed in a very controlled manner - the addresses are removed on one node, and brought up on the other.If two heartbeat-machines lose communication with each other, they may both attempt to perform failover. One way to solve this, is by configuring a STONITH-plugin (Shoot The Other Node In The Head). This will use a management interface and attempt to turn off the other service before starting its services. Some mechanism like this is crucial if you involve shared storage in fail over.
Personally, I have never experienced
haproxy
die - I consider it a very stable service. I useheartbeat
for failover of IP-addresses only if running on the haproxy-nodes.Thank you Kvisle and Kyle! We ended up going with keepalived since, as Kyle mentioned, it is the haproxy creators recommended solution. Keepalived includes the ability to run a user-space script of your choice and determine resource availability based on exit status. So you can very easily accomplish failover with process monitoring. Another benefit is the simplicity compared to heartbeat with pacemaker / corosync, just one application / process and one configuration file.
In our tests we have seen failover happen so quick as to not drop a single ping. Thanks again!
http://www.keepalived.org/
Great article on keepalived and VRRP
Also see: related serverfault answer