7

I currently administer a small web server running ubuntu linux with apache, mysql, and ssh. I'm backing it up using rsync to another server, but I'm backing it up to a /backup directory.

I'd like to have it set up where if the first server goes down I can change the ip of the second server and have all the users, files, databases etc. ready to go.

Does anyone have any suggestions on the easiest / best way to go about this?

Considerations

  • Users
  • Databases
  • Apache Configuration
  • Files
  • Making sure the same software is installed on both boxes. (probably need to do this up front)
ScArcher2
  • 623
  • 1
  • 7
  • 9

4 Answers4

1

For file based services (a web server etc.) rsync can effectively keep the second server up to date - (users, configs etc) - when it comes to databases things get a bit more complex (I've used MySQL and a slave server for this and it was very effective, I've also used PostgreSQL in a few HA/standby configurations but it was way more clumsy)

This, combined with a bit of IP theft (a quick script to assign the IP of the failed machine to the interface of the backup machine) can make for a relatively straighforward setup but allow quick recovery.

Just one thing to consider - beware of the failback. Moving services to a backup machine is one thing, moving them back once you've corrected the failure can get hairy, pay close attention to the databases.

LinuxHA is a (somewhat heavyweight) approach to this if you decide to make it a bit more automated

http://www.linux-ha.org/

Mark Regensberg
  • 1,411
  • 12
  • 14
1

You can use rsync or drbd to keep your backup server in sync, or mount your data via nfs from a 3rd server. If you want to keep it simple, I would back up to the same directory locations on the backup server as the source server.

heartbeat2 is a good solution for managing the IP addresses and provides tools for automatic or manual failover - and takes into consideration arp cache flushing and other things that I wouldn't have thought of.

Brent
  • 22,857
  • 19
  • 70
  • 102
0

I believe heartbeat will do this for you, but if you don't use it, I recommend manually setting up a virtual IP for the web server.

Each web server will have its own real IP and also a virtual IP. The virtual IP is only assigned to a machine when it is the active web server.

This setup means that ssh, rsync and all other tools can continue running on the real IPs without being confused by a changing IP address.

Zan Lynx
  • 906
  • 5
  • 13
0

Virtualisation can help here. You can have 2 servers running as host servers, both with a single virtual server ready to go. The live server has the virtual server running, while the backup server has it's virtual server "turned off" but can still access the file system of that server.

Then you can do regular rsyncs from the live virtual server to the backup virtual server. If the live server goes down, you just need to start the backup virtual server.

The details depend on which virtualisation software you use (I've done this with linux-vserver before), but some important points are:

  • you will need to exclude some settings - IP address in particular.
  • test your set up when things are working - you need to know it works
  • have DNS set up for both eg www1.mysite.com and www2.mysite.com with www.mysite.com being a round robin for www1 and www2
  • you could even look into some sort of heartbeat service to automatically start the backup server, but that may be overly complex unless downtime is really expensive.
Hamish Downer
  • 9,420
  • 6
  • 38
  • 51