ddh

Registered
Jun 6, 2007
1
0
151
The Netherlands
Hi,

I host a number of smaller websites on a Linux Cpanel VPS, and am looking into setting up a live mirror in a different datacenter. So far I understand this to require the following elements:

1. setup two identical servers (with at least the same software)
2. setup a dns failover, so that when the primary server becomes unavailable, it sends the traffic to server two.
3. setup dns synchronisation between the two cpanel servers
4. use rsync to sync the /home folder from server 1 to server 2. (like here)
5. setup mysql master-slave replication between server 1 and server 2. (like here)

(I gave the tuto's in the hope of perhaps helping others)

Now my questions, if you please:
1. Why should I use dns failover, and can't I simply have my 1st and 2nd nameservers point to server 1, and the 3rd and 4th to server two? This should ensure a seamless transition when server 1 becomes unavailable. But am I missing something here?
2. I'm wondering what to do with changes made on the second server, while the first one is down. For changes in the database (i.e. orders in a webshop), I guess I could setup a mysql master-master relationship (like here), but what if file changes are made on server two (i.e. the site owner updates a product image) is there any way to transfer those to server 1 when it becomes available again?

Can anyone please shed some light on my questions? Maybe I'm going about this in totally the wrong way, I'd love to hear that too.

Thanks!

David
 

Murtaza_t

Well-Known Member
Jan 24, 2005
474
0
166
Earth
cPanel Access Level
Website Owner
Hello,

It depends on what setup are you looking for..? whether you want to have a load balancing setup to shared traffic or a fail over setup.

If you are looking for a load balanced setup then you will need some additional scripts that will copy data to and fro as files will get updated simultaneously on both the servers... a bit complicated and not 100% reliable. In this case you will need to point the DNS to both the servers like "1st and 2nd nameservers point to server 1, and the 3rd and 4th to server two"

However from the information that you have provided.. I suppose you are looking for a fail over setup.. Here you will need the DNS on server 2 to take over only if the DNS on server 1 has gone down. You can use the MySQL master-master setup to copy the mysql data or can even use a SAN/NAS drives which will make your setup look a bit decent. And to copy data you will need to run a script on startup of server 1 to sync data from server 2 before taking over from it. I would recommend you to use server 2 as a backup of server 1 and it will only become active if server 1 is not available.. so that the traffic is flowing the either way and not 2 way at the same time.

You can refer this LINK for more help and advance setup.
 

hodfords

Active Member
Feb 22, 2002
43
1
308
Agreed. Moosa is right. The way DNS's work is that it's not always sequential

so if you have

ns1 - server1
ns2 - server1
ns3 - server2
ns4 - server2

A lot of the times server2 will get traffic even though it should serve as a "hot standby"

What we are concerned about now is how to sync stuff like:-

- Cpanel Theme
- Users / Groups created on master server
- exim config
- mail queue retry times
- WHM / Cpanel settings
- log files
etc etc

If somebody has a working version - would really appreciate if they could share it with us.... alternatively if we come up with something we will post details about how we did it...
 

Murtaza_t

Well-Known Member
Jan 24, 2005
474
0
166
Earth
cPanel Access Level
Website Owner
The Entire setup can be rSynced from one server to another along with file permissions and ownership.

The idea handling the DNS request is most important. As you cannot have 2 different IPs for your site. the site will not work for ISP who use their cache to resolve the website at the time when the main server is down.

This can be achieved by configuring a loopback adapter on the server. I can provide you the details if you let me know the exact requirement.