Professional Documents
Culture Documents
Helali Bhuiyan
Both these websites contain almost the same content, but the wiki site provides better explanations. Therefore, I recommend the wiki site. In case of conflicts between the materials presented in this document and that presented on the Amanda websites, the websites are the authoritative sources of information. Users of this document are expected to know basic Linux commands. For example, creating/removing files/directories, changing the current directory, modifying access rights, etc. Some of the commands used to install Amanda require root access, while some require regular-user access. To distinguish between these two sets of commands, the root-privileged commands start with #, and regular-user invoked commands start with $ in the command prompt. For example, Command executed by root, # amrecover test Command executed by normal user, $ amdump test In this document, I described steps to install a server-side Amanda on mvstu2 machine, and a client-side Amanda on mvstu3 machine, which are located in our lab. As installing softwares in Linux machines are sometime dependent on the kernel version and the gcc version, I am providing these information below,
University of Virginia
Helali Bhuiyan
mvstu2: [amb6fp@mvstu2 ~]$ uname -a Linux mvstu2 2.6.20-1.2320.fc5 #1 Tue Jun 12 18:20:44 EDT 2007 i686 i686 i386 GNU/Linux [amb6fp@mvstu2 ~]$ gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++,f77 --disable-libgcj --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-56.fc5) mvstu3: [amb6fp@mvstu3 ~]$ uname -a Linux mvstu3 2.6.20-1.2312.fc5 #1 Tue Apr 10 14:53:08 EDT 2007 i686 i686 i386 GNU/Linux [amb6fp@mvstu3 ~]$ gcc -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux Thread model: posix gcc version 4.1.1 20070105 (Red Hat 4.1.1-51)
University of Virginia
Helali Bhuiyan
$ wget http://easynews.dl.sourceforge.net/sourceforge/amanda/ama nda-2.5.2p1.tar.gz Then unzip the downloaded file by executing the following command: $ tar xvzf amanda-2.5.2p1.tar.gz Now change your directory to this new unzipped Amanda source code directory: $ cd amanda-2.5.2p1
2. Compiling Amanda:
Before compiling Amanda, you should decide, under which user name Amanda will be run (usually this user is you or your username on that machine). Amanda is very strict about who runs what, and access rights. Some parts of Amanda can only be run by the selected user; others can only be run by the root. If a specific part of Amanda is supposed to be run by the selected user, you must not run that program as root or vice versa. Lets assume that the user name is amb6fp. You will also have to decide a group under which the Amanda programs will be run. I picked disk as the group, which has access to the disk in that machine. Now pick a configuration name. Amanda can have multiple configurations. I picked test as the configuration name. As a start, we will install the server part of Amanda on one of our machines mvstu2. So we have the following configurations so far: Username: amb6fp Group: disk Configuration name: test Machine: mvstu2 To compile Amanda, execute the following command within the Amanda source code directory under user amb6fp: $./configure -with-user=amb6fp -with-group=disk -with-config=test If you want to only install the client/server part of Amanda (which I did later for the client part of my installation), add -without-server or -without-client option to the end. Now build Amanda by, $ make
University of Virginia
Helali Bhuiyan
To install Amanda, you need to be the root. So switch to root account by (you will need to give the root account password after this), $ su root Now install Amanda by, # make install
University of Virginia
Helali Bhuiyan
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-%%" 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! avoids interfering with production runs } define tapetype DVD_SIZED_DISK { filemark 4 KB length 4482 MB } Based on these entries, now we need to create some directories/files. These should match with the entries in the amanda.conf file entries mentioned above. Some of these directory creations may require root privilege. But note that after creating them under the root account, we change the ownership to the Amanda user (amb6fp) and group disk. # mkdir -p /space/amandahold # chown amb6fp:disk /space/amandahold # chmod 750 /space/amandahold # su amb6fp $ mkdir /space/amandahold/test # mkdir /var/lib/amanda/test # chown amb6fp:disk /var/lib/amanda/test # chmod 750 /var/lib/amanda/test # su amb6fp $ touch /var/lib/amanda/test/tapelist
University of Virginia
Helali Bhuiyan
Now, we will create the virtual tapes, making sure the dumpuser amb6fp has access to the vtapes, but not everyone else on this server. # # # # $ $ $ $ mkdir /space/vtapes chown amb6fp:disk /space/vtapes chmod 750 /space/vtapes su amb6fp 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
The for loop above creates as many slots as you have specified in the tapecycle variable in the amanda.conf file. (Do not add a leading zero to the numbers.) Now a quick test to verify the virtual tape setup: $ ammt -f file:/space/vtapes/test/slots status If OK, the ammt command should give the following output, file:/space/vtapes/test/slots status: ONLINE Then label the tapes: $ for i in 1 2 3 4 5; do amlabel test TEST-$i slot $i; done This should give the following output, labeling tape in slot 1 (file:/space/vtapes/test/slots): rewinding, reading label, not an amanda tape (Read 0 bytes) rewinding, writing label TEST-1, checking label, done. labeling tape in slot 2 (file:/space/vtapes/test/slots): rewinding, reading label, not an amanda tape (Read 0 bytes) rewinding, writing label TEST-2, checking label, done. labeling tape in slot 3 (file:/space/vtapes/test/slots): rewinding, reading label, not an amanda tape (Read 0 bytes) rewinding, writing label TEST-3, checking label, done. labeling tape in slot 4 (file:/space/vtapes/test/slots): rewinding, reading label, not an amanda tape (Read 0 bytes) rewinding, writing label TEST-4, checking label, done. labeling tape in slot 5 (file:/space/vtapes/test/slots): rewinding, reading label, not an amanda tape (Read 0 bytes) rewinding, writing label TEST-5, checking label, done. And reset the changer to the first slot again: $ amtape test reset
University of Virginia
Helali Bhuiyan
This will give the following output, amtape: changer is reset, slot 1 is loaded. Thats the end of configuring the amanda.conf file. We will test this configuration later on, after doing some more setup given below.
University of Virginia
Helali Bhuiyan
Amanda is very strict about permissions to this file. The .amandahosts file also needs strict permissions. They should be owned by the Amanda user (amb6fp) and not be readable or writeable by anyone else. Also, the home directory of the Amanda user (containing the .amandahosts file) should not be writeable by anyone else. So do the following to set up appropriate access rights: # chown amb6fp ~/.amandahosts # chmod 755 ~amb6fp # chmod 600 ~amb6fp/.amandahosts Later you can check the access rights to this file by executing, $ ls l .amandahosts This should give the following output, [amb6fp@mvstu2 ~]$ ls -l .amandahosts -rw------- 1 amb6fp amb6fp 87 Jul 25 16:43 .amandahosts
University of Virginia
Helali Bhuiyan
Amanda ports). In the website, they gave configuring options for other daemon tools like inetd. But we will use xinetd. So, ignore the other configurations for inetd or Dan Bernstein's daemontools. To configure xinetd, you first need to check if you have xinetd or not. You can check if xinetd is already running in your system by running, [amb6fp@mvstu2 ~]$ sudo service xinetd status xinetd (pid 2077) is running... This will give the output above. Note that I have used sudo access to run this command. You can also run this command under the root account. You will need to have sudo access/root privilege to check any services status. If xinetd is not installed, you can do that by, # yum install xinetd Then check again if xinetd is running. As we just installed xinetd, now we can just configure it to add the Amanda service, and restart the xinetd server. To add Amanda to xinetd, add the file amanda to the directory /etc/xinetd.d/. So the complete path to this file is /etc/xinetd.d/amanda. Now, add the following lines to this file, service amanda { socket_type = dgram protocol = udp wait = yes user = amb6fp group = disk groups = yes server = /usr/local/libexec/amandad server_args = -auth=bsd amdump amindexd amidxtaped disable = no } NOTE: You should note that in the website (http://wiki.zmanda.com/index.php/Configuring_bsd/bsdudp/bsdtcp_authentication), they give some examples. There is another parameter, only_from. This parameter means accept connections only from these hosts. For now, do not use it. It gave me problem. Now we will restart the xinetd server to take this new configuration file into effect. Do this by, [amb6fp@mvstu2 xinetd.d]$ sudo service xinetd reload Reloading configuration: [ OK ]
University of Virginia
Helali Bhuiyan
10
University of Virginia
Helali Bhuiyan
NOTE: conf info dir /var/lib/amanda/test/curinfo does not exist NOTE: it will be created on the next run. NOTE: index dir /var/lib/amanda/test/index does not exist NOTE: it will be created on the next run. Server check took 0.071 seconds Amanda Backup Client Hosts Check -------------------------------WARNING: mvstu3.ece.virginia.edu: selfcheck request failed: timeout waiting for ACK Client check: 1 host checked in 30.237 seconds, 1 problem found (brought to you by Amanda 2.5.2p1) As you can see, there are multiple errors. Pick one by one. ERROR: program /usr/local/libexec/planner: not executable ERROR: program /usr/local/libexec/dumper: not executable So we will make these two files executable and set appropriate access rights, [root@wuneng libexec]# chmod 4755 planner [root@wuneng libexec]# chmod 4755 dumper Now run the amcheck again to see how far we have corrected, [amb6fp@mvstu2 libexec]$ amcheck test Amanda Tape Server Host Check ----------------------------Holding disk /space/amandahold/test: 27947920 KB disk space available, using 27947920 KB slot 1: read label `TEST-1', date `X' NOTE: skipping tape-writable test Tape TEST-1 label ok NOTE: conf info dir /var/lib/amanda/test/curinfo does not exist NOTE: it will be created on the next run. NOTE: index dir /var/lib/amanda/test/index does not exist NOTE: it will be created on the next run. Server check took 0.118 seconds Amanda Backup Client Hosts Check -------------------------------WARNING: mvstu3.ece.virginia.edu: selfcheck request failed: timeout waiting for ACK
11
University of Virginia
Helali Bhuiyan
Client check: 1 host checked in 30.155 seconds, 1 problem found (brought to you by Amanda 2.5.2p1) As you can see, the first two errors are gone. But we have failed to test the client. That means the Amanda server cannot connect to the client. But this is normal as we did not install the client yet. So we will install a client now.
12
University of Virginia
Helali Bhuiyan
13
University of Virginia
Helali Bhuiyan
# chown -R amb6fp:disk /usr/local/var/lib/amanda That is the end of the client configuration. Now we will test and resolve some problems.
16 Test
Run the amcheck command from the server machine (mvstu2). NOTE: Ensure that xinetd servers on both machines are running, and also any firewall is not blocking the traffic. If iptables is running, which is the firewall we use in our machines, you can check first if they are running by, # service iptables status If iptables is running (you will know by looking at the output of the previous command), you can either stop it for this test purpose (# service iptables stop), or add necessary rules to the iptables (that will allow traffic to the Amanda ports that we configured in the /etc/services file.). Now run the amcheck, [amb6fp@mvstu2 ~]$ amcheck test Amanda Tape Server Host Check ----------------------------Holding disk /space/amandahold/test: 27947884 KB disk space available, using 27947884 KB slot 1: read label `TEST-1', date `X' NOTE: skipping tape-writable test Tape TEST-1 label ok NOTE: conf info dir /var/lib/amanda/test/curinfo does not exist NOTE: it will be created on the next run. NOTE: index dir /var/lib/amanda/test/index does not exist NOTE: it will be created on the next run. Server check took 0.078 seconds Amanda Backup Client Hosts Check -------------------------------ERROR: NAK mvstu3.ece.virginia.edu: user amb6fp from 128.143.11.242 is not allowed to execute the service noop: Please add "amdump" to the line in /home/amb6fp/.amandahosts on the client Client check: 1 host checked in 0.204 seconds, 1 problem found
14
University of Virginia
Helali Bhuiyan
(brought to you by Amanda 2.5.2p1) As you can see that we have a new problem (ERROR at the bottom of this output). The solution to this problem is to change the .amandahosts file entries within the client machine (mvstu3). So, we will make the following changes in the .amandahosts file in mvstu3, 128.143.11.242 amb6fp amdump 128.143.11.242 root amindexd amidxtaped As you can see, I have changed the name of the server mvstu2.ece.virginia.edu to its corresponding IP address 128.143.11.242. I do not know the exact reason why Amanda gives this error, where we are supposed to write every address in url format (mvstu2.ece.virignia.edu). But in this case, unless we change the server name to its corresponding IP address, it does not work. Now run the amcheck again, [amb6fp@mvstu2 ~]$ amcheck test Amanda Tape Server Host Check ----------------------------Holding disk /space/amandahold/test: 27947884 KB disk space available, using 27947884 KB slot 1: read label `TEST-1', date `X' NOTE: skipping tape-writable test Tape TEST-1 label ok NOTE: conf info dir /var/lib/amanda/test/curinfo does not exist NOTE: it will be created on the next run. NOTE: index dir /var/lib/amanda/test/index does not exist NOTE: it will be created on the next run. Server check took 0.077 seconds Amanda Backup Client Hosts Check -------------------------------Client check: 1 host checked in 0.435 seconds, 0 problems found (brought to you by Amanda 2.5.2p1) So everything is OK now. We are done with the configuration successfully. Now we will do some actual dump.
15
University of Virginia
Helali Bhuiyan
17 Do the dump
Remember that in the disklist file inside the server, we said that we are going to dump the /home/amb6fp/amandatest directory from the client mvstu2. So you need to have this directory. If the directory is not there, make one and put some files in there for test, which we will dump on mvstu2, the server machine. Then we will do some recovery. To do the dump, run the following from the server machine. Remember, Amanda client does not dump the data; the server initiates the dump process (through the communication between the daemons). So run amdump from the mvstu2 machine, [amb6fp@mvstu2 ~]$ cd /var/lib/amanda/test/ [amb6fp@mvstu2 test]$ ls changerfile-access changerfile-clean changerfile-slot tapelist tapelist.amlabel [amb6fp@mvstu2 test]$ amdump test [amb6fp@mvstu2 test]$ ls amdump.1 changerfile-slot log.20070726225016.0 tapelist.amlabel changerfile-access curinfo oldlog tapelist.yesterday changerfile-clean index tapelist [amb6fp@mvstu2 test]$ In order to show that we actually dumped some data, I did something more than just running the amdump program. First, I showed the content of the /var/lib/amanda/test/ directory, which stores information related to each dump. As you can, there was no log file before the dump. Then I do the dump by running $ amdump test (amdump should be run under the Amanda user, not root). This command actually does the dump, fetches data from the client and writes them on the virtual tapes that we configured before. Then I showed the content of the directory again, and you can see that one log file and some other directories have been created. You should open the log file to see if everything went well. If everything went well, then you should see this in the log file, DISK planner mvstu3.ece.virginia.edu /home/amb6fp/amandatest START planner date 20070725192915 INFO planner Adding new disk mvstu3.ece.virginia.edu:/home/amb6fp/amandatest. START driver date 20070725192915 STATS driver hostname mvstu2 STATS driver startup time 0.032
16
University of Virginia
Helali Bhuiyan
START taper datestamp 20070725192915 label TEST-1 tape 0 FINISH planner date 20070725192915 time 0.429 SUCCESS dumper mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725192915 0 [sec 1.060 kb 8474 kps 7992.7 orig-kb 12710] SUCCESS chunker mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725192915 0 [sec 11.587 kb 8474 kps 734.1] STATS driver estimate mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725192915 0 [sec 6 nkb 12742 ckb 6400 kps 1024] SUCCESS taper mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725192915 0 [sec 0.059 kb 8480 kps 141392.2 {wr: writers 266 rdwait 0.013 wrwait 0.045 filemark 0.000}] INFO taper tape TEST-1 kb 8512 fm 1 [OK] FINISH driver date 20070725192915 time 13.089 NOTE: If the iptables firewall blocks traffic, then you may see this, DISK planner mvstu3.ece.virginia.edu /home/amb6fp/amandatest START planner date 20070725193103 INFO planner Adding new disk mvstu3.ece.virginia.edu:/home/amb6fp/amandatest. START driver date 20070725193103 STATS driver hostname mvstu2 STATS driver startup time 0.031 START taper datestamp 20070725193103 label TEST-1 tape 0 FINISH planner date 20070725193103 time 0.466 FAIL chunker mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725193103 0 [cannot read header: got 0 instead of 32768] FAIL driver mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725193103 0 [too many dumper retry: "[request failed: timeout waiting for ACK]"] FAIL chunker mvstu3.ece.virginia.edu /home/amb6fp/amandatest 20070725193103 0 [cannot read header: got 0 instead of 32768] INFO taper tape TEST-1 kb 0 fm 0 [OK] FINISH driver date 20070725193103 time 46.898 In that case, either stop the firewall, or configure the firewall to allow Amanda traffic.
17
University of Virginia
Helali Bhuiyan
on
As you can see, we have an ftp-like command prompt. We will use some commands to recover some data. Some useful commands are: help: lists all the available commands listhost: shows all the clients that are being dumped on this server listdisk: show all the directories of a certain client that are being dumped
18
University of Virginia
Helali Bhuiyan
sethost hostname: sets the hostname setdisk diskname: sets the disk (or directory) to do the recovery history: shows the dump history for a disk. History means on which date and time dumps were made. setdate: sets date of the dump add: adds a file to be extracted extract: extracts all the files that has been added to the list by the add command [root@mvstu3 amandatest]# amrecover test AMRECOVER Version 2.5.2p1. Contacting server on mvstu2.ece.virginia.edu ... 220 mvstu2 AMANDA index server (2.5.2p1) ready. Setting restore date to today (2007-07-26) 200 Working date set to 2007-07-26. 200 Config set to test. 501 Host mvstu3 is not in your disklist. Use the sethost command to choose a host to recover amrecover> listhost 200- List hosts for config test 201- mvstu3.ece.virginia.edu 200 List hosts for config test amrecover> sethost mvstu3.ece.virginia.edu 200 Dump host set to mvstu3.ece.virginia.edu. amrecover> listdisk 200- List of disk for host mvstu3.ece.virginia.edu 201- /home/amb6fp/amandatest 200 List of disk for host mvstu3.ece.virginia.edu amrecover> setdisk /home/amb6fp/amandatest 200 Disk set to /home/amb6fp/amandatest. amrecover> history 200Dump history for config "test" host "mvstu3.ece.virginia.edu" disk /home/amb6fp/amandatest 201- 2007-07-26-23-12-25 1 TEST-2:1 201- 2007-07-26-23-11-45 0 TEST-1:1 200 Dump history for config "test" host "mvstu3.ece.virginia.edu" disk /home/amb6fp/amandatest amrecover> setdate 2007-07-26-23-12-25 200 Working date set to 2007-07-26-23-12-25. amrecover> ls 2007-07-26-23-12-25 tracer/ 2007-07-26-23-12-25 nscode/ 2007-07-26-23-12-25 memtomem_old/ 2007-07-26-23-12-25 memtomem/ 2007-07-26-23-12-25 Server.java
19
University of Virginia
Helali Bhuiyan
2007-07-26-23-12-25 FileCreator.java 2007-07-26-23-12-25 Client.java 2007-07-26-23-12-25 CTCP-wad/ 2007-07-26-23-12-25 . amrecover> add Server.java Added file /Server.java amrecover> add Client.java Added file /Client.java amrecover> extract Extracting files using file:/space/vtapes/test/slots mvstu2.ece.virginia.edu. The following tapes are needed: TEST-2 tape on drive host
Restoring files into directory /home/amb6fp/amandatest Continue [?/Y/n]? y Extracting files using file:/space/vtapes/test/slots mvstu2.ece.virginia.edu. Load tape TEST-2 now Continue [?/Y/n/s/t]? y ./Client.java ./Server.java amrecover> quit 200 Good bye. tape on drive host
In the example above, we used some commands to see the host list, disk list, and files that were dumped on the server. First, we checked host names by running the listhost command. Then we set the host to mvstu3.ece.virginia.edu by using sethost command. Similarly, we set the disk that we want to recover. Then we use the history command to see the dump history, and later we select a specific date of dump by using the setdate command. To actually restore some files, we first add those files by using the add command. Later, when we are done with selecting which files to recover by using the add command, we use the extract command to finally restore the files. Later you can check your original directory to see if we really restored the data correctly.
20
University of Virginia
Helali Bhuiyan
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. $ for i in 1 2 3 4 5; do amlabel test TEST-$i slot $i; done $ amtape test reset
21