the company i work for currently has 2 linux servers running under Debian that are being paid for.
One of them currently hosts multiple websites + mail services as well. The other linux currently is doing nothing.

Now we would like to have the strongest machine host the webservers and have mails as backup in case the second servers fails. Same thing with the weak machine, we'd like it to host the mails but still have websites in case the main server fails. If this is impossible, just having some kind of load balancing between both would be sufficient. Thanks for the help
PS.: Im still a rookie concerning linux so complete explanations would be appreciated

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.
If this question can be reworded to fit the rules in the help center, please edit the question.

1

This isn't the best starter project for a rookie.
–
ceejayozSep 16 '13 at 15:40

This doesn't help me much but thanks for the input, i still have to do it though
–
DexirianSep 16 '13 at 15:49

You really should consider discussing the project with whoever assigned it to you. Being asked to basically build a web/mail load balanced highly-available cluster as a newbie to Linux is setting someone up to fail. Maybe they don't realize it's a big task even for the professionals.
–
ceejayozSep 16 '13 at 15:54

Well in terms of time i have upcoming 3 months to complete this project, so i wouldnt mind taking the time to learn and what not, but sadly my sys admin isn't that advanced with linux either, and the server is already been bought so we want to at least use it in some way. Wouldn't there be a easier way to at least have some kind of functional setup?
–
DexirianSep 16 '13 at 15:57

Just showed this thread to my sys admin and he said word for word : Just so we understand each other, i dont want you to do it asap, i want you to learn it and understand how it works and then maybee we'll do it. So do you recommend any article or wiki or general knowledge page i should read ? That'd be of great help
–
DexirianSep 16 '13 at 15:59

1 Answer
1

FIRST: Get yourself an IP address that can be shared between the two servers. I'll explain why later.

Load balancing a web server involves a few steps:

Load balancing the requests

syncing the files

sharing session data.

We use software called HAProxy to do the load balancing of requests. You can use round robin DNS but you lose fault tolerance. We have network mounted storage that ensures both servers have access to current files. And finally, we use a memached server to store shared session data between Apache HTTPd instances.

With name dropping out of the way, here are your fundamentals:

You want one location to point requests to, an address that points to both web servers. The easiest way to do this is with round robin DNS. RRDNS though, is complicated to set up with fault detection and correction (IE: if server1 goes down, at least half of your requests will be un-servicable). The alternative to RRDNS is a shared (usually virtual) IP Address that is ideally on the same subnet (and your server generally have to be in the same data center, etc...) there are a lot of restrictions. Failing the above two options you get closer to a hardware load balancer. You don't have to go purchase an F5 Load balancer though, you can get away with a third VM, HAProxy, LVS, or something similar. This final option leaves you witha very critical single point of failure though.

Either way, your common entry point sits at the front line and generally proxies requests (A VIP with keepalived skips the proxy but something tells me you may not be [un]fortunate enough to have your two VMs in the same data center with a compatible network. From there, generally speaking, you want the applications involved to have an idea of what its brothers and sisters (Read: PEERS) are doing. Apache HTTPd needs Session data your mail servers can probably act independently but will have to point to shared mailboxes somehow.

Finally, serving the same image file from each server can be challenging depending on your infrastructure. You could do local (subnet) NFS mounts, or tunnel NFS through TLS over the internet (see: HIGH LATENCY) or rsync copies at agreeable intervals, etc. (This is probably the simplest problem to solve).

If you don't need true load balancing and just NEED a fail over solution that will kinda maybe still work (new logins, lost shopping carts, anything stored in session data), you could set a monitoring process and RNDC your DNS records (with a low Time to Live) to reflect the active (working) server. (Expect 10-120 second delays where requests are lost).

Luckily the mail system has redundancy built in. You can spin up another mail server get it all tested and working, and add an MX entry at your desired priority and it should kind of work. (Not dealing with imap/pop3/receiving mail here... just sending is drop dead simple).

I did a project like this as my final project for my undergrad degree. Setup our Central Authentication system in a load balanced, redundant, and fault tolerant environment. It took about a year to go from design to production. (That was one web application). You can probably do it quicker... but this is a MASSIVE undertaking if you are not adept at linux, familiar with networking principles (Can you carry on an intelligent conversation about layer 3 switching and application layer error checking?), and in general, willing to work long hours learning about things you never thought you cared about.

To answer some of the questions, yes i can prolly have an intelligent conversation regarding the OSI layers, ive got basic network admins courses, just that they cover linux very lightly, but go more into Microsoft. Also i am willing to work lots of hours regarding this projet as its pretty much all i have to do at the moment :P Now from all the options you proposed, the third one with a third VM hosting HAProxy / LVS sounds the best for our current needs. I take it we WILL have to purchase at least one additional machine to our current two? Also thanks again for the reply, really appreciated
–
DexirianSep 16 '13 at 17:08

Also if you don't mind me asking, would it be possible to contact you in any way apart from on this topic?
–
DexirianSep 16 '13 at 17:10

You'll want to address any specific questions to server fault in general. Better to have 50+ experts reviewing your issues than just 1.
–
lVlint67Sep 16 '13 at 17:21