I have two public load balanced webservers and one private database server.
The database server runs nfsd and is nfs mounted by the two webservers.

I am adding a backup database server so that when the master database fails,
the backup takes over.  No problems there.

The part I am having difficulty with is the nfs mounts.  It is no secret that
when the nfsd goes down, it becomes a headache to umount the directories that
relay on this.

I have tried everything that I have been able to find in my searching.  My
most successful attempt was like this:
- the two databases use carp and ifstated, when the master database fails and
the backup database takesover, it triggers a script in ifstated.
- The script will ssh into each webserver, umount the nfs mounts then mount
them again with the backup database as the target.

When the initial mount used "mount -t nfs ..." the umount would just hang.
When the initial mount used "mount_nfs -is ..." the umount would work only
sometimes, with no obvious pattern of when it would work or not.

I will consider any suggestion, or alternative.  Is OpenAFS an option?
I am just looking for a way to have failover for network file storage.

Thanks,
- Tom

-------------------------------------------------------

# cat /etc/ifstated.conf
init-state auto

carp_up = "carp0.link.up && carp1.link.up"
carp_down = "!carp0.link.up || !carp1.link.up"

state auto {
        if $carp_up
                set-state master
        if $carp_down
                set-state backup
}

# in this state we are the master mysql server, and the nfs mount
state master {
        init {
                # start nfs posse
                #run "/usr/sbin/portmap"
                #run "echo -n>/var/db/mountdtab"
                #run "/sbin/mountd"
                #run "/sbin/nfsd -tun 4"

                #run "/bin/sleep 20"

                # go through each client using our nfsd and umount them
                #  from their current nfs mounts and remount them using us
                run "/etc/ifstated_scripts/remount_nfs.sh"

                # let things settle
                run "/bin/sleep 20"
        }

        if $carp_down
                set-state backup
}

# in this state we are just waiting to take over
state backup {
        init {
                # stop nfs posse (in reverse order)
                #run "ps -acx | grep nfsd | awk '{print $1}' | xargs kill "
                #run "kill -TERM `cat /var/run/mountd.pid`"
                #run "ps -acx | grep portmap | awk '{print $1}' | xargs kill
"

                # let things settle
                run "/bin/sleep 20"
        }

        if $carp_up
                set-state master
}

--------------------------------------------------------

# cat /etc/ifstated_scripts/remount_nfs.sh
#!/bin/sh

# when using master nfs server, ip=192.168.20.32
# when using backup nfs server, ip=192.168.20.31
# webserver (nfs-client) ips = 192.168.20.12, 192.168.20.11

# the same test directory exists on all nfs-server and nfs-client servers
# /backup/nfs_test_mount

NFS_SERVER_IP=192.168.20.32

SSH=/usr/bin/ssh
MOUNT=/sbin/mount_nfs
UMOUNT=/sbin/umount
SLEEP=/bin/sleep
ECHO=/bin/echo

# list all directories that haves to me umount'd
NFS_MOUNTS="/backup/nfs_test_mount"

for machine in 192.168.20.12 192.168.20.11
do

        $ECHO "Logging into $machine ... ";

        for directory in $NFS_MOUNTS
        do
                NFS_UNMOUNT="$UMOUNT -f $directory"
                NFS_MOUNT="$MOUNT -si $NFS_SERVER_IP:$directory $directory"

                $ECHO "- unmounting $directory"
                $SSH [EMAIL PROTECTED] "$NFS_UNMOUNT"

                $ECHO "- sleeping zZzZ"
                $SLEEP 20

                $ECHO "- mounting $directory"
                $SSH [EMAIL PROTECTED] "$NFS_MOUNT"
        done

done
_________________________________________________________________
Spell a grand slam in this game where word skill meets World Series. Get in
the game.
http://club.live.com/word_slugger.aspx?icid=word_slugger_wlhm_admod_april08

Reply via email to