0

I need to reconfigure a prod env to provide hot failover for a db driven web app written in Perl that is currently running on an Apache HTTPD server, on a Linux OS.

The app is not designed to run in a cluster. Thus, if 2 instances of this app are connected to the same db and exposed to users via a NLB it would result in disaster (a logically corrupted db).

I would like to configure different db credentials for two app instances put under an Apache mod_proxy NLB installed on a 3rd machine. Normally, instance 2 would be shutdown and instance 1 would handle all the load. When something goes wrong with instance 1, I would need a script to send a shutdown command to instance 1, connect to the db and disable instance 1's db credential, restart the db server and finally start instance 2. If anything goes wrong in this chain of events I would be happy for the app to remain unavailable to users.

The problem is that I don't know of an easy way to configure this hot failover scenario. I would be happy to glue a shell script to mod_proxy but don't know if that's possible.

Can it be done without configuring an additional monitoring system that would detect the problem and trigger the required actions?

1 Answer 1

0

Why try to recreate the wheel? There are lots of perfectly good failover solutions with proven stability records. For example, use Pacemaker to control starting/stopping your services and Heartbeat to detect the health of you servers.

If all you're trying to guard against is failure of one of your Apache front-end servers then you could use a load balancer like haproxy instead. Haproxy can be configured to only use one server as a primary, a fall back to a single web server. Like so:

listen externalwww 10.0.1.186:80
        bind 10.0.1.186:443
        mode    tcp
        option  persist
        option  httpchk
        default-server  inter 5000
        server  external 33.44.55.66 check port 80 inter 15000 rise 10
        server  internal 10.0.1.49 check port 80 backup
4
  • Because neither of these is trivial to setup/configure. On the long run they are definitely the way to go. But I'm a dev, not a sysadmin and only need to provide a temporary solution. Ideally, I would like to piece together this solution ASAP and learning these specialized tools is non trivial to say the least.
    – bogdan
    Jan 28, 2013 at 16:43
  • You're going to spend more time piecing something together than it will take you to set up Pacemaker and Heartbeat. But how about haproxy? See my edit for an alternative solution.
    – longneck
    Jan 28, 2013 at 16:51
  • The core of my problem is that I need to run a script when the balancer detects failure. Only through a script I can ensure everything happens in the exact sequence that I need. Can haproxy run a script when it detects failure of a member server?
    – bogdan
    Jan 28, 2013 at 17:09
  • You're going to spend more time piecing something together than it will take you to set up Pacemaker and Heartbeat.
    – longneck
    Jan 28, 2013 at 17:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .