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.


Any help would be GREATTTTLY APPRECIATED!
gavin_goesAsked:
Who is Participating?
 
madunixCommented:
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.
#!/bin/bash
#  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
SOURCEPATH="/../source/"
DESTPATH="/../target/"
DESTHOST="10.6.40.81"
#The user you created with ssh_keys
DESTUSER="root"
LOCKFILE="/var/lock/rsyncbackup.lock"
LOGFILE="/var/log/rsyncbackup.log"
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
fi
# If it finished, create a new lock file
touch $LOCKFILE
# 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")
SECONDS=$(($STOPTIME - $STARTTIME))
echo "[$DONE]finished: - Tranfer took:$(((SECONDS/60)/60)) hours $(((SECONDS/60)%60)) minutes $((SECONDS%60)) seconds" >> $LOGFILE
# Remove lock file
rm -f $LOCKFILE
# END
#

Open in new window

0
 
Alexey KomarovChief Project EngineerCommented:
0
 
BrucematCommented:
you could have a look at the linux virtual server http://www.linuxvirtualserver.org/
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
bman21Commented:
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.

rsync -avu --delete /PRIMARY_SERVER/DATA/DIR/* -e ssh BACKUP_SERVER.YOURDOMAIN.COM:/BACKUP_SERVER/DATA/DIR/*

where
-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:  http://linuxproblem.org/art_9.html

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 * * * * rsync_shell_script.sh

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!
0
 
gmckeown99Commented:
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.

http://wiki.openvz.org/HA_cluster_with_DRBD_and_Heartbeat

HA:
http://www.drbd.org/users-guide/ch-heartbeat.html

http://www.linuxjournal.com/article/9074
0
 
mat5xCommented:
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



0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.