How To:Mirror Dumps to Virtual Tapes and Real Tapes using RAIT: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
Line 50: Line 50:
==Disaster Recovery from a RAIT tapeset==
==Disaster Recovery from a RAIT tapeset==


To assist in disaster recovery (as well as changer scripts) the AMANDA package now also includes amdd, which is a simple dd(1) replacement which supports (only) the "if=xxx", "of=xxx", "bs=nnn[kMb]" "skip=nnn" and "count=nnn" options, but which can read and write RAIT tapesets.
When performing a manual restore from a RAIT tapeset, you can just use amrestore on the device, like so:
 
<pre> $ amrestore -f 10 'rait:/dev/rmt/tps0d{4,5,6}n'</pre>
$ ammt -f 'rait:/dev/rmt/tps0d{4,5,6}n' rewind
$ ammt -f 'rait:/dev/rmt/tps0d{4,5,6}n' fsf 10
$ amdd  if='rait:/dev/rmt/tps0d{4,5,6}n' bs=32k skip=1 | amrestore ...
 
Using [[amdd]] and your usual Amanda unpack instructions will suffice for disaster recovery from RAIT tape-sets.


==Mirroring a backup==
==Mirroring a backup==

Revision as of 20:08, 16 July 2007

This article is a part of the How Tos collection.

Introduction

RAIT is an acronym for "Redundant Array of Inexpensive Tapes", where data is striped over several tape drives, with one drive writing an exclusive-or-sum of the others which can be used for error recovery. Any one of the data streams can be lost, and the data can still be recovered.

This means that a 3-drive RAIT set will write 2 "data" streams and one "parity" stream, and give you twice the capacity, twice the throughput, and the square of the failure rate (i.e. a 1/100 failure rate becomes 1/10,000, since a double-tape failure is required to lose data).

Similarly, a 5-drive RAIT set will give you 4 times the capacity, 4 times the throughput (with sufficient bus bandwidth), and the square of the failure rate.

This means you can back up partitions as large as four times your tape size with Amanda, with higher reliability and speed.

RAIT can also be used to mirror a backup to two drives. A 2-drive RAIT duplicates the output stream and each output stream can have different drivers, like a real tape, a virtual tape (see File driver) or a mix of them.

Currently, only 2, 3 and 5 drive sets are supported.

Using a RAIT

If you have several tape devices on your system you tell Amanda to use them as a RAIT by listing them as a list of single tape devices, between curly braces, separated with a comma (the string needs curly braces, otherwise it is treated as a single device name):

tapedev "rait:{/dev/nst0,/dev/nst1,/dev/nst2}"

The curly-braces can be used only the differences in the strings like:

tapedev "rait:/dev/rmt/tps0d{4,5,6}n"

which means that /dev/rmt/tps0d4n, /dev/rmt/tps0d5n, and /dev/rmt/tps0d6n are to be treated as a RAIT set. You can now mount three tapes, and label them with amlabel, etc.

Also, you want to create a new tapetype entry, which lists an n-drive RAIT set, for this RAIT-set. So if you were using an entry like:

define tapetype EXB-8500 {
    comment "Exabyte EXB-8500 drive on decent machine"
    length 4200 mbytes
    filemark 48 kbytes
    speed 474 kbytes
}

You would want to make a new one, with capacity and speed times N-1:

define tapetype EXB-8500x3 {
    comment "Exabyte EXB-8500 3 drive stripe on decent machine"
    length 8400 mbytes
    filemark 200 kbytes
    speed 948 kbytes
}

and change your tapetype entry to "tapetype EXB-8500x3" to tell Amanda about the multiple drive set.

Disaster Recovery from a RAIT tapeset

When performing a manual restore from a RAIT tapeset, you can just use amrestore on the device, like so:

 $ amrestore -f 10 'rait:/dev/rmt/tps0d{4,5,6}n'

Mirroring a backup

RAIT with only two drives, creates a perfect copy of the data: a mirror of your backup. Each of these mirrors is handled by its own output driver: one of the mirrors can write to a real tape device, and the other mirror can write a virtual tape (vtape) using the "file" driver. The vtapes can be used for fast recovery, and the tapes can be stored offsite.

Together with the "chg-multi" changer, which is suitable for a whole range of applications, this setup requires these parameters in amanda.conf (the parameters dumpcycle, runspercycle and tapecycle should be adapted to your environment):

dumpcycle 1 week
runspercycle 5
tapecycle 10
tpchanger "chg-multi"
changerfile "chg-multi-mirror.conf"
# tapedev is not needed
# changerdev is not needed

We create the file chg-multi-mirror.conf in the same directory, with these contents:

multieject 0
needeject 0
gravity 0
ejectdelay 0
statefile /home/amanda/daily/changerstatus
firstslot 1
lastslot 10
slot 1 rait:{file:/amandatapes/daily/vtape1,tape:/dev/nst0}
slot 2 rait:{file:/amandatapes/daily/vtape2,tape:/dev/nst0}
slot 3 rait:{file:/amandatapes/daily/vtape3,tape:/dev/nst0}
slot 4 rait:{file:/amandatapes/daily/vtape4,tape:/dev/nst0}
slot 5 rait:{file:/amandatapes/daily/vtape5,tape:/dev/nst0}
slot 6 rait:{file:/amandatapes/daily/vtape6,tape:/dev/nst0}
slot 7 rait:{file:/amandatapes/daily/vtape7,tape:/dev/nst0}
slot 8 rait:{file:/amandatapes/daily/vtape8,tape:/dev/nst0}
slot 9 rait:{file:/amandatapes/daily/vtape9,tape:/dev/nst0}
slot 10 rait:{file:/amandatapes/daily/vtape10,tape:/dev/nst0}

This assumes we have only 1 tapedrive (/dev/nst0), which we need to manually change the tape each day.

RAIT with a real tape changer is not supported.

  • NOTE: this needs more clarification: what about chg-manual, and chg-rait?

We create the 10 virtual tapes:

$ for i in 1 2 3 4 5 6 7 8 9 10; do mkdir -p /amandatapes/daily/vtape$i/data; done

We insert a tape in the physical tapedrive, and label the first tape. This will label both the virtual tape vtape1 and the tape in the physical drive identically:

$ amlabel daily DAILY-01 slot 1
$ amcheck daily

Last check, and we are ready for the normal amdump run.

When reading a RAIT set and an XOR sum mismatch is detected, this is flagged with the error:

 EDOM (Numerical argument out of domain)

When the tape in the tapedrive is not the same label as the tape in the corresponding tape in the vtape set, the checksums of course do not match and you get the cryptic error:

amcheck-server: slot 2: reading label: Numerical argument out of domain

This means that the tapes in slot 2 do not match (or that one of the tapes had a read error). Finding out which tape each side of the mirror has, can be done with amdd:

$ ammt -t file:/amandatapes/daily/vtape2 rewind
$ amdd  if=file:/amandatapes/daily/vtape2 bs=32k count=1
AMANDA: TAPESTART DATE X TAPE DAILY-02

1+0 in
1+0 out
$ ammt -t file:/amandatapes/daily/vtape2 rewind
$ ammt -t /dev/nst0 rewind
$ amdd  if=/dev/nst0 bs=32k count=1
AMANDA: TAPESTART DATE X TAPE Test-03

1+0 in
1+0 out
$ ammt -t /dev/nst0 rewind

In the example we see that the physical tape is actually labeled "Test-03", while we need the tape labeled "DAILY-02". Note that we always rewind the tape again when finished.

Using amrecover with half of the mirror

When needing to restore, you can use the specific vtape, or the physical tape. Just specify the correct device to amrecover (or amrestore) on the command line, or with the settape subcommand from amrecover.

# amrecover daily -d amandaserver.example.com:file:/amandatapes/daily/vtape5

Note that, when you specify the driver, you must specify the hostname too.

Alternatively, you could set up a special configuration for restoring, named "halfmirror" that is almost identical to the normal config, except for the chg-multi.conf: fill that file without rait option and only the virtual tape half of the mirror:

In the amanda.conf from the configuration named halfmirror:

tpchanger "chg-multi"
changerfile "chg-multi-halfmirror.conf"
amrecover_changer "halfmirror"
amrecover_do_fsf true
amrecover_check_label true

chg-multi-halfmirror.conf:

multieject 0
needeject 0
gravity 0
ejectdelay 0
statefile /home/amanda/daily/restorchgstatus   # different name than the normal mirror
firstslot 1
lastslot 10
slot 1 file:/amandatapes/daily/vtape1
slot 2 file:/amandatapes/daily/vtape2
slot 3 file:/amandatapes/daily/vtape3
slot 4 file:/amandatapes/daily/vtape4
slot 5 file:/amandatapes/daily/vtape5
slot 6 file:/amandatapes/daily/vtape6
slot 7 file:/amandatapes/daily/vtape7
slot 8 file:/amandatapes/daily/vtape8
slot 9 file:/amandatapes/daily/vtape9
slot 10 file:/amandatapes/daily/vtape10

By using a different name for statefile above, we do not interfere with the notion of current tape etc from the normal daily configuration. (This would not work with chg-disk.)

And recovering from this set of vtapes goes like:

# amrecover halfmirror -d halfmirror
Tip

If you are short in diskspace, you can get fancy, and keep only the last 5 (runspercycle) vtapes online, by removing the contents of the data directory in each vtape that is older than runspercycle, except the first pair of files (the label). Even the "TAPEEND" pair of files is not strictly needed for Amanda. An erased vtape, with correct label then looks like:

$ ls -l /amandatapes/daily/vtape4
-rw-------  1 amanda disk      10 Mar 29 00:04 00000-DAILY-04
-rw-------  1 amanda disk   32768 Mar 29 00:04 00000.DAILY-04