Debian Etch System Failover

Ill start by saying im new to debian... and a little bit more then a begginer with unix/linus OS.

 I want to setup a failover between two identical systems running the exact same software. One would be my main server with the live information and have the other machine kick in if the first machine fails. The software I am installing is called Hotspot Engine. It installs the OS and all their required services out of the box. The software has an SQL, Apache, Radius server installed. I would like to setup both machines from scratch.. Setup the failover then begin to update all my information. then test to see if the failover is working.

I have looked around the web and found a few places talking about HA clusters using heartbeat but from what i found those dont work well with SQL...

Then i found a site saying just setup an rysnc script that will automatically run every 15 minutes and copies all the different files between the two systems

So My question is... What is my best option.. and How do i do it?! Does anyone have a step by step guide?

I only have the two servers and dont have an extra to monitor the two desktops ( i saw a few sites that required that)

Also if i wanted to set it up so both machines accept from the same internal IP address and that also fails over.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexey KomarovChief Project EngineerCommented:
you could have a look at the linux virtual server
you need to be able to get a virtual IP which is shared by both servers.
you also need to get the filesystem in sync. The best way would be to have some shared storage like an nfs share that both servers can have access to.

If this is not possible you could use a heartbeat system with a script to reconfigure the failover server if the primary server is not accessable.
rsync is a pretty simple command to use.  Just note that if you are trying to sync your database files that if the first server fails and a database in the middle of a SQL write could result in database corruption.  I've been using rsync to backup my databases for quite some time now and have done several test restores without issue though...just wanted to give you forewarning in case you do use this method.  

I have a script below that is sufficient in copying new or modified files while deleting files that were deleted on your primary server as well.  I like to call this solution a "Hot Copy" of your primary server data.


-a = all files/folders
-v = verbose
-u = update (only copy updated or new files/folders)
--delete = delete any files from your Backup server if they no longer exist on your primary server
-e = execute a command line program
ssh = Secure SHell.  This will need to be enabled on both servers for this to work.  

NOTE - you will need to add ssh keys to each server to allow login without passwords.  here is a good link that I use regularly on how to do this:

save that into a shell script and place in your cron daemon.

you can place it into your cron daemon by executing:

crontab -e

This opens up an editor much like vi, vim, gedit, etc...  I am assuming you know most of the basic operators for these editors, but just in case, I have explained them on a step by step basis.
add this line to that file:

hit the "i" button on your keyboard (stands for "insert")

*/15 * * * *

save the file and exit. (press the "ESC" button, type ":w", then ":q" to exit the editor)

Please be sure to test the rsync script BEFORE adding it to the cron daemon to ensure desireable results...not to mention that the first go around will more than likely take longer than 15 minutes as you are copying everything over to your backup server from scratch.

That's it.  It gets a bit technical if you want to create your own script to do what you want to do, but overall have been please with the results of this script.  I haven't used it in an environment where you would need to run it every 15 minutes, so you might want to keep a close eye on it to be sure it's not going to take longer than 15 minutes to run.

Good luck!
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

The best method that I know of for your requirement is to use a combination of DRBD and Heartbeat. DRBD (Distributed Redundant Block Device) is a driver that replicates the blocks of on server's drive to a second system. The advantage is the sync happens at the block level, not the file system. The second has an exact copy at the lowest level, eliminating file system replication.

Heartbeat is a failover mechanism, that takes over control of starting/stopping of the apps. The systems share a virtual IP Address that points to the primary server. When the secondary detects that the system is down (no longer responding to "heartbeats", it will initiate a takeover and assume the resources of the primary. This all happens in 3-10 seconds.

Install a few virtual machines if you can and try it out.

you really dont want to use DRDB with mysql and failover. much of the data in mysql is in ram at various times, and booting a mysql off a blindly-copied mysql directory will result in errors in the DBs which
normally repair ok, but could be lost data, or mysql not starting at all.

i'd use mysql replication, personally. check the mysql HA link that someone posted above.

as for rsyncing frequently, check out lsyncd which is inotify + rsync tool. copies files when required
as opposed to every 15 minutes, tho DRBD would be more suitable/reliable for regular files if the system
is across high speed bandwidth (ie 100mbps+). if its distant (across internet) i'd use rsync/lsyncd

madunix (Fadi SODAH)Chief Information Security Officer Commented:
rsync is a good tool to build a relation between master and slave, for example my qmail server master and slave are replucated by
copying  these directories:
- - /home/vpopmail/
- - /var/qmail/control/
- - /var/qmail/alias
and other directories that exists in both the servers and needs to be replicated, using rsync command:
rsync -avz -e ssh -R /home/vpopmail user@host:/home/rsync/backupdir

on the otherhand it depends on you application, If the files and file systems are too heavey I/O _very_ busy or locked by applications copy/ftp/rsync... commands are not useful specially for DB and it is better to use mirror/shadow/standby features of database.
#  This script uses Rsync the backup files
#  to a remote server. To use this script
#  you first have to setup ssh to use keys.
#  This elimates the need for a password but
#  still provides security I have ssh on
#  a non standard port so I had to specify
#  the port (ssh -p 2998).
#  Simply change the variables list below
#  to match your specifications.
#  The Script also logs the transfer time.
#  For automated backup add script to crontab.
# Setup Variables
#The user you created with ssh_keys
STARTTIME=$(date +"%s")
# Verfiy the last rsync is not still running
if [ -f $LOCKFILE ]; then
ERRORTIME=$(date +"%d/%b/%Y:%H:%M:%S %Z")
echo "[$ERRORTIME] WARNING rsyncbackup.lock exists, aborting..." >> $LOGFILE
exit 1
# If it finished, create a new lock file
# The rsync command (for explanation type rsync --help)
rsync -aqrpogtu --delete --bwlimit=512 --rsh='ssh -p 22' $SOURCEPATH $DESTUSER@$DESTHOST:$DESTPATH 2>&1 >> $LOGFILE
# Log when the script was run
DONE=$(date +"%d/%b/%Y:%H:%M:%S %Z")
# Log how long it took the script to run
STOPTIME=$(date +"%s")
echo "[$DONE]finished: - Tranfer took:$(((SECONDS/60)/60)) hours $(((SECONDS/60)%60)) minutes $((SECONDS%60)) seconds" >> $LOGFILE
# Remove lock file

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Storage Software

From novice to tech pro — start learning today.