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
(new stuff)
Line 1: Line 1:
{{How To Header}}
{{How To Header}}
= Overview =
= Overview =
The basis of a RAIT configuration is the [[RAIT Device]], which allows Amanda to mirror (with two child devices) or stripe with parity (with 3 or more child devices) data across several child devices.  The RAIT device should not be confused with RAID -- a RAID system will continue functioning in a degraded state, while the RAIT device will not write in a degraded state.  It does allow reading in a degraded state, in order to support recoveries.
The basis of a RAIT configuration is the [[RAIT Device]], which allows Amanda to mirror (with two child devices) or stripe with parity (with 3 or more child devices) data across several child devices.  See [[How To:Stripe Dumps across Tapes using RAIT]] for a bit more background on the RAIT device and RAIT-related changers.


== No Changer ==
=Mirroring a backup=
The most basic RAIT configuration is similar to a basic tape configuration with no changer, but with two or more tape devices:
tapedev "rait:/dev/nst{0,1,2}"


== chg-multi ==
RAIT with only two drives, creates a perfect copy of the data: a mirror of your backup.
If all of your child devices will have different names (different vtapes, S3 devices, etc.), using [[chg-multi]] may be the easiest way to specify multiple devices.
Each of these mirrors is handled by its own device. For example, one of the mirrors can
tpchanger "chg-multi"
write to a real tape device, and the other mirror can write a virtual tape (vtape) using
changerfile "changer.conf"
the VFS device.  The vtapes can be used for fast recovery, and the tapes can be stored
with changer.conf:
offsite.
multieject 0
needeject 0
gravity 0
ejectdelay 0
statefile /var/lib/amanda/daily/changerstatus
firstslot 1
lastslot 10
slot 1 rait:{file:/var/vtapes/slot1,tape:/dev/nst0}
slot 2 rait:{file:/var/vtapes/slot2,tape:/dev/nst0}
slot 3 rait:{file:/var/vtapes/slot3,tape:/dev/nst0}
# etc.
 
Note that, in this case, it is important to manually keep the tape drive in sync with the slot that Amanda expects.
 
== chg-rait ==
For more complex configurations, [[chg-rait]] is appropriate.  This uses some trickery to operate independent "child changers" and distributes changer commands to its children.  Its configuration file begins with
  nchangers=2
which gives the number of child changers; then come a series of variables for each child changer, each with a numeric suffix:
  tpchanger_1="chg-zd-mtx"
  changerdev_1="/dev/mtx1"
  changerfile_1="/etc/amanda/myconfig/chg-zd-mtx.conf"
  tapedev_1="/dev/scsi/changer/c3t5d1"
  tpchanger_2="chg-disk"
  tapedev_2="file:/var/vtapes"
 
This option does a better job of keeping the various changers in sync, but chg-rait can be a bit cranky.  Post any problems to the mailing list.
 
= Examples =
==RAIT with 3 autoloaders example setup==
 
Disclaimer: Known to work on Solaris with Sony TSL-9000 autoloaders and amanda-2.6.0p2, YMMV.
 
This assumes that you have a working configuration named Dailyset1 and all the non-RAIT parameters have been set.
 
It is probably easiest to set up and test a non-RAIT configuration, and once that works, make the following
modifications to convert to a RAIT setup after deleting all log files, everything under curinfo/ and emptying the tapelist and tapelist.amlabel files.
 
 
Set the following in amanda.conf:
<pre>
tpchanger "chg-rait"                                    # the tape-changer glue script (chg-rait modified,
  see below)
tapedev "rait:tape:/dev/rmt/{0,1,2}ln"                      # the no-rewind tape devices
changerfile "/usr/local/etc/amanda/Dailyset1/changer.conf"  # tape changer configuration parameter file
#changerdev                                                # tape changer configuration parameter device
  (not used here)
</pre>
 
In changer.conf:
 
  #
nchangers=3
#
tpchanger_1="chg-zd-mtx"                                    # modified chg-zd-mtx, see below
changerdev_1="/dev/scsi/changer/c3t4d1"                      # changer device
changerfile_1="/usr/local/etc/amanda/Dailyset1/changer1.conf" # device specific config file
#tapedev_1                                                    # not used
#
tpchanger_2="chg-zd-mtx"                                    # modified chg-zd-mtx, see below
changerdev_2="/dev/scsi/changer/c3t5d1"                      # changer device
changerfile_2="/usr/local/etc/amanda/Dailyset1/changer2.conf" # device specific config file
#tapedev_2                                                    # not used
#
tpchanger_3="chg-zd-mtx"                                    # modified chg-zd-mtx, see below
changerdev_3="/dev/scsi/changer/c3t6d1"                      # changer device
changerfile_3="/usr/local/etc/amanda/Dailyset1/changer3.conf" # device specific config file
#tapedev_3                                                    # not used
 
In the changerX.conf files (one file for 3 identical loaders should be OK, but not tested):
 
# Device specific parameters for the loaders. See the comments at the start of chg-zd-mtx for details
#
firstslot=1
lastslot=7
havereader=0
autoclean=0
poll_drive_ready=5
initial_poll_delay=5
cleanslot=8
#
 
Note: chg-zd-mtx as supplied gets it's configuration from amanda.conf and is called by chg-rait 3 times, once for each loader. The clean fix would be to modify chg-zd-mtx to optionally accept explicit configuration information from the caller and modify chg-rait to provide it from the changer.conf file.
 
RAIT expects all 3 loaders to be in sync, that is all loaders are in the same state, have the same number of tapes, and all tapes have the same labels in corresponding slots.
 
Test your configuration.
 
Try '''amtape Dailyset1 reset''' and all the loaders should load slot 1 and '''amtape Dailyset1 current''' should show slot 1 as loaded.
 
You may get some warnings, but if all loaders load properly, ignore them.
 
With slot 1 loaded for all loaders, label the tapes.


  amlabel -f Dailyset1 Dailyset1-001
This example shows how to mirror a dump to virtual tapes and real tapes. First, get each set up and running independently. For example, your vtape configuration (based on [[How To:Set Up Virtual Tapes]]) might look like
  amtape Dailyset1 slot next
  tpchanger "chg-disk:/u01/vtapes"
  amlabel -f Dailyset1 Dailyset1-002
with, say, 25 slots in <tt>/u01/vtapes</tt>. Similarly, your physical tape configuration might be
  amtape Dailyset1 slot next
  tpchanger "chg-zd-mtx"
.
  changerdev "/dev/mtx1"
.
  changerfile "/etc/amanda/myconfig/chg-zd-mtx.conf"
.


And so on until all tapes are labeled.
Combining these two is fairly straightforward. The first can be specified directly, since it has no configuration parameters, but the second will require its own changer definition:
define changer "robot" {
  tpchanger "chg-zd-mtx"
  changerdev "/dev/mtx1"
  changerfile "/etc/amanda/myconfig/chg-zd-mtx.conf"
}
Then, specify both to the RAIT changer as the Amanda tape device:
tpchanger "chg-rait:{chg-disk:/u01/vtapes,robot}"


Load slot 1 (amtape Dailyset1 slot 1) and do a test backup (amdump Dailyset1).
Run some {{man|8|amtape}} subcommands to exercise the new changer, then an {{man|8|amcheck}} and {{man|8|amdump}}. Easy as that!


 
== Old, chg-multi method ==
 
''This method is for use in Amanda-2.6.1 and earlier, before the new RAIT changer was available.''
==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:
<pre> $ amrestore -f 10 'rait:/dev/rmt/tps0d{4,5,6}n'</pre>
 
==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):
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):

Revision as of 04:50, 18 February 2009

This article is a part of the How Tos collection.

Overview

The basis of a RAIT configuration is the RAIT Device, which allows Amanda to mirror (with two child devices) or stripe with parity (with 3 or more child devices) data across several child devices. See How To:Stripe Dumps across Tapes using RAIT for a bit more background on the RAIT device and RAIT-related changers.

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 device. For example, one of the mirrors can write to a real tape device, and the other mirror can write a virtual tape (vtape) using the VFS device. The vtapes can be used for fast recovery, and the tapes can be stored offsite.

This example shows how to mirror a dump to virtual tapes and real tapes. First, get each set up and running independently. For example, your vtape configuration (based on How To:Set Up Virtual Tapes) might look like

tpchanger "chg-disk:/u01/vtapes"

with, say, 25 slots in /u01/vtapes. Similarly, your physical tape configuration might be

 tpchanger "chg-zd-mtx"
 changerdev "/dev/mtx1"
 changerfile "/etc/amanda/myconfig/chg-zd-mtx.conf"

Combining these two is fairly straightforward. The first can be specified directly, since it has no configuration parameters, but the second will require its own changer definition:

define changer "robot" {
 tpchanger "chg-zd-mtx"
 changerdev "/dev/mtx1"
 changerfile "/etc/amanda/myconfig/chg-zd-mtx.conf"
}

Then, specify both to the RAIT changer as the Amanda tape device:

tpchanger "chg-rait:{chg-disk:/u01/vtapes,robot}"

Run some amtape(8) subcommands to exercise the new changer, then an amcheck(8) and amdump(8). Easy as that!

Old, chg-multi method

This method is for use in Amanda-2.6.1 and earlier, before the new RAIT changer was available.

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.

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.

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