Ubuntu – Getting heartbeat to fallover when apache service fails

apache-2.2failoverheartbeatUbuntu

I've currently got heartbeat set up nicely on ubuntu linux server so that if the heartbeat service is not detected (either because the server is down or just the heartbeat service is down) it fallsover to the secondary server as described in a blog post on my site.

alt text

So we start at the initial state, apache on the working server dies in the interim state, then apache on the secondary server starts in the final state.
Currently if apache fails but heartbeat doesn't the switch over doesn't occur.
Does anyone know how to do this?

Best Answer

One potential solution for monitoring daemons with heartbeat 1.x that I've used successfully in production is to have a perl daemon that polls the process list at an interval and if it doesn't see the process name, it initiates the heartbeat standby. You could configure mon to duplicate this functionality.

Heartbeat 2.x has native support for this functionality and the ocf_heartbeat_apache resource agent will allow you to monitor the process.

It is also notable that heartbeat is in maintenance only mode and that Corosync is supposed to succeed it.

Where possible, I avoid the active/passive approach to high availability with Web or application servers. It wastes resources and it's often more difficult to scale horizontally. There are some situations where this is unavoidable but with Apache, this is rarely the case.

Your Web application would need to share session state, which is often accomplished by storing the sessions either in a database or in memory. At this point, you can load balance all incoming connections using a solution such as LVS or Nginx. Of course, your proxy and load balancing solution would need to be redundant to prevent a single point of failure. You could use heartbeat for this as well.