How To:Build a Test Environment With Virtual Tapes: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(filemark of a vtape is15 bytes max instead of 32k)
m (autolabel)
 
(24 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Here is a Quick Setup for a test configuration with a virtual
{{How To Header}}
tape changer, emulating tapes on disk.
Here is a Quick Setup for a test configuration with a virtual tape changer, emulating tapes on disk.


A test environment is very handy to experiment with the more obscure features of amanda,  
Note that this article describes setting up vtapes specifically for a test environment.  For a more complete description of virtual tapes and their use, see [[file driver]] and [[How To:Set Up Virtual Tapes]].
or get more familiar with all the possible options in amanda.conf and the dumptype options.
 
And you can practice restores quickly.
A test environment is very handy to experiment with the more obscure features of amanda, or get more familiar with all the possible options in amanda.conf and the dumptype options. And you can practice restores quickly.


Let's call the configuration "test".
Let's call the configuration "test".
Line 11: Line 11:


  $ amadmin x version | grep CONFIG_DIR
  $ amadmin x version | grep CONFIG_DIR
  CONFIG_DIR=/usr/local/etc/amanda
  CONFIG_DIR=/etc/amanda
  $ cd /usr/local/etc/amanda
  $ cd /etc/amanda
  $ mkdir test
  $ mkdir test


Copy a template [[amanda.conf]] file to the directory created,
and adapt the parameters to your environment.  Here are some values:


Copy a template {{man|5|amanda.conf}} file to the directory created, and adapt the parameters to your environment.  Here are some values:
'''Amanda 2.6.0 or below (old chg-disk):'''
  org "Acme Inc."
  org "Acme Inc."
  mailto "[email protected]"
  mailto "[email protected]"
Line 26: Line 28:
  tpchanger "chg-disk"                            # a virtual tape changer
  tpchanger "chg-disk"                            # a virtual tape changer
  tapedev "file:/space/vtapes/test/slots"
  tapedev "file:/space/vtapes/test/slots"
  changerfile "/home/amanda/test/changerfile"
  changerfile "/var/lib/amanda/test/changerfile"
  labelstr "TEST-.*"
  labelstr "TEST-.*"
  tapetype DISK
#label_new_tapes "TEST-%%"
  infofile "/home/amanda/test/curinfo"
#autolabel "TEST-%%"
  logdir "/home/amanda/test/log"
  tapetype DVD_SIZED_DISK
  indexdir "/home/amanda/test/index"
  logdir "/var/lib/amanda/test"
  tapelist "/home/amanda/test/tapelist"
  infofile "/var/lib/amanda/test/curinfo"
  indexdir "/var/lib/amanda/test/index"
  tapelist "/var/lib/amanda/test/tapelist"
   
   
  holdingdisk hd1 {
  holdingdisk hd1 {
Line 39: Line 43:
   
   
  define dumptype comp-tar {
  define dumptype comp-tar {
     program GNUTAR
     program "GNUTAR"
     compress fast
     compress fast
     index yes
     index yes
Line 45: Line 49:
  }   
  }   
   
   
  define tapetype DISK {
  define tapetype DVD_SIZED_DISK {
     filemark 15 bytes
     filemark 4 KB
     length 1g
     length 4482 MB
  }
  }
'''Amanda 2.6.1 or above (new chg-disk):'''
org "Acme Inc."
dumpcycle 7
runspercycle 5
tapecycle 5
dumpuser "amanda"
tpchanger "chg-disk:/space/vtapes/test/slots"                            # a virtual tape changer
labelstr "TEST-.*"
#label_new_tapes "TEST-%%"
#autolabel "TEST-%%"
tapetype DVD_SIZED_DISK
logdir "/var/lib/amanda/test"
infofile "/var/lib/amanda/test/curinfo"
indexdir "/var/lib/amanda/test/index"
tapelist "/var/lib/amanda/test/tapelist"
holdingdisk hd1 {
    directory "/space/amandahold/test"
}
define dumptype comp-tar {
    program "GNUTAR"
    compress fast
    index yes
    record no          # Important! avoid interfering with production runs
define tapetype DVD_SIZED_DISK {
    filemark 4 KB
    length 4482 MB
}


The above contains only the bare minimum.  The idea of a test environment is just to add and change most of the values in amanda.conf.
The above contains only the bare minimum.  The idea of a test environment is just to add and change most of the values in amanda.conf.


Note: you may set "record yes" in the dumptype for those directories that are NOT used by any real Amanda config.
Note: you may set "record yes" in the dumptype for those directories that are NOT used by any real Amanda config.  It is ok to add "record yes" if the parent of a directory is part of another amanda config, but this is only a subdirectory of that directory.


Create some directories/files that we configured in amanda.conf:
Create some directories/files that we configured in amanda.conf:


  # mkdir -p /space/amandahold
  # mkdir -p /space/amandahold
# chown amanda:disk /space/amandahold
# chmod 750 /space/amandahold
  # su - amanda
  # su - amanda
  $ mkdir /space/amandahold/test  
  $ mkdir /space/amandahold/test  
  $ mkdir -p /home/amanda/test/curinfo
  $ mkdir /var/lib/amanda/test
$ mkdir /home/amanda/test/log
  $ touch /var/lib/amanda/test/tapelist
  $ mkdir /home/amanda/test/index
$ touch /home/amanda/test/tapelist


And create the virtual tapes:
And create the virtual tapes, making sure the [[dumpuser]] has access to the vtapes, but not everyone else on this server:


  # mkdir /space/vtapes
  # mkdir /space/vtapes
  # chown amanda:disk /space/vtapes
  # chown amanda:disk /space/vtapes
# chmod 750 /space/vtapes
  # su - amanda
  # su - amanda
  $ mkdir -p /space/vtapes/test/slots
  $ mkdir -p /space/vtapes/test/slots
  $ cd /space/vtapes/test/slots
  $ cd /space/vtapes/test/slots
  $ for i in 1 2 3 4 5; do mkdir slot$1; done
  $ for i in 1 2 3 4 5; do mkdir slot$i; done
  $ ln -s slot1 data
  $ ln -s slot1 data


In the loop above: create as many slots as you have specified '''tapecycle'''
In the loop above: create as many slots as you have specified '''tapecycle''' in the amanda.conf.  (Do not add a leading zero to the numbers.)
in the amanda.conf.  (Do not add a leading zero to the numbers.)


Quick test to verify the virtual tape setup:
Quick test to verify the virtual tape setup:


# Amanda 2.6.0 and above:
$ amdevcheck <config> file:/space/vtapes/test/slots
# pre-2.6.0
  $ ammt -f file:/space/vtapes/test/slots status
  $ ammt -f file:/space/vtapes/test/slots status
If OK, the <tt>ammt</tt> command should print "ONLINE", while the {{man|8|amdevcheck}} should print "VOLUME_UNLABELED"


Then label the tapes:
Then label the tapes:
Line 88: Line 133:


  $ amtape test reset
  $ amtape test reset
Since Amanda version 2.5.0 you can also add the parameter '''label_new_tapes''', (''''autolabel''' as of version 3.1)  which will automatically label any tape if needed -- very handy in this case (unless you want to test '''amlabel''' commands).


Now create a small '''disklist''' file:
Now create a small '''disklist''' file:
Line 94: Line 141:
  client1.example.com        /var/log  comp-tar
  client1.example.com        /var/log  comp-tar


Run [[amcheck]] and solve all issues.
Configure the servers you added in the disklist as Amanda clients.
 
Run {{man|8|amcheck}} and solve all issues.


And you're ready for the first test run:
And you're ready for the first test run:


  $ amdump test
  $ amdump test
== Resetting the environment ==
After some tests, you may want to start from scratch, removing all the garbage created while testing.
For this, remove the contents of the status directories and also the virtual tapes. But do not remove the directories or files themselves.
$ rm -rf /space/vtapes/test/slots/slot*/*
$ rm -rf /space/amandahold/test/*
$ rm -rf /var/lib/amanda/test/*
$ > /var/lib/amanda/test/tapelist
And amlabel the tapes again as above.  When using the '''label_new_tape''' parameter ('''autolabel'''' as of version 3.1), Amanda will label them even automatically again.
Hopefully, you have made a safe copy of the "base" amanda.conf and disklist before starting the experiments, otherwise you'll have to walk through these files and inspect the values.

Latest revision as of 23:07, 21 October 2010

This article is a part of the How Tos collection.

Here is a Quick Setup for a test configuration with a virtual tape changer, emulating tapes on disk.

Note that this article describes setting up vtapes specifically for a test environment. For a more complete description of virtual tapes and their use, see file driver and How To:Set Up Virtual Tapes.

A test environment is very handy to experiment with the more obscure features of amanda, or get more familiar with all the possible options in amanda.conf and the dumptype options. And you can practice restores quickly.

Let's call the configuration "test".

First find out where the configuration directory is, and create a new config, as user amanda:

$ amadmin x version | grep CONFIG_DIR
CONFIG_DIR=/etc/amanda
$ cd /etc/amanda
$ mkdir test


Copy a template amanda.conf(5) file to the directory created, and adapt the parameters to your environment. Here are some values:

Amanda 2.6.0 or below (old chg-disk):

org "Acme Inc."
mailto "[email protected]"
dumpcycle 7
runspercycle 5
tapecycle 5
dumpuser "amanda"
tpchanger "chg-disk"                            # a virtual tape changer
tapedev "file:/space/vtapes/test/slots"
changerfile "/var/lib/amanda/test/changerfile"
labelstr "TEST-.*"
#label_new_tapes "TEST-%%"
#autolabel "TEST-%%"
tapetype DVD_SIZED_DISK
logdir "/var/lib/amanda/test"
infofile "/var/lib/amanda/test/curinfo"
indexdir "/var/lib/amanda/test/index"
tapelist "/var/lib/amanda/test/tapelist"

holdingdisk hd1 {
    directory "/space/amandahold/test"
}

define dumptype comp-tar {
    program "GNUTAR"
    compress fast
    index yes
    record no           # Important! avoid interfering with production runs
}  

define tapetype DVD_SIZED_DISK {
    filemark 4 KB
    length 4482 MB
}


Amanda 2.6.1 or above (new chg-disk):

org "Acme Inc."
mailto "[email protected]"
dumpcycle 7
runspercycle 5
tapecycle 5
dumpuser "amanda"
tpchanger "chg-disk:/space/vtapes/test/slots"                            # a virtual tape changer
labelstr "TEST-.*"
#label_new_tapes "TEST-%%"
#autolabel "TEST-%%"
tapetype DVD_SIZED_DISK
logdir "/var/lib/amanda/test"
infofile "/var/lib/amanda/test/curinfo"
indexdir "/var/lib/amanda/test/index"
tapelist "/var/lib/amanda/test/tapelist"

holdingdisk hd1 {
    directory "/space/amandahold/test"
}

define dumptype comp-tar {
    program "GNUTAR"
    compress fast
    index yes
    record no           # Important! avoid interfering with production runs
}  

define tapetype DVD_SIZED_DISK {
    filemark 4 KB
    length 4482 MB
}


The above contains only the bare minimum. The idea of a test environment is just to add and change most of the values in amanda.conf.

Note: you may set "record yes" in the dumptype for those directories that are NOT used by any real Amanda config. It is ok to add "record yes" if the parent of a directory is part of another amanda config, but this is only a subdirectory of that directory.

Create some directories/files that we configured in amanda.conf:

# mkdir -p /space/amandahold
# chown amanda:disk /space/amandahold
# chmod 750 /space/amandahold
# su - amanda
$ mkdir /space/amandahold/test 
$ mkdir /var/lib/amanda/test
$ touch /var/lib/amanda/test/tapelist

And create the virtual tapes, making sure the dumpuser has access to the vtapes, but not everyone else on this server:

# mkdir /space/vtapes
# chown amanda:disk /space/vtapes
# chmod 750 /space/vtapes
# su - amanda
$ mkdir -p /space/vtapes/test/slots
$ cd /space/vtapes/test/slots
$ for i in 1 2 3 4 5; do mkdir slot$i; done
$ ln -s slot1 data

In the loop above: create as many slots as you have specified tapecycle in the amanda.conf. (Do not add a leading zero to the numbers.)

Quick test to verify the virtual tape setup:

# Amanda 2.6.0 and above:
$ amdevcheck <config> file:/space/vtapes/test/slots
# pre-2.6.0
$ ammt -f file:/space/vtapes/test/slots status

If OK, the ammt command should print "ONLINE", while the amdevcheck(8) should print "VOLUME_UNLABELED"

Then label the tapes:

$ for i in 1 2 3 4 5; do amlabel test TEST-$i slot $i; done

And reset the changer to the first slot again:

$ amtape test reset

Since Amanda version 2.5.0 you can also add the parameter label_new_tapes, ('autolabel as of version 3.1) which will automatically label any tape if needed -- very handy in this case (unless you want to test amlabel commands).

Now create a small disklist file:

amandaserver.example.com   /var/log   comp-tar
client1.example.com        /var/log   comp-tar

Configure the servers you added in the disklist as Amanda clients.

Run amcheck(8) and solve all issues.

And you're ready for the first test run:

$ amdump test

Resetting the environment

After some tests, you may want to start from scratch, removing all the garbage created while testing.

For this, remove the contents of the status directories and also the virtual tapes. But do not remove the directories or files themselves.

$ rm -rf /space/vtapes/test/slots/slot*/*
$ rm -rf /space/amandahold/test/*
$ rm -rf /var/lib/amanda/test/*
$ > /var/lib/amanda/test/tapelist

And amlabel the tapes again as above. When using the label_new_tape parameter (autolabel' as of version 3.1), Amanda will label them even automatically again.

Hopefully, you have made a safe copy of the "base" amanda.conf and disklist before starting the experiments, otherwise you'll have to walk through these files and inspect the values.