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.

link|improve this question
feedback

4 Answers

http://www.linuxvirtualserver.org/

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   1.2.3.4
Primary Server 1.2.3.5
Backup Server 1.2.3.6

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

link|improve this answer
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
feedback

Further to the orignal question, 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.

link|improve this answer
forge.mysql.com/wiki/MySQL_Proxy would allow your code to talk with a proxy that would send the requests to the server that was up. varnish-cache.org would be able to run and check the health of the web backend and serve responses from the webserver that was currently up. A 'director' type solution would be best, perhaps one of your VPS providers offers that as a service. – deleted Apr 15 '10 at 4:54
feedback

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

Cheers

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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