3

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).

Cyril N.
  • 624
  • 1
  • 10
  • 36

3 Answers3

4
  • 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
Stone
  • 7,011
  • 1
  • 21
  • 33
  • 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 03 '12 at 09:49
  • Yes, you should do a master/mater replication to the first server be able to catch up when comes back. – Stone Feb 03 '12 at 11:31
3

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!

Scrivener
  • 3,116
  • 1
  • 22
  • 24
1

It sounds like you need this solution: DRDB

lsimard
  • 41
  • 4
  • 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 02:22