we need to setup one server=Linux+ WEB+MySQL+DNS and "maybe" cpanel on it and clients want that when this server fails, there is another one takeing over seamlessly and automatically, how to achieve this? load balancer? any cheaper software solution?
This is one of those cases, where you would probably be better off doing things right on the primary server. Setting up a "seemless" solution for your requirements isn't easy. More importantly it's not cheap either. Especially from a network side.
It's fairly easy to replicate data across servers, but getting the network side to seemlessly flipover is another story. I have had requests like this before. Once you explain the cost involved with doing it, the client all of the sudden isn't as interested in a "seemless" solution.
Assuming the server is in the same datacenter and you can get a virtual IP... look at rsync+scp to copy over web files between servers, mysql replication for the database, dns cluster in cpanel, and keepalived for IP failover. Good luck!
Domain Registration | Shared Hosting | Dedicated Servers | Colocation | Server Management http://web.com.ph
Doing what he said wht rsnyc, mySQL replication, and DNS. You could run 2 servers with different IPs. One the 2nd server setup a script that pings the primary server. If the script detects it as down, you could run a bash script that adds the primary servers IP on the second box.
You would have to setup your apache to listen on *:80 and *:443. If you have multiple IPs then it gets hairy though, but it's a simple solution (if done right) for doing what you want. If you have a ton of sites with different IPs and SSL certs then its get a lot more complicated.
For what it's worth, as long as you use good hardware and configure it correctly, you should have much downtime.
I did that for my hosting and the results are great (about 1-2 minutes to switch over). Just put OpenVZ virtual machines there on a DRBD storage. Once the failover happens, the same virtual system with the same MAC and IP starts on the secondary system. Pretty easy, but requires writing custom scripts and debugging-debugging-debugging
As for rsync/etc, many people who tried that path report problems. I didn't try to do this, but from what I hear, it is pretty troublesome. DRBD is inherently faster, as it works in kernelspace as a driver and operates with blocks, not files.
A simple way of doing it would be to use DRBD. The server in Primary mode would do all the serving, and writes to the hard drives would be synchronously sent to the Secondary server. If the main server fails, you just put the other server in Primary mode and start your services. You can put your DRBD resources on LVM volumes so that you can take periodic snapshots.
We do something similar, but with Xen VMs. If a Xen server fails, the VMs reboot on another server within minutes.