Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 103 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
103
Dung lượng
1,8 MB
Nội dung
The output of the cdrecord command follows. The line that shows the CD drive type and manufacturer is the one you are interested in. At the beginning of the line is the SCSI ID information shown as 1,0,0, which is the SCSI device number (1), the logical unit number (0), and the device ID (0). cdrecord-Clone 2.01-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling Note: This version is an unofficial (modified) version with DVD support Note: and therefore may have bugs that are not present in the original. Note: Please send bug reports or support requests to http://bugzilla.redhat.com/bugzilla Note: The author of cdrecord should not be bothered with problems in this version. scsidev: ‘ATA’ devname: ‘ATA’ scsibus: -2 target: -2 lun: -2 Linux sg driver version: 3.5.27 Using libscg version ‘schily-0.8’. cdrecord: Warning: using inofficial libscg transport code version (schily - Red Hat-scsi-linux-sg.c-1.83-RH ‘@(#)scsi-linux-sg.c 1.83 04/05/20 Copyright 1997 J. Schilling’). scsibus1: 1,0,0 100) ‘HL-DT-ST’ ‘RW/DVD GCC-4243N’ ‘1.07’ Removable CD-ROM 1,1,0 101) * 1,2,0 102) * 1,3,0 103) * 1,4,0 104) * 1,5,0 105) * 1,6,0 106) * 1,7,0 107) * You supply the SCSI device number, the device ID, and the logical unit num- ber to the cdrecord command, in that order, as part of the dev option. Asam- ple cdrecord command is as follows: cdrecord -v dev=1,0,0 -data /tmp/cd.image This command does not generally produce a bootable CD. For a CD to be bootable, the image file being recorded onto the CD needs to follow a specific format. Also, your BIOS must support booting from your particular CD-ROM. To produce a bootable image file, you need to follow several steps. First, you need to obtain a boot image. If you have a bootable CD-ROM in the disk drive, the boot image can be written to a file with the following command: dd if=/dev/fd0 of=boot.img bs=10k count=144 TIP One handy boot image is the diskboot.img, which is on disk one of the Fedora Core and Red Hat Enterprise installation disks. 788 Chapter 31 39_599496 ch31.qxd 8/30/05 7:13 PM Page 788 This command puts the boot image in the file boot.img. You must put this somewhere in the directory that you are going to put on the CD. In the exam- ple provided, you could create a directory /home/terry/boot and place the file there. You also need to give mkisofs some extra parameters to have it cre- ate a bootable image. mkisofs -r -b /home/terry/boot/boot.img -c /home/terry/boot/boot.catalog -o /tmp/cd.image /home/terry The boot.catalog file need not already exist. It is generated by mkisofs. The command line option just tells mkisofs where in the image to store the generated file. Using dump The dump package consists of several commands for backing up and restoring the file system. The dump command is used to do backups of either entire par- titions or individual directories of ext2 and ext3 file systems. The restore command is used to restore an entire partition, individual directories, or indi- vidual files. Syntax of the dump Command The first argument to the dump command is a list of options. Following that are all arguments required by the various options in the same order as the options were specified. The last argument is the file system to back up. Table 31-2 lists the available dump options. Table 31-2 Dump Options OPTION MEANING TYPE B The number of records per volume Number b The number of kilobytes per dump record Number h The dump level at which to use nodump flags Number f Name of file or device to write to Filename d Tape density Number n Tell dump to send a message when done None s Length of dump tape Number in feet u Record the date of this dump in /etc/dumpdates None T Add only files older than the given time Time (ctime) (continued) Backing Up and Restoring the File System 789 39_599496 ch31.qxd 8/30/05 7:13 PM Page 789 Table 31-2 (continued) OPTION MEANING TYPE W List the file systems that need to be backed up None w List individual files that need to be backed up None 0–9 Specify a dump level of 0 through 9 None CAUTION Using dump on a live file system can be dangerous and unreliable. For more information on this topic, see redhat.com/archives/ext3-users /2003-January/msg00034.html. Sample dump Command If you want to see a sample of the output from the dump command, try enter- ing the command shown here: dump 0uf /dev/nst0 /dev/hda3 This command specifies that the file system on /dev/hda3should be backed up on the magnetic tape on device /dev/nst0. It specifies that the backup should use backup level 0 (full backup) and write the time of the backup to the /etc/dumpdates file. The /etc/dumpdates file is used to keep track of the dates when your information was backed up. Using restore The restore command is used to retrieve files from the backups created with dump. You can use restore to restore an entire file system or you can use it to interactively select which files you want to restore. The syntax for the restore command is the same as that for the dump com- mand, although it has different options. Table 31-3 lists the options. Table 31-3 Restore Options OPTION MEANING TYPE r Restores the entire dump archive None C Compares the files on the file system to those None in the dump archive R Starts the restore from a particular tape in a None multivolume sequence 790 Chapter 31 39_599496 ch31.qxd 8/30/05 7:13 PM Page 790 Table 31-3 (continued) OPTION MEANING TYPE x Extracts only specified files List of files t Lists the contents of the dump archive List of files I Restores files in interactive mode None b Blocks size of the dump in kilobytes Number D Names the file system to be compared against File system f Names dump archive to restore from Filename h Recreates directories but does not restore None their contents m Extracts files by inode number instead of name None N Prints filenames rather than extracting them None s Specifies the tape number to start on when Number using the R option T Specifies where to write temporary files Directory v Specifies verbose mode None y Does not prompt when bad blocks are encountered None Restoring the File System To restore a damaged or erased file system, you must first recreate the direc- tory or partition that has been lost. If, for instance, you want to recreate the /home directory, which existed by itself on the /dev/hdb1 partition, you could use the following commands: mkfs /dev/hdb1 mount /dev/hdb1 /home Note that this command erases all of the data on the /dev/hdb1 partition. This method of restoration is useful only for restoring all of the files previously archived with dump. If any files have been added, modified, or deleted since the last backup, those changes are lost. Restoring individual files is covered in the section “Using Restore Interactively.” Also, if mkfs is accidentally run on a different partition than the one meant to be restored, all of the data on the par- tition on which it is mistakenly run is irrevocably erased. The restore command must be run inside the directory that is going to be restored. So, restore can restore the /home directory with the following commands: Backing Up and Restoring the File System 791 39_599496 ch31.qxd 8/30/05 7:13 PM Page 791 cd /home restore rf /dev/nst0 The r flag tells restore to restore the entire archive rather than just some files. The f flag tells restore that the archive is located on the device /dev/rft0. Using restore Interactively The restore command, in addition to being used to restore an entire file sys- tem, can also be used in an interactive mode, which enables you to restore individual files. The interactive mode is invoked as follows: restore if /dev/nst0 This command runs restore in interactive mode and specifies that it should restore from the archive on the device /dev/rft0. The interactive mode enables you to type options to restore and lets you control restore’s behavior. It includes the options shown in Table 31-4. Table 31-4 Restore Commands COMMAND MEANING add Adds a file or directory to the list of files to be extracted. If a directory is specified, all contained files, subdirectories, and files contained in subdirectories are extracted. File paths are relative to the current directory being viewed in the dump archive. cd Changes which directory within the dump archive is being viewed. delete Removes a file or directory from the list of files to be extracted. If a directory is specified, all files in that directory, subdirectories, and files in subdirectories are removed from the list as well. Note that this does not affect what is stored in the dump archive, but rather which files are extracted during the restore. extract Extracts all files and directories currently in the list of files to extract and restores them in the file system. help Lists available commands. ls Lists the contents of the directory currently being viewed in the dump archive. If a directory is specified, the contents of the specified directory are listed rather than the contents of the current directory. Files and directories marked with * in the file listing are currently marked for extraction. pwd Prints the path within the dump archive of the directory currently being viewed. 792 Chapter 31 39_599496 ch31.qxd 8/30/05 7:13 PM Page 792 Table 31-4 (continued) COMMAND MEANING quit Exits the restore program. No other actions are taken by restore. setmodes Rather than extracting the files, this sets the permissions on the files in the file system so that they match the permissions of the files in the dump archive that are marked for extraction. verbose Switches verbose mode on or off. Using tar Fedora Core and Red Hat Enterprise Linux include the GNU version of tar. It includes some extensions to the older standard versions of tar, including multi- volume archiving, an automated process in which tar prompts for new media to be inserted whenever it runs out of space. The tar program is a utility originally designed for making magnetic tape backups, but is useful for any kind of archiving purpose. When making archives, it is important to specify a leading ./ for files. That creates a relative path, which will be necessary when restoring the files later. The tar command requires one command option followed by any number of optional options. Table 31-5 lists the command options. Table 31-5 tar Options COMMAND EXPLANATION A Appends the contents of the given tar files to the specified tar archive. d Finds differences between what’s in the tar archive and what’s in the file system. j Filters the archive through the bzip filter. Used to compress or decompress files ending with bz2 extension. r Appends the given files to the specified tar archive. t Lists the contents of the specified tar archive. u Appends the given files to the specified tar archive, but only if they are newer than the files in the tar archive. x Extracts the given files from the specified tar archive. z Filters the archive through the gzip filter. Used to compress or decompress files ending with gz extension. Backing Up and Restoring the File System 793 39_599496 ch31.qxd 8/30/05 7:13 PM Page 793 In addition to specifying a command, you must specify a device or file to act as the destination of the tar archive. Creating a tar Archive The tar command was originally designed to create tape archives; in fact tar is a contraction of tape archive. But, you can create tar archives and save them anywhere on your system, not just to a tape drive. To create a tar file use the following command syntax. tar cvf (name of tar file to create) (list of files to add) If you wanted to create a tar file of the files testing1.txt, test- ing2.txt, and testing3.txt and place them into a tar archive called testing.tar, you would issue this command: tar cvf testing.tar testing1.txt testing2.txt testing3.txt In this example, you could use wildcards to make your job easier by using testing*.txt instead of typing the filenames individually. You can also use tar to back up entire directories by issuing the directory name you want to tar instead of filenames. For example, if you wanted to tar a directory called ch4 to the tape drive, you would issue this command: tar cvf /dev/st0 ch4 This command would create a tar file called ch4.tar that would contain the contents of ch4, including all files as well as any subdirectories and rewind the tape to the beginning. Extracting a Tar Archive To extract a tar archive, use the following syntax: tar x (name of tar file) To extract the tar file created in the previous section, issue this command: tar x testing.tar This would extract the files from the tar file and place them in the current directory. If you extract a tar file containing a directory and subdirectories, if any, the directory and its subdirectories will be extracted into their original directory structure at the location from where the tar command was issued. For example, to extract the sample directory you created previously, you would type the following: tar xvf /dev/st0 794 Chapter 31 39_599496 ch31.qxd 8/30/05 7:13 PM Page 794 This command would extract the sample directory, and any files or subdi- rectories it contained, from the tape and place it at the location from where the tar command was run. Advanced Tools This section discusses a number of advanced backup tools, including AMANDA, the amdump test, and pax. Using AMANDA The Advanced Maryland Automatic Network Disk Archiver (AMANDA) package is a set of tools for doing backups of multiple machines over the net- work. Using AMANDA, you can configure your Red Hat Linux machine to be a centralized backup server for the other machines in the network, including Windows systems. AMANDA is included with Fedora Core and Red Hat Enterprise Linux. To use AMANDA, install the following packages: ■■ amanda ■■ amanda-client ■■ amanda-server ■■ Gnuplot You need to install the amanda-server and gnuplot packages only on the machine that is going to be the backup server. However, you must install amanda-client on any machine that you want to back up using AMANDA. You must install the base amanda package on both the client and server machines. The amanda package contains several commands, shown in Table 31-6. Table 31-6 AMANDA Commands COMMAND USE amdump Normally executed periodically by a cron job, this utility is run on the AMANDA server. It requests backups from the various AMANDA clients. amflush If amdump has trouble writing backups to tape, they are kept in temporary storage space on disk until the problem is corrected. After the problem is fixed, this command is run to write the data in the temporary storage space to the tapes. amcleanup If the AMANDA server crashes during the running of amdump, this utility should be run to clean up after the interrupted amdump. (continued) Backing Up and Restoring the File System 795 39_599496 ch31.qxd 8/30/05 7:13 PM Page 795 Table 31-6 (continued) COMMAND USE amrecover This utility provides a way to select which tapes should be used to recover files. amrestore This utility is used to restore individual files or directories or entire partitions from AMANDA backups. amlabel This utility is used to write an AMANDA label onto a tape. You must use this command to label tapes before they can be written to with amdump. amcheck This utility should be run before amdump to verify that the correct tape is in the drive. amadmin This utility does various administrative tasks. amtape This utility is used for low-level tape control, such as loading and ejecting disks. amverify This utility checks AMANDA tapes for errors. amrmtape This utility deletes a tape with a particular label from the AMANDA tape database. amstatus This utility reports on the current status of a running amdump program. Installing AMANDA After installing the necessary RPMs, some additional installation is required to get AMANDA running. You must create subdirectories in the /etc/amanda and /usr/admn/amanda directories for each backup schedule you are going to run. For instance, if you plan to run a backup schedule called test, you must execute the following commands: mkdir -p /etc/amanda/test mkdir -p /usr/admn/amanda/normal You also need to create some temporary space for AMANDA to keep files, which it is in the process of backing up. So if, for instance, you want to create this space as a directory on your root partition, you can use the following com- mand to make an amanda directory: mkdir /amanda 796 Chapter 31 39_599496 ch31.qxd 8/30/05 7:13 PM Page 796 Configuring AMANDA To configure AMANDA, you must make changes to the amanda.conf file and put it in the subdirectory in /etc/amanda that you created. A sample amanda.conf file is created during AMANDAinstallation. So in the example, for instance, it would be called /etc/amanda/test/amanda.conf. The amanda.conf file has many options, shown in Table 31-7, but has defaults for most of them. Table 31-7 amanda.conf Options OPTION EXAMPLE MEANING org “name” org This option specifies the name “Tristero” used in reports generated by AMANDA. mailto mailto “root This option specifies account names that “accounts” example” Amanda should put in charge of the backup process. dumpuser dumpuser This option specifies the user account that “account” “Amanda” the AMANDA dump process should run as. inparallel inparallel 5 This entry specifies the number of amdump number processes that can run simultaneously. netusage netusage This entry indicates the bandwidth that num unit 1000 Kpbs AMANDA is allowed to consume while doing backups. It should be set such that even if all of the allocated bandwidth is consumed there is still enough bandwidth for other tasks that might operate at the same time as the AMANDA backup process. dumpcycle dumpcycle This option specifies the length of the num unit 1 week backup cycle. runspercycle runspercycle 7 This option specifies the number of num backups that should be done during a single dump cycle. So, with a dump cycle of 1 week and seven runs per cycle, AMANDA makes one full backup and six incremental backups every week. tapespercycle tapespercycle This option specifies how many tapes are num unit 7 tapes available for use in a single backup cycle. runtapes num runtapes 1 This option specifies how many tapes are available for use in each backup. tapedev tapedev This option specifies the device name of “device” “/dev/rft0” the tape device. Backing Up and Restoring the File System 797 39_599496 ch31.qxd 8/30/05 7:13 PM Page 797 [...]... wa 93 3 4 0 94 6 0 0 93 7 0 0 94 6 0 0 93 7 0 0 Performance Monitoring What information is shown? In the procs section, the r column shows the number of processes that are ready to run and waiting for their turn to run on the CPU and the b column shows the number of processes that are blocked, or sleeping, and thus not ready to run In the first example, therefore, two processes are ready to run and. .. 11458 11478 11458 1 199 2 12001 12002 12002 12113 SID TTY 12002 pts/2 12002 pts/2 PGID 11458 11478 1 199 2 12002 12113 SID 11458 11458 11458 12002 12002 TIME CMD 00:00:00 bash 00:00:00 ps TTY pts/1 pts/1 pts/1 pts/2 pts/2 TPGID 1 199 2 1 199 2 1 199 2 12113 12113 STAT Ss S S+ Ss R+ UID 500 500 500 500 500 TIME 0:00 0:08 0:00 0:00 0:00 COMMAND /bin/bash jpilot more ps.txt /bin/bash ps j The Unix98 format produced... 114484 347584 0 0 13 49 1342 1437 cpu -us sy id wa 93 3 4 0 91 9 0 0 92 8 0 0 94 6 0 0 92 8 0 0 Under the swap heading, si shows the amount of memory that has been read in from the swap device (or devices, if there are multiple swap files or partitions) and so the amount of memory that has been written out to a swap device As you can see in the example just shown, swap usage on this system, even during... compression algorithm that results in the highest compression levels server fast This option specifies that the server should use the fastest compression algorithm Table 31-10 AMANDA Dumping Strategies STRATEGY EXPLANATION standard This option specifies that AMANDA should use the standard dumping strategy, which includes both full and incremental backups nofull This option specifies that AMANDA should use... and never do full backups This is useful when a set of machines all have the same base installation and setup with only minor differences that do not change rapidly Amanda then saves space by backing up only the changes that occur over time (continued) 801 802 Chapter 31 Table 31-10 (continued) STRATEGY EXPLANATION noinc This option specifies that incremental backups should never occur and that AMANDA... permissions of this file to 600 using chmod That ensures that only root can modify the file and other users cannot add hosts to the file, thus bypassing the permission system and gaining access to the full file system Performing Backups with AMANDA To perform a backup, you simply run amdump with the name of the backup that you want to run The configuration information and list of partitions to back up are... learned how to back up and restore your file system You learned how to choose which files are important to back up and to choose a backup medium, a backup method, and a tape rotation schedule appropriate for the needs of your situation You also learned how to use low-level archiving tools such as tar and dump to produce archives and file system data and to restore corrupted file system data from archives... covered here The -d option invokes iostat’s disk utilization mode; all the examples in this section use it because doing so disables CPU utilization reports iostat’s default output should resemble the following: $ iostat -d Linux 2.6.10-1.770_FC3.root (beast.example.com) Device: hda hdb hdd tps 1.30 0.46 0.00 Blk_read/s 11.46 2 .99 0.00 Blk_wrtn/s 9. 79 4.06 0.00 05/05/2005 Blk_read 399 6171 104 397 6 680... Table 31 -9 AMANDA Compression Types TYPE EXPLANATION none This option specifies that no compression should be used on AMANDA backups client best This option specifies that the client should use the compression algorithm that results in the highest compression levels client fast This option specifies that the client should use the fastest compression algorithm server best This option specifies that the... the system, the greater the fluctuation If you specify -a, inact and active replace the buff and cache columns under the memory heading inact displays the amount of inactive memory and active displays the amount of active memory Inactive memory is the buffer memory the free command shows as free (unused) when buffer adjustments are enabled; active memory is memory that is both allocated and in use and . following com- mand to make an amanda directory: mkdir /amanda 796 Chapter 31 39_ 599 496 ch31.qxd 8/30/05 7:13 PM Page 796 Configuring AMANDA To configure AMANDA, you must make changes to the amanda.conf. command must be run inside the directory that is going to be restored. So, restore can restore the /home directory with the following commands: Backing Up and Restoring the File System 791 39_ 599 496 . including Windows systems. AMANDA is included with Fedora Core and Red Hat Enterprise Linux. To use AMANDA, install the following packages: ■■ amanda ■■ amanda-client ■■ amanda-server ■■ Gnuplot You