Forum Moderators: bakedjake

Message Too Old, No Replies

Redundant server question

         

ChrisDragonKni

5:44 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Excuse any stupid questions, I am a newbie :-)

I want to have 2 servers so that my website is mirrored on both of them, so that if one server breaks then the other will take over.

However my website has data files which are changed by the users extremely regularly, and therefore manually copying the files once a day or so is not good enough. What I need to do is basically set up a system for a directory on my server which will work a bit like a RAID 1 disk, i.e. when a modification is made to a file on server 1, then server 2 is automatically updated as well.

Most importantly though is that if server 1 died and server 2 carried on running, then when server 1 is fixed again, the data from server 2 must automatically update server 1. All this without any disruption to the members visiting my site.

The servers will be distributed geographically so I will need to use the internet rather than internal networks to sync the servers. However as both servers have internet connections of around 100Mbps this is not a problem.

I am running Apache on a Linux server.

Please tell me how I can keep 2 folders on 2 servers syncronised in this way.

Thankyou.

Tapolyai

5:53 pm on Jul 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is available from ISPs - at a seriously high cost.

The simplest, poor men's way of doing it -

Presumptions - Apache MySQL and PHP.

A cron job every five minuts dumps your DB, and zips the .sql and all the pages that changed up. Then FTP's the information to the secondary site.

The harder part is setting up a "cheap" way to manage the DNS - which points the visitor to the alternate site.

Best suggestion, use a self managed dynamic DNS provider. When the primary site goes down, the DDNS will point to the secondary site.

In the above, very crude and limited, solution the current connected users will loose their sessions, the information difference between the servers (in our example 5 minutes) will be lost. The DNS new information will also take a few minutes to expire from caches.

When the downed server comes back up, before going live, it should request an update, and sync with the other server, of course.

sja65

8:12 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



For your data - If you are using something like MySQL, use replication. For flat files, use rsync. Make your rsync domains small, and whenever there is an update in a domain, trigger a sync.

For failover - You can write a simple script to add the ip address of the failed machine to the working machine. You can even take over the mac address of the failed machine if you are directly behind a machine (like many cisco routers) that don't regularly update their arp tables. You can also use IPVS or round robin dns so you can be getting benefit out of both machines all of the time.

wheel

1:35 am on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've had my isp set up sja's suggestion in the past and believe it works well, inexpensively.

I think there's off the shelf software (hearbeat? - I dunno, I'm going from memory) that handles this setup.

SeanW

8:07 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



There are a few HA projects out there. O'Reilly had an article a while back about some simple ping scripts that would migrate a MAC/IP combo between two machines for HA.

Even RedHat AS in cluster mode is a bit kludgy, you need shared scsi or SAN disk for quorums, and they still end up doing address migration and such.

Whoever talked about rsync and mysql replication is bang on... That's the easiest way to do it.

Sean

freeflight2

10:12 pm on Jul 27, 2005 (gmt 0)

10+ Year Member



some ISPs offer "cluster" solutions with 2 servers and they are actually not that expensive ($300/mo or so)

I built my own failover system like this:
5 DB servers: 1 as master, 4 as slave - see replication in the mysql docs. if master fails one of the slaves takes over the master role.
6-8 web servers - most of the data resides in the mysql DB so they just randomly hit the slaves for selects and the master for writes (which then replicates all the data to the slaves). They are load balanced via DNS and with a small TTL of 300 so servers/IPs can be added / removed.
I also wrote a bunch of scripts to execute cmds on all machines at the same time and to rsync all file changes between them.