Is there a way to perform the following under Linux:

  1. There are two web servers, main and backup
  2. There are two database servers (postgres), main and backup
  3. Web Servers are in sync with each other, ie. configuration/content/applications are the same
  4. Backup database is continuously synced up with main database.
  5. If either of main servers goes down, it's being replaced with backup one on the fly.
  6. When main database server goes back up, all the data from backup server is uploaded to it.

To make it more complex, an important detail is that the two servers are actually VPS and they are hosted in different countries by diferent providers, so none of the obvious solutions for servers in the same subnet/rack etc are going to work here.

Essentially, I need the hot swapping working automatically with no or minimal user intervention, if possible. Recovery procedure is preferably automatic but can include some manual steps.



would allow you to put a load balancer (or better, two) in front of your production and backup servers.

You could use heartbeat alone which would allow a public IP to be served by two IPs. It would have to sense the primary or secondary going down, and then would send out an announcement to become that public IP.

You would have something like:

Public IP
Primary Server
Backup Server

Everyone would see the single IP which would be served virtually by whichever machine was 'active'

  • it does not seem to mention DB sever hot swapping, can it do that? – Art Apr 15 '10 at 3:29
  • Yes, you can do the same with your SQL servers. heartbeat runs a virtual IP that is served by the 'active' server. – deleted Apr 15 '10 at 4:09
  • linux-ha.org/wiki/Main_Page for heartbeat. – deleted Apr 15 '10 at 4:10

Look into haproxy or Nginx as the frontend load balancer. This will monitor and redirect traffic from your primary to your backup server if primary goes down or vice versa aka automatic fail-over.

For the data syncing between your database, look into multi-master replication.

|improve this answer|||||

You should probably look at DNS failover for the web tier and perhaps Tungsten Cluster for the DB tier.


|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.