LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-04-2013, 09:53 AM   #1
lp449
Member
 
Registered: Oct 2004
Location: Olsztyn, Poland
Distribution: Debian Squeeze / CentOS 6
Posts: 60

Rep: Reputation: 15
Webserver failover (over WAN)


Hello!

Company I work for has a webserver hosting a website based on PHP and MySQL, the service is located on a dedicated server in one of datacenters. My boss wants me to think of a solution of a problem when the server goes down. We also have another server in some other datacenter (in different location) that could possibly act as a backup. What would you recommend (from your own experience) me to do to have such failover with database replication ... so probably active backup?

Any help would be appreciated

Last edited by lp449; 03-04-2013 at 09:54 AM.
 
Old 03-04-2013, 10:25 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by lp449 View Post
Hello!

Company I work for has a webserver hosting a website based on PHP and MySQL, the service is located on a dedicated server in one of datacenters. My boss wants me to think of a solution of a problem when the server goes down. We also have another server in some other datacenter (in different location) that could possibly act as a backup. What would you recommend (from your own experience) me to do to have such failover with database replication ... so probably active backup?

Any help would be appreciated
Maybe...such things are typically thorny problems, especially when WAN's are involved. You could set up heartbeat on the backup server, to fail the services over to the backup when contact with the primary is lost, which is (ideally) what you want. The problem arises in that it's on a WAN....if the cable at your datacenter going to that section of the WAN is disconnected, it fails over....when the server at the other end isn't down. Now you have TWO servers running the same site/database at the same time.

If you've got a fairly bulletproof network, and your WAN speed is good, I'd set up heartbeat to monitor things. Based on the MySQL database, I'd also make sure to have it replicated SOMEHOW (dump file copied to the backup server a few times a day? MySQL cluster? ), and have a script ready to import that data to the backup server's database, before it brings up the web engine. Obviously, copying the PHP/web pages would have to be done on a daily basis too, so that any changes to the production server are mirrored.

In an IDEAL world, you'd have all of this on a SAN, and have it replicated between locations, and just have to mount the drive.
 
1 members found this post helpful.
Old 03-04-2013, 10:42 AM   #3
lp449
Member
 
Registered: Oct 2004
Location: Olsztyn, Poland
Distribution: Debian Squeeze / CentOS 6
Posts: 60

Original Poster
Rep: Reputation: 15
Thanks for the reply TB0ne! Yeah, I thought of heartbeat or pacemaker but I'm not sure it would work good over WAN. There's another problem ... database stores personal data, so to transfer it over WAN I should probably think of deploying some kind of a VPN connection between the servers. Another thing I think of is to use lsyncd + MySQL replication (Master / Master) over such VPN connection and on top of it I could just try round-robin DNS failover (two A records for domain). What do you think of that?
 
Old 03-04-2013, 12:48 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by lp449 View Post
Thanks for the reply TB0ne! Yeah, I thought of heartbeat or pacemaker but I'm not sure it would work good over WAN. There's another problem ... database stores personal data, so to transfer it over WAN I should probably think of deploying some kind of a VPN connection between the servers. Another thing I think of is to use lsyncd + MySQL replication (Master / Master) over such VPN connection and on top of it I could just try round-robin DNS failover (two A records for domain). What do you think of that?
Yes, that could definitely work. However, when you get into VPN connections, etc., there is going to be an admin cost involved in the time taken to set it up, document it, and keep it maintained later. Might be better to go low-tech in a way, but when you say WAN, do you mean the Internet, or a company-paid-for dedicated WAN? If it's your own circuit, you shouldn't have to worry too much about a VPN or security methods, since you (ostensibly), OWN the connection.

You could write some simple scripts to do this, as an alternative. On the primary system:
  • The script will take a MySQL dump of your database, grab a copy of your web page(s), tar it all up, then PGP encrypt it and SCP it over to the backup system.
On the backup system:
  • A script will verify the primary is up. You can do this with wget, curl, or even a simple ping. If it fails, decrypt the tar file, restore the MySQL data, copy the web pages into place, and bring up MySQL and http.
Neither will be too difficult to write, and easy to maintain. If you're not looking for INSTANT failover, and would be happy with a couple of minutes, it shouldn't be too complicated.
 
Old 03-04-2013, 01:06 PM   #5
lp449
Member
 
Registered: Oct 2004
Location: Olsztyn, Poland
Distribution: Debian Squeeze / CentOS 6
Posts: 60

Original Poster
Rep: Reputation: 15
I'd definitely be happy with a couple of minutes with failover. Unfortunately by "WAN" I mean the Internet and as for now there is no chance of getting any dedicated circuits (mainly because of their costs). You get me right - I want something that would be easy to maintain and doesn't take too much time to get it running. What matters here the most is good performance and the most important - security (personal data).
 
Old 03-04-2013, 04:16 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by lp449 View Post
I'd definitely be happy with a couple of minutes with failover. Unfortunately by "WAN" I mean the Internet and as for now there is no chance of getting any dedicated circuits (mainly because of their costs). You get me right - I want something that would be easy to maintain and doesn't take too much time to get it running. What matters here the most is good performance and the most important - security (personal data).
I'd script it myself then, and keep it simple. Should only really be a few commands, and you can cron it to run the backup/transfer a few times a day. If you PGP encrypt the tar file, you'll be fairly secure, and if you use a keyswapped scp command, that'll not only be easy to script, but fairly secure too. That'll get your data to the other machine. From there, it's just a matter of decrypt/decompress/load, and fire up the services.
 
Old 03-04-2013, 09:43 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Unless I'm missing something, I don't get the pgp bit. scp is encrypted anyway and the OP has control over the 2 servers...
 
Old 03-05-2013, 02:15 AM   #8
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Aside from the replication (use a IPSEC VPN between data-centers!) use an external DNS provider/monitoring company to monitor the primary and then alter DNS accordingly if it fails.

Our provider has very low (<30 second) TTL/Cache times defined for our DNS entries. On the few occasions we've needed it it's been very responsive.
 
Old 03-05-2013, 10:49 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by chrism01 View Post
Unless I'm missing something, I don't get the pgp bit. scp is encrypted anyway and the OP has control over the 2 servers...
I only mentioned it because the OP wanted more security, and it's a trivial thing to script. You are right...it is optional, and scp encryption should be fine. But the OP did say that while they have control over the servers, they are using the Internet to connect them.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
load balancing / wan failover fdelval Linux - Networking 4 07-23-2010 08:13 PM
Dual WAN failover kool_kid Linux - Networking 3 07-16-2010 08:26 AM
Failover with webserver with private SSL certs svancouw Linux - Server 2 10-23-2007 05:00 PM
Webserver Failover using RH5 Jimerson Red Hat 3 08-14-2007 12:57 PM
webserver failover imi@tux Linux - Networking 1 05-23-2006 02:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration