Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)
share|improve this question

4 Answers 4

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.
share|improve this answer

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/

share|improve this answer
    
+1 to Heartbeat –  Stewart Robinson May 1 '09 at 8:19

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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