Mailing List Archive

Software RAID HA Resource Script
Hello Alan, et al.

I've been playing with Software RAID in a high availability setup and
thought I would contribute this example RAID script back to the
heartbeat project. I'm currently working with kimberlite,
(http://oss.missioncriticallinux.com) but I mocked up this script as a
proof of concept.

I've got some STONITH hardware that works with DB-9 serial ports
coming in "Real Soon Now" they tell me that I will probably contribute
patches for as well:


Western Telematics RPC10 (do you support that already? http://www.wti.com/)
Nightware RPC100S (http://www.nightware.com/)
An 'EMB port' on an industrial PC platform (don't have a URL)

-Eric.

#!/bin/bash
#
# Example Linux RAID high availability RAID resource script
#
# Author: Eric Z. Ayers <eric.ayers@compgen.com>
#
# License: Copyright 2000, Computer Generation Incorporated.
# You are free to use and modify this file. You are also free
# to redistribute this file and any changes you make.
#
# You are encouraged to submit modifications/updates to
# linux-ha-dev@lists.tummy.com
#
# This script is an example start/stop script for a
# high availability RAID resource.
#
# Note, I hardcoded config variables at the top of the script. It might
# be more "elegant" to pass these in as parameters, but that was too much
# like hard work for me.
#
# This script assumes you are running linux kernel 2.2.X with
# the RAID MD driver version 0.90 or better for help with linux Software
# RAID, see the Software RAID howto or try the Linux RAID mailing list:
# linux-raid@vger.kernel.org
#
# You might need to pass the command line parameter: raid=noautodetect
# in an HA environment so that the kernel doesn't automatically start
# up your raid partitions when you boot the node. This means that it isn't
# going to work to use RAID for the system disks and the shared disks.
#
# 0) partition the disks to use for RAID
# 1) Create /etc/raidtab.md? on both systems (see example file below)
# 2) Initialize your raid partition with
# /sbin/mkraid --configfile /etc/raidtab.md? /dev/md?
# 3) Format your filesystem
# mke2fs /dev/md0
# 3) Create the mount point on both systems.
# DO NOT add your raid filesystem to /etc/fstab
# 4) copy this script (to /etc/rc.d/init.d if you wish) and edit it to
# reflect your desired settings.
# 5) Modify the heartbeat 'haresources' setup file
# 6) unmount the filesystem and stop the raid device with 'raidstop'
# 7) fire up heartbeat!
#
#
# EXAMPLE config file /etc/raidtab.md0
# This file must exist on both machines!
#
# raiddev /dev/md0
# raid-level 1
# nr-raid-disks 2
# chunk-size 64k
# persistent-superblock 1
# #nr-spare-disks 0
# device /dev/sda1
# raid-disk 0
# device /dev/sdb1
# raid-disk 1
#


MD=md0
MOUNTPOINT=/data1 # where the filesystem should be mounted
SCSI_MODULE=0 # set to 1 if there is a SCSI module to be loaded
RAID0_MODULE=0 # set to 1 if there is a RAID0 module to be loaded
RAID1_MODULE=1 # set to 1 if there is a RAID1 module to be loaded
MDDEV=/dev/$MD # Device name for RAID block device


# Utilities used by this script
MODPROBE=/sbin/modprobe
FSCK=/sbin/fsck
FUSER=/sbin/fuser
RAIDSTART=/sbin/raidstart
MOUNT=/bin/mount
UMOUNT=/bin/umount
RAIDSTOP=/sbin/raidstop


function check_util {
if [ ! -x "$1" ] ; then
echo "ERROR: setup problem: Couldn't find utility $1"
exit 1
fi
}

check_util $MODPROBE
check_util $FSCK
check_util $FUSER
check_util $RAIDSTART
check_util $MOUNT
check_util $UMOUNT
check_util $RAIDSTOP

# Look for the 'start' or 'stop' argument
case "$1" in

#
# Start up the RAID device and mount the filesystem
#
start)

$MOUNT | grep -e "^$MDDEV" >/dev/null
if [ $? -ne 1 ] ; then
echo "ERROR: Device $MDDEV is already mounted!"
exit 1;
fi


# Insert SCSI module
if [ "$SCSI_MODULE" -gt 0 ] ; then
$MODPROBE scsi_hostadapter
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't insert SCSI module."
exit 1;
fi
fi

# Insert raid personality modules
if [ "$RAID0_MODULE" -gt 0 ] ; then
$MODPROBE raid0
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't insert RAID0 module"
exit 1
fi
fi
if [ "$RAID1_MODULE" -gt 0 ] ; then
$MODPROBE raid1
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't insert RAID1 module"
exit 1
fi
fi

# Run raidstart to start up the RAID array
$RAIDSTART --configfile /etc/raidtab.$MD $MDDEV
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't start RAID for $MDDEV"
exit 1
fi

# Check the filesystem & auto repair
$FSCK -a $MDDEV

# NOTE: if any errors at all are detected, it returns non-zero
# if the error is >4 then there is a big problem
if [ $? -ge 4 ] ; then
echo "ERROR: Couldn't sucessfully fsck filesystem for $MDDEV"
exit 1
fi

# Mount the filesystem
$MOUNT $MDDEV $MOUNTPOINT
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't mount filesystem for $MDDEV on $MOUNTPOINT"
exit 1
fi

;;

stop)

# See if the MD device is mounted
$MOUNT | grep -e "^$MDDEV" >/dev/null
if [ $? -ne 1 ] ; then

# Kill all processes open on filesystem
$FUSER -mk $MOUNTPOINT

# the return from fuser doesn't tell us much
#if [ $? -ne 0 ] ; then
# echo "ERROR: Couldn't kill processes on $MOUNTPOINT"
# exit 1;
#fi

# Unmount the filesystem
$UMOUNT $MDDEV
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't unmount filesystem for $MDDEV"
exit 1
fi
else
echo "WARNING: Filesystem $MOUNTPOINT not mounted?"
fi


# Turn off raid
$RAIDSTOP --configfile /etc/raidtab.$MD $MDDEV
if [ $? -ne 0 ] ; then
echo "ERROR: Couldn't stop RAID for $MDDEV"
exit 1
fi

;;

*)
echo "This script should be run with the argument 'start' or 'stop'"
exit 1
;;
esac

# If you got to this point, chances are everything is O.K.
exit 0;


# Revision History
# $Log: ha_raid1.sh,v $
# Revision 1.1 2000/08/24 16:25:09 eric
# Initial revision
#
#
Software RAID HA Resource Script [ In reply to ]
Hi Eric,

"Eric Z. Ayers" wrote:
>
> Hello Alan, et al.
>
> I've been playing with Software RAID in a high availability setup and
> thought I would contribute this example RAID script back to the
> heartbeat project. I'm currently working with kimberlite,
> (http://oss.missioncriticallinux.com) but I mocked up this script as a
> proof of concept.

Great! I can drop it into the release. Someone else sent me something that I
forgot to include (oops!). Guess I'd better look around for it. Have you
actually tried this with heartbeat then?

Is there a reason you didn't license it under the GPL?

> I've got some STONITH hardware that works with DB-9 serial ports
> coming in "Real Soon Now" they tell me that I will probably contribute
> patches for as well:
>
> Western Telematics RPC10 (do you support that already? http://www.wti.com/)
> Nightware RPC100S (http://www.nightware.com/)
> An 'EMB port' on an industrial PC platform (don't have a URL)

This is the device that Kimberlite supports, right?

No, I only have a fancier device from BayTech. What does this device cost?

Thanks!

-- Alan Robertson
alanr@suse.com
Software RAID HA Resource Script [ In reply to ]
Alan Robertson writes:
> Hi Eric,
>
> "Eric Z. Ayers" wrote:
> >
> > Hello Alan, et al.
> >
> > I've been playing with Software RAID in a high availability setup and
> > thought I would contribute this example RAID script back to the
> > heartbeat project. I'm currently working with kimberlite,
> > (http://oss.missioncriticallinux.com) but I mocked up this script as a
> > proof of concept.
>
> Great! I can drop it into the release. Someone else sent me something that I
> forgot to include (oops!). Guess I'd better look around for it. Have you
> actually tried this with heartbeat then?

Yes, I have tried it with heartbeat. It's sitting in
/etc/ha.d/resource.d/ and configured in my haresources right now. It
doesn't make any heartbeat specific error logging calls (like ha_log
instead of echo), though. I've been running it standalone to test
the different RAID-1 recovery scenarios. I'll writeup my "disk killer"
hardware a little later.

> Is there a reason you didn't license it under the GPL?

Basically, I don't really care. The GPL scares away some people who want
to modify something and sell it as a commerical product. Like, for
example, we'd like to link in libreadline into one of our products,
but we don't want to give away our source code. But really, I
shouldn't have even bothered. I mean, come on! It's just a script! I
don't care how you use it and I don't want to force someone to make
their modifications GPL as well. But if you want to copy it and
re-distribute your changes under GPL, that's fine by me. If there is
some reason you want me to say, "GPL" on it then I will do that. The
only reason I put a 'copyright' line on there is that I didn't want someone to claim it was proprietary to them.

> > I've got some STONITH hardware that works with DB-9 serial ports
> > coming in "Real Soon Now" they tell me that I will probably contribute
> > patches for as well:
> >
> > Western Telematics RPC10 (do you support that already? http://www.wti.com/)
> > Nightware RPC100S (http://www.nightware.com/)
> > An 'EMB port' on an industrial PC platform (don't have a URL)

(What I meant to say is that these are 3 different devices)

> This is the device that Kimberlite supports, right?

the WTI RPC-10 is the device that kimberlite supports, yes.

> No, I only have a fancier device from BayTech. What does this
> device cost?

The first 2 are in the $150 range. The third one is integrated into
the motherboard, kind of like Intel's EMP port on their high end
server motherboards. For all I know, this thing I'm getting IS an
Intel motherboard, but I haven't seen it yet.

-ERic.
Software RAID HA Resource Script [ In reply to ]
"Eric Z. Ayers" wrote:
>
> Alan Robertson writes:
> > Hi Eric,
> >
> > "Eric Z. Ayers" wrote:
> > >
> > > Hello Alan, et al.
> > >
> > > I've been playing with Software RAID in a high availability setup and
> > > thought I would contribute this example RAID script back to the
> > > heartbeat project. I'm currently working with kimberlite,
> > > (http://oss.missioncriticallinux.com) but I mocked up this script as a
> > > proof of concept.
> >
> > Great! I can drop it into the release. Someone else sent me something that I
> > forgot to include (oops!). Guess I'd better look around for it. Have you
> > actually tried this with heartbeat then?
>
> Yes, I have tried it with heartbeat. It's sitting in
> /etc/ha.d/resource.d/ and configured in my haresources right now. It
> doesn't make any heartbeat specific error logging calls (like ha_log
> instead of echo), though. I've been running it standalone to test
> the different RAID-1 recovery scenarios. I'll writeup my "disk killer"
> hardware a little later.

Great! Thanks!

> > Is there a reason you didn't license it under the GPL?
>
> Basically, I don't really care. The GPL scares away some people who want
> to modify something and sell it as a commerical product. Like, for
> example, we'd like to link in libreadline into one of our products,
> but we don't want to give away our source code. But really, I
> shouldn't have even bothered. I mean, come on! It's just a script! I
> don't care how you use it and I don't want to force someone to make
> their modifications GPL as well. But if you want to copy it and
> re-distribute your changes under GPL, that's fine by me. If there is
> some reason you want me to say, "GPL" on it then I will do that. The
> only reason I put a 'copyright' line on there is that I didn't want someone to claim it was proprietary to them.

Actually, they can do just that even with the copyright line, because they
don't have to distribute source (which would include the copyright line).
And being public domain, they don't even have to include the copyright line
if they redistribute it. That's what it means to say "public domain". It
means the author has no control at all any more.

And when they modify it, you get no benefit. You might have to turn around
and buy it from someone who has modified it. Of course, as you pointed out
in this particular example, it isn't that big a deal.

However, it does complicate things a tiny bit if I want to package it with
heartbeat, because everything else is licensed either GPL or LGPL. Now I
have to say some parts GPL, some LGPL, and some are public domain.

> > > I've got some STONITH hardware that works with DB-9 serial ports
> > > coming in "Real Soon Now" they tell me that I will probably contribute
> > > patches for as well:
> > >
> > > Western Telematics RPC10 (do you support that already? http://www.wti.com/)
> > > Nightware RPC100S (http://www.nightware.com/)
> > > An 'EMB port' on an industrial PC platform (don't have a URL)
>
> (What I meant to say is that these are 3 different devices)
>
> > This is the device that Kimberlite supports, right?
>
> the WTI RPC-10 is the device that kimberlite supports, yes.
>
> > No, I only have a fancier device from BayTech. What does this
> > device cost?
>
> The first 2 are in the $150 range. The third one is integrated into
> the motherboard, kind of like Intel's EMP port on their high end
> server motherboards. For all I know, this thing I'm getting IS an
> Intel motherboard, but I haven't seen it yet.

But what I remember is that the Western Telematics device only controls one
machine. So, you need at least two for a cluster.

So, the $400 (I think) for the RPC5-15 from BayTech which controls 4
machines and has an ethernet interface sounds more reasonable than it
might first appear.

-- Alan Robertson
alanr@suse.com
Software RAID HA Resource Script [ In reply to ]
Alan Robertson writes:
...
>
> Actually, they can do just that even with the copyright line, because they
> don't have to distribute source (which would include the copyright line).
> And being public domain, they don't even have to include the copyright line
> if they redistribute it. That's what it means to say "public domain". It
> means the author has no control at all any more.
>
> And when they modify it, you get no benefit. You might have to turn around
> and buy it from someone who has modified it. Of course, as you pointed out
> in this particular example, it isn't that big a deal.
>
> However, it does complicate things a tiny bit if I want to package it with
> heartbeat, because everything else is licensed either GPL or LGPL. Now I
> have to say some parts GPL, some LGPL, and some are public domain.

OK, I'll GPL it and re-contribute itif that makes it easeir on you.
The problem I have is that you have to modify it just to get it to
work with your setup... It seems ridiculous, that's all. Maybe I
should just parameterize it and then we can GPL it w/o objections.

> > The first 2 are in the $150 range. The third one is integrated into
> > the motherboard, kind of like Intel's EMP port on their high end
> > server motherboards. For all I know, this thing I'm getting IS an
> > Intel motherboard, but I haven't seen it yet.
>
> But what I remember is that the Western Telematics device only controls one
> machine. So, you need at least two for a cluster.
>
> So, the $400 (I think) for the RPC5-15 from BayTech which controls 4
> machines and has an ethernet interface sounds more reasonable than it
> might first appear.

Well, think of what you just said. If you are going to have 2 machines
in a cluster, you save $100 bucks by buying 2 small ones. And what if
one goes on the blink? I am scared to put this device on the network
(single pt of failure, security, etc.) I know, you told me the next
version will support SSH. I still like the serial device.

-Eric.
Software RAID HA Resource Script [ In reply to ]
"Eric Z. Ayers" wrote:
>
> Alan Robertson writes:
> ...
> >
> > Actually, they can do just that even with the copyright line, because they
> > don't have to distribute source (which would include the copyright line).
> > And being public domain, they don't even have to include the copyright line
> > if they redistribute it. That's what it means to say "public domain". It
> > means the author has no control at all any more.
> >
> > And when they modify it, you get no benefit. You might have to turn around
> > and buy it from someone who has modified it. Of course, as you pointed out
> > in this particular example, it isn't that big a deal.
> >
> > However, it does complicate things a tiny bit if I want to package it with
> > heartbeat, because everything else is licensed either GPL or LGPL. Now I
> > have to say some parts GPL, some LGPL, and some are public domain.
>
> OK, I'll GPL it and re-contribute itif that makes it easeir on you.
> The problem I have is that you have to modify it just to get it to
> work with your setup... It seems ridiculous, that's all. Maybe I
> should just parameterize it and then we can GPL it w/o objections.

It's really not that big a deal. I can take it like it is. I certainly didn't
mean that you don't have a perfect right to distribute it under whatever license
you see fit to use. I'm delighted you made it available!

> > > The first 2 are in the $150 range. The third one is integrated into
> > > the motherboard, kind of like Intel's EMP port on their high end
> > > server motherboards. For all I know, this thing I'm getting IS an
> > > Intel motherboard, but I haven't seen it yet.
> >
> > But what I remember is that the Western Telematics device only controls one
> > machine. So, you need at least two for a cluster.
> >
> > So, the $400 (I think) for the RPC5-15 from BayTech which controls 4
> > machines and has an ethernet interface sounds more reasonable than it
> > might first appear.
>
> Well, think of what you just said. If you are going to have 2 machines
> in a cluster, you save $100 bucks by buying 2 small ones. And what if
> one goes on the blink? I am scared to put this device on the network
> (single pt of failure, security, etc.) I know, you told me the next
> version will support SSH. I still like the serial device.

That's fine. I like the symmetry involved in access. For two nodes, there's
little difference (except the price) for more than two nodes, I think the
BayTech wins, because the failure of one node means another node can't be
reset. This is more likely than a switch failure in my opinion. And, then you
have to deal with interconnect topology, etc. Clearly the telnet version is
pretty risky to put on a semi-public or public net. By the way, when the switch
hangs or fails, you just can't reset nodes. Power is not lost to the machines.

Nothing against the Western Telematics device at all. The price is right, as
you point out. The whole point of making an open standard API is that Alan's
taste in switches doesn't limit what people can do.

Have you looked at any of the code in the Stonith library?

Are you planning on writing any/all of these?


Thanks!

-- Alan Robertson
alanr@suse.com
Software RAID HA Resource Script [ In reply to ]
"Eric Z. Ayers" wrote:

> Alan Robertson writes:
> ...
> >
> > Actually, they can do just that even with the copyright line, because they
> > don't have to distribute source (which would include the copyright line).
> > And being public domain, they don't even have to include the copyright line
> > if they redistribute it. That's what it means to say "public domain". It
> > means the author has no control at all any more.
> >
> > And when they modify it, you get no benefit. You might have to turn around
> > and buy it from someone who has modified it. Of course, as you pointed out
> > in this particular example, it isn't that big a deal.
> >
> > However, it does complicate things a tiny bit if I want to package it with
> > heartbeat, because everything else is licensed either GPL or LGPL. Now I
> > have to say some parts GPL, some LGPL, and some are public domain.
>
> OK, I'll GPL it and re-contribute itif that makes it easeir on you.
> The problem I have is that you have to modify it just to get it to
> work with your setup... It seems ridiculous, that's all. Maybe I
> should just parameterize it and then we can GPL it w/o objections.

It is just a bit rediculus. If you contributed it as "public domain", then one
of the things Alan is free to do is re-license it as GPL. So the complaint above
that Alan will have to change his license banner from two licenses to three is
just false.

The rest of Alan's discussion is correct: by issuing the code yourself under the
GPL, you are at lease assured that you will not have to buy back enhancements to
your own code.

Crispin

--
Crispin Cowan
Chief Research Scientist, WireX Communications, Inc. http://wirex.com
Free Hardened Linux Distribution: http://immunix.org
Software RAID HA Resource Script [ In reply to ]
Crispin Cowan wrote:
>
> It is just a bit rediculus. If you contributed it as "public domain", then one
> of the things Alan is free to do is re-license it as GPL. So the complaint above
> that Alan will have to change his license banner from two licenses to three is
> just false.


You're absolutely right.

-- Alan Robertson
alanr@suse.com