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 actually own two linux web servers and I was wondering how I could make them work together in case one goes down.

From what I found, cluster seems to be the closest, because it would replicate the data (for mysql as example) from srv1 to srv2, and vice-versa.

I found a howto on HowToForge, but they talk about 4 servers. After reading, it seems legit, because the cluster need a server to synchronise the data (and a second server in case the first goes down!).

So it's not what I'm looking for, or eventually not in that way.

What I'd like would be that srv1 & srv2 are identical (mysql and apache files) in case srv1 goes down.

The aim at the end will be to build a FailOver (and not a LoadBalancing) system. For the IP, I will switch it manually from my registrar.

Is it possible to do it with only two servers?

Thanks for your help !

(If I was not clear, I'm sorry, It's not really clear in my mind too).

share|improve this question
1  
Yes, look into master-master replication. –  ceejayoz Jan 13 '12 at 19:00

3 Answers 3

up vote 4 down vote accepted
  • Mysql can replicate so it is done.
  • For the files you can use some cluster filesystem like GlusterFS or you can clone partitions with drbd
  • For the IP failover you can use ucarp
share|improve this answer
    
You say that Mysql can replicate, but with just two servers, I'll have to do a Master/Master replication, or I missed something? –  Cyril N. Feb 3 '12 at 9:49
    
Yes, you should do a master/mater replication to the first server be able to catch up when comes back. –  Stone Feb 3 '12 at 11:31

Yes, you can certainly do replication with only two servers. You will need to make sure that whatever code your webserver is running is up to date on both servers - don't just update the live one, or it will be out of date if you have to fail over!

You will need to replicate MySQL in a master/master system, however, that can be a little bit tricky to setup. Master/slave replication is much easier, but your system will not be able to perform writes if it fails over to the slave. You would need to make sure to configure your software to fall into a read-only mode on the secondary system. There are various guides for both master-master and master-slave replication.

As for DNS based fail over, make sure your TTL is low. Remember, it will take at least around one TTL to fail over to the secondary server. This will increase the load on your DNS servers. You may also want to investigate alternate DNS systems that are built for failover and can do that automatically for you.

Good luck!

share|improve this answer

It sounds like you need this solution: DRDB

share|improve this answer
    
Welcome to Serverfault! It's considered bad practice to just post a link as an answer. We would prefer it if you posted a summary of the solution in the answer, with attribution to any links. The aim is to have SF a repository of answers, rather than links to answers. Thanks –  pauska Jan 14 '12 at 2:22

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.