Amanda RAIT Notes

Introduction



I recently acquired a Sun StorEdge L1800 tape library - a mid-sized, 48-slot,
4-drive affair from the late 1990s. Eventually, I started using it with
Amanda, a free backup and recovery
scheduler, for basic home backups. Not too shabby.




Since this thing only uses DLT-7000 drives (35 GB native tapes), it’s not able
to hold loads of data. Currently, I’m working on using it solely for full
(aka level-0) backups, with incrementals being done on other media. Of
course, these are older tapes and drives, so I’d want some level of redundancy.
Boosting the dump speed (native rate is just under 5 MB/sec) would be nice,
too. And that’s how I started using RAIT in Amanda.



RAIT basics


RAIT, or Redundant Array of Inexpensive Tapes, is pretty well described in
the Amanda online manual.
It’s basically a RAID-3 using tape - two tapes are used for a data stripe,
and a third for parity. Amanda’s implementation seems a bit limited, compared
to some commercial products; the parity stripe doesn’t rotate around the
tapes (useful for auto-compressing tape drives - if one drive always does
the parity, that drive will probably have poor compression and may limit
the amount of storable data), and you can only use 3 or 5 drives (though you
can do mirrored backup tapes in amanda, so 2 drives are somewhat supported).


There’s a brief article in
the amanda wiki about configuring RAIT,
and some sample config files in this
mailing list posting
,
so I won’t go into excessive detail here. Essentially, you use the
chg-rait tape changer, with a config file that specifies a drive, changer
type and config file, and changer device for each of the drives involved.
Each drive gets its own changer config, so you can mix and match different
changers freely - even use a vtape/disk “changer” if you desire. Pretty
straightforward.


If you need more info, read the chg-rait script. It’s just a shell script,
is really short, and has some good comments.

The Problem With RAIT In A Library


So, you can pretty easily whip up three changer configs that each use the
same SCSI generic device to control the changer, but use a different drive in
the library and a different range of tapes. Be warned, you’ll probably want
to have 3 copies of every tape label - Amanda will assume each tape in a
RAIT set will have the same label, and if they don’t match things may complain.


What they don’t tell you is that chg-rait will pass the same slot number to
each of the three (or however many) sub-changers. If you’re using three
configs for chg-zd-mtx, each with different ranges of tapes in the same
library, this will result in one tape loading successfully (since the
requested slot is actually in that config’s range of slots) and the other
two configs failing to find a slot (since the requested slot isn’t in their
ranges).


To get around this, I wrote a small fake changer script in perl. It bumps
the given slot number by a set amount, calls a real changer, and corrects
the slot number in its output before returning. The changer script, and the
bump value (number of slots to skip over in the changer) are both highly
changer-dependant, and are both constants in the script. See below:

#!/usr/bin/perl5 -w
#
# This invokes chg-zd-mtx, but bumps the slot number by a constant amount.

$bump = 11;
$real_changer = "chg-zd-mtx";

if( exists($ARGV[0]) and $ARGV[0] eq "-slot" ) {
    if( $ARGV[1] =~ m|[0-9]+| ) {
        $slot = $ARGV[1] + $bump;
        $cmd = "$real_changer $ARGV[0] $slot\n";
    } else {
        $cmd = "$real_changer $@\n";
    }
} else {
    $cmd = "$real_changer $@\n";
}

# Run the command, and modify the returned slot number
open(CPIPE, "${cmd}|");
while() {
    $line = $_;
    if( $line =~ m|^([0-9]+)\s+(.*)| ) {
        $slot = $1 - $bump;
        $rest = "$2\n";
        print "$slot $rest";
    } else {
        print "$line";
    }
}

# vi:set ai aw sw=4:


Obviously, you’ll need a couple copies of this (I use two, one for the
second drive, and one for the third) for each of the offsets into the
library’s tape storage array.