I will soon need to setup a database server on a budget. We are planning to use Postgres on Ubuntu (most likely) and we'd like to have a backup server. For replication, I think I'll just use Postgres's Streaming Replication. It does all that I need and is simple to set up.
But what if the main server fails and we need the backup? Is there a way to route data to the backup without a third computer?
Let's say my main computer has the domain name PG-MAIN
and my backup has the domain name PG-BACKUP
. If I had a third computer I could (for example) check to see if PG-MAIN
is up and if it is down, rename PG-BACKUP
to PG-MAIN
. Then, any query sent to PG-MAIN
would still succeed. Maybe that would be a bad solution. I don't actually know. (Although this Server Fault answer says it's a bad idea to use DNS that way.)
But is there a way for the backup to silently take the place of the main computer upon failure without the use of a third computer? I can't think of anything. And by "failure", I mean like the database daemon stops responding or a piano falls on the computer.
If it turns out to be absolutely, positively impossible, what would be cost-effective way of handling the fallback? The client applications will be custom-made. Should the logic of fallback part of the system be handled by the client applications? (That last part sounds like a very bad idea.)
0 Answers