RHEL6 虚拟磁带机使用指南

字体大小: 中小 标准 ->行高大小: 标准
在linux上学习备份命令tar的时候,有提到使用磁带机将数据备份到磁带,但对于学习者来说,很少有机会使用真正的磁带机,只有在归档海量数据的时候,磁带机会比较常见,在使用Oracle rman进行备份和恢复的时候也需要磁带机,因而本章介绍下如何在rhel6 64位操作系统下模拟磁带机和模拟磁带机的简单使用。

一:配置相关环境,编译安装mhvtl.tgz(linux 虚拟带库)

  1. [root@rhel6 src]# tar -zxvf mhvtl.tgz   [root@rhel6 src]# cd mhvtl-0.18/  
  2. [root@rhel6 mhvtl-0.18]# yum -y install zlib-devel mtx mt-st lsscsi  [root@rhel6 mhvtl-0.18]# useradd vtl  
  3. [root@rhel6 mhvtl-0.18]# echo '123456' |passwd --stdin vtl  Changing password for user vtl.  
  4. passwd: all authentication tokens updated successfully.   
  5. [root@rhel6 mhvtl-0.18]# mkdir /opt/mhvtl    //虚拟带库存储路径  [root@rhel6 mhvtl-0.18]# mkdir /etc/mhvtl    //配置文件路径  
  6. [root@rhel6 mhvtl-0.18]# chown -R vtl.vtl /opt/mhvtl/ /etc/mhvtl/   
  7. [root@rhel6 mhvtl-0.18]# cd kernel/  //需要安装kernel-devel和kernke-headers软件包,否则以下编译会报错  [root@rhel6 kernel]# ls  
  8. fetch24.c  fetch26.c  fetch27.c  fetch.c  Makefile  mhvtl.c  mhvtl-kmod.spec  vtl_common.h  [root@rhel6 kernel]# make && make install  
  9. [root@rhel6 kernel]# modprobe mhvtl  [root@rhel6 kernel]# lsmod  |grep mhvtl   
  10. mhvtl                  26165  0    
  11. [root@rhel6 kernel]# cd ..  [root@rhel6 mhvtl-0.18]# make && make install  
  12.  [root@rhel6 mhvtl-0.18]# /etc/init.d/mhvtl start  //启动mhvtl程序  
  13. vtltape: version 0.18.10  vtltape: version 0.18.10  
  14. vtltape: version 0.18.10  vtltape: version 0.18.10  
  15. vtltape: version 0.18.10  vtltape: version 0.18.10  
  16. vtltape: version 0.18.10  vtltape: version 0.18.10  
  17. vtllibrary: version 0.18.10  vtllibrary process PID is 14448  
  18. vtllibrary: version 0.18.10  vtllibrary process PID is 14451  
  19.  [root@rhel6 mhvtl-0.18]# ls /etc/mhvtl/  
  20. device.conf  library_contents.10  library_contents.30  mhvtl.conf  [root@rhel6 mhvtl-0.18]# ls /opt/mhvtl/  
  21. CLN101L4  E01002L4  E01007L4  E01012L4  E01017L4  E03002L4  E03007L4  E03012L4  E03017L4  F01031L5  F01036L5  F03031L5  F03036L5  CLN102L5  E01003L4  E01008L4  E01013L4  E01018L4  E03003L4  E03008L4  E03013L4  E03018L4  F01032L5  F01037L5  F03032L5  F03037L5  
  22. CLN301L4  E01004L4  E01009L4  E01014L4  E01019L4  E03004L4  E03009L4  E03014L4  E03019L4  F01033L5  F01038L5  F03033L5  F03038L5  CLN302L5  E01005L4  E01010L4  E01015L4  E01020L4  E03005L4  E03010L4  E03015L4  E03020L4  F01034L5  F01039L5  F03034L5  F03039L5  
  23. E01001L4  E01006L4  E01011L4  E01016L4  E03001L4  E03006L4  E03011L4  E03016L4  F01030L5  F01035L5  F03030L5  F03035L5 

二:查看带库相关信息

  1. [root@rhel6 mhvtl-0.18]# lsscsi -g  [0:0:0:0]    disk    ATA      ST3160815AS      4.AA  /dev/sda   /dev/sg0  
  2. [8:0:0:0]    storage IET      Controller       0001  -         /dev/sg1  [8:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb   /dev/sg2  
  3. [9:0:0:0]    mediumx STK      L700             550V  /dev/sch0  /dev/sg11  //为带库机械手  [9:0:1:0]    tape    IBM      ULT3580-TD5      550V  /dev/st0   /dev/sg3  
  4. [9:0:2:0]    tape    IBM      ULT3580-TD5      550V  /dev/st1   /dev/sg4  [9:0:3:0]    tape    IBM      ULT3580-TD4      550V  /dev/st2   /dev/sg5  
  5. [9:0:4:0]    tape    IBM      ULT3580-TD4      550V  /dev/st3   /dev/sg6  [9:0:8:0]    mediumx SPECTRA  PYTHON           550V  /dev/sch1  /dev/sg12  //为带库机械手  
  6. [9:0:9:0]    tape    IBM      ULT3580-TD4      550V  /dev/st4   /dev/sg7  [9:0:10:0]   tape    IBM      ULT3580-TD4      550V  /dev/st5   /dev/sg8  
  7. [9:0:11:0]   tape    IBM      ULT3580-TD4      550V  /dev/st6   /dev/sg9  [9:0:12:0]   tape    IBM      ULT3580-TD4      550V  /dev/st7   /dev/sg10  
  8.   
  9. [root@rhel6 mhvtl-0.18]# lsscsi -l  [0:0:0:0]    disk    ATA      ST3160815AS      4.AA  /dev/sda   
  10.   state=running queue_depth=31 scsi_level=6 type=0 device_blocked=0 timeout=30 [8:0:0:0]    storage IET      Controller       0001  -         
  11.   state=running queue_depth=32 scsi_level=6 type=12 device_blocked=0 timeout=0 [8:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb   
  12.   state=running queue_depth=32 scsi_level=6 type=0 device_blocked=0 timeout=30 [9:0:0:0]    mediumx STK      L700             550V  /dev/sch0  
  13.   state=running queue_depth=32 scsi_level=6 type=8 device_blocked=0 timeout=0 [9:0:1:0]    tape    IBM      ULT3580-TD5      550V  /dev/st0   
  14.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:2:0]    tape    IBM      ULT3580-TD5      550V  /dev/st1   
  15.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:3:0]    tape    IBM      ULT3580-TD4      550V  /dev/st2   
  16.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:4:0]    tape    IBM      ULT3580-TD4      550V  /dev/st3   
  17.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:8:0]    mediumx SPECTRA  PYTHON           550V  /dev/sch1  
  18.   state=running queue_depth=32 scsi_level=6 type=8 device_blocked=0 timeout=0 [9:0:9:0]    tape    IBM      ULT3580-TD4      550V  /dev/st4   
  19.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:10:0]   tape    IBM      ULT3580-TD4      550V  /dev/st5   
  20.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:11:0]   tape    IBM      ULT3580-TD4      550V  /dev/st6   
  21.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 [9:0:12:0]   tape    IBM      ULT3580-TD4      550V  /dev/st7   
  22.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900     
  23. [root@rhel6 ~]# mtx -f /dev/sg11 status    Storage Changer /dev/sg11:4 Drives, 43 Slots ( 4 Import/Export )  
  24. Data Transfer Element 0:Empty  Data Transfer Element 1:Empty  
  25. Data Transfer Element 2:Empty  Data Transfer Element 3:Empty  
  26. ————————输出省略————————————   
  27. [root@rhel6 ~]# mtx -f /dev/sg11 load 1 0  //将磁带从1号槽位装入driver 0Loading media from Storage Element 1 into drive 0...done  
  28.  [root@rhel6 ~]# mtx -f /dev/sg11 status  
  29.   Storage Changer /dev/sg11:4 Drives, 43 Slots ( 4 Import/Export )  Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = E01001L4                              
  30. Data Transfer Element 1:Empty  Data Transfer Element 2:Empty  
  31. Data Transfer Element 3:Empty       ————————输出省略———————————— 

三:使用磁带机,nst0代表不回卷设备

  1. 1.将数据归档到模拟磁带机  [root@rhel6 media]# mt -f /dev/nst0 tel  
  2. At block 0.  [root@rhel6 media]# tar -cvf /dev/nst0 张敬轩\ -\ 定局\ -\ 盛世仁杰主题曲.mp3   
  3. 张敬轩 - 定局 - 盛世仁杰主题曲.mp3  [root@rhel6 media]# mt -f /dev/nst0 tel  
  4. At block 350.   
  5. 2.倒带至磁带头并查看磁带内容,查看完内容后,会把磁带指针停止在内容位置后  [root@rhel6 media]# mt -f /dev/nst0 rewind  
  6. [root@rhel6 media]# mt -f /dev/nst0 tel  At block 0.  
  7. [root@rhel6 media]# tar -tvf /dev/nst0  -rw-r--r-- nobody/nobody 3569715 2010-07-26 04:54 张敬轩 - 定局 - 盛世仁杰主题曲.mp3  
  8. [root@rhel6 media]# mt -f /dev/nst0 tel  At block 349.  
  9.  3.继续添加文件至磁带机  
  10. [root@rhel6 media]# tar -cvf /dev/nst0 /boot/vmlinuz-2.6.32-71.el6.x86_64   /boot/vmlinuz-2.6.32-71.el6.x86_64  
  11. [root@rhel6 media]# mt -f /dev/nst0 tel  At block 721.  
  12.  4.从磁带机中导出归档文件  
  13. [root@rhel6 media]# mt -f /dev/nst0 rewind       [root@rhel6 media]# tar -tvf /dev/nst0  
  14. -rw-r--r-- nobody/nobody 3569715 2010-07-26 04:54 张敬轩 - 定局 - 盛世仁杰主题曲.mp3   
  15. [root@rhel6 media]# mt -f /dev/nst0 rewind  [root@rhel6 media]# rm -i 张敬轩\ -\ 定局\ -\ 盛世仁杰主题曲.mp3    //删除本地文件  
  16. rm: remove regular file `张敬轩 - 定局 - 盛世仁杰主题曲.mp3'? y   
  17. [[root@rhel6 media]# tar -xvf /dev/nst0          //导出第一个文件  张敬轩 - 定局 - 盛世仁杰主题曲.mp3  
  18.  [root@rhel6 media]# tar -xvf /dev/nst0           //导出第二个文件  
  19. boot/vmlinuz-2.6.32-71.el6.x86_64   
  20. 验证:  [root@rhel6 media]# ls  
  21. boot  张敬轩 - 定局 - 盛世仁杰主题曲.mp3  [root@rhel6 media]# ls boot/  
  22. vmlinuz-2.6.32-71.el6.x86_64   
  23.  5.清除磁带机中的数据并倒带至磁带头  
  24. [root@rhel6 media]# mt -f /dev/nst0 erase  [root@rhel6 media]# mt -f /dev/nst0 tel  
  25. At block 0. 

四:卸载磁带机

  1. [root@rhel6 media]# mtx -f /dev/sg11 unload 1 0  Unloading drive 0 into Storage Element 1...done 

附上HP磁带机的简单使用说明,见 http://www.linuxidc.com/Linux/2011-12/49156p2.htm

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/58472.html