歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

RHEL6 虛擬磁帶機使用指南

在linux上學習備份命令tar的時候,有提到使用磁帶機將數據備份到磁帶,但對於學習者來說,很少有機會使用真正的磁帶機,只有在歸檔海量數據的時候,磁帶機會比較常見,在使用Oracle rman進行備份和恢復的時候也需要磁帶機,因而本章介紹下如何在rhel6 64位操作系統下模擬磁帶機和模擬磁帶機的簡單使用。

一:配置相關環境,編譯安裝mhvtl.tgz(linux 虛擬帶庫)

  1. [root@rhel6 src]# tar -zxvf mhvtl.tgz   
  2. [root@rhel6 src]# cd mhvtl-0.18/  
  3. [root@rhel6 mhvtl-0.18]# yum -y install zlib-devel mtx mt-st lsscsi  
  4. [root@rhel6 mhvtl-0.18]# useradd vtl  
  5. [root@rhel6 mhvtl-0.18]# echo '123456' |passwd --stdin vtl  
  6. Changing password for user vtl.  
  7. passwd: all authentication tokens updated successfully.  
  8.  
  9. [root@rhel6 mhvtl-0.18]# mkdir /opt/mhvtl    //虛擬帶庫存儲路徑  
  10. [root@rhel6 mhvtl-0.18]# mkdir /etc/mhvtl    //配置文件路徑  
  11. [root@rhel6 mhvtl-0.18]# chown -R vtl.vtl /opt/mhvtl/ /etc/mhvtl/  
  12.  
  13. [root@rhel6 mhvtl-0.18]# cd kernel/  //需要安裝kernel-devel和kernke-headers軟件包,否則以下編譯會報錯  
  14. [root@rhel6 kernel]# ls  
  15. fetch24.c  fetch26.c  fetch27.c  fetch.c  Makefile  mhvtl.c  mhvtl-kmod.spec  vtl_common.h  
  16. [root@rhel6 kernel]# make && make install  
  17. [root@rhel6 kernel]# modprobe mhvtl  
  18. [root@rhel6 kernel]# lsmod  |grep mhvtl   
  19. mhvtl                  26165  0   
  20.  
  21. [root@rhel6 kernel]# cd ..  
  22. [root@rhel6 mhvtl-0.18]# make && make install  
  23.  
  24. [root@rhel6 mhvtl-0.18]# /etc/init.d/mhvtl start  //啟動mhvtl程序  
  25. vtltape: version 0.18.10  
  26. vtltape: version 0.18.10  
  27. vtltape: version 0.18.10  
  28. vtltape: version 0.18.10  
  29. vtltape: version 0.18.10  
  30. vtltape: version 0.18.10  
  31. vtltape: version 0.18.10  
  32. vtltape: version 0.18.10  
  33. vtllibrary: version 0.18.10  
  34. vtllibrary process PID is 14448  
  35. vtllibrary: version 0.18.10  
  36. vtllibrary process PID is 14451  
  37.  
  38. [root@rhel6 mhvtl-0.18]# ls /etc/mhvtl/  
  39. device.conf  library_contents.10  library_contents.30  mhvtl.conf  
  40. [root@rhel6 mhvtl-0.18]# ls /opt/mhvtl/  
  41. CLN101L4  E01002L4  E01007L4  E01012L4  E01017L4  E03002L4  E03007L4  E03012L4  E03017L4  F01031L5  F01036L5  F03031L5  F03036L5  
  42. CLN102L5  E01003L4  E01008L4  E01013L4  E01018L4  E03003L4  E03008L4  E03013L4  E03018L4  F01032L5  F01037L5  F03032L5  F03037L5  
  43. CLN301L4  E01004L4  E01009L4  E01014L4  E01019L4  E03004L4  E03009L4  E03014L4  E03019L4  F01033L5  F01038L5  F03033L5  F03038L5  
  44. CLN302L5  E01005L4  E01010L4  E01015L4  E01020L4  E03005L4  E03010L4  E03015L4  E03020L4  F01034L5  F01039L5  F03034L5  F03039L5  
  45. E01001L4  E01006L4  E01011L4  E01016L4  E03001L4  E03006L4  E03011L4  E03016L4  F01030L5  F01035L5  F03030L5  F03035L5 

二:查看帶庫相關信息

  1. [root@rhel6 mhvtl-0.18]# lsscsi -g  
  2. [0:0:0:0]    disk    ATA      ST3160815AS      4.AA  /dev/sda   /dev/sg0  
  3. [8:0:0:0]    storage IET      Controller       0001  -         /dev/sg1  
  4. [8:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb   /dev/sg2  
  5. [9:0:0:0]    mediumx STK      L700             550V  /dev/sch0  /dev/sg11  //為帶庫機械手  
  6. [9:0:1:0]    tape    IBM      ULT3580-TD5      550V  /dev/st0   /dev/sg3  
  7. [9:0:2:0]    tape    IBM      ULT3580-TD5      550V  /dev/st1   /dev/sg4  
  8. [9:0:3:0]    tape    IBM      ULT3580-TD4      550V  /dev/st2   /dev/sg5  
  9. [9:0:4:0]    tape    IBM      ULT3580-TD4      550V  /dev/st3   /dev/sg6  
  10. [9:0:8:0]    mediumx SPECTRA  PYTHON           550V  /dev/sch1  /dev/sg12  //為帶庫機械手  
  11. [9:0:9:0]    tape    IBM      ULT3580-TD4      550V  /dev/st4   /dev/sg7  
  12. [9:0:10:0]   tape    IBM      ULT3580-TD4      550V  /dev/st5   /dev/sg8  
  13. [9:0:11:0]   tape    IBM      ULT3580-TD4      550V  /dev/st6   /dev/sg9  
  14. [9:0:12:0]   tape    IBM      ULT3580-TD4      550V  /dev/st7   /dev/sg10  
  15.  
  16.  
  17. [root@rhel6 mhvtl-0.18]# lsscsi -l  
  18. [0:0:0:0]    disk    ATA      ST3160815AS      4.AA  /dev/sda   
  19.   state=running queue_depth=31 scsi_level=6 type=0 device_blocked=0 timeout=30 
  20. [8:0:0:0]    storage IET      Controller       0001  -         
  21.   state=running queue_depth=32 scsi_level=6 type=12 device_blocked=0 timeout=0 
  22. [8:0:0:1]    disk    IET      VIRTUAL-DISK     0001  /dev/sdb   
  23.   state=running queue_depth=32 scsi_level=6 type=0 device_blocked=0 timeout=30 
  24. [9:0:0:0]    mediumx STK      L700             550V  /dev/sch0  
  25.   state=running queue_depth=32 scsi_level=6 type=8 device_blocked=0 timeout=0 
  26. [9:0:1:0]    tape    IBM      ULT3580-TD5      550V  /dev/st0   
  27.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  28. [9:0:2:0]    tape    IBM      ULT3580-TD5      550V  /dev/st1   
  29.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  30. [9:0:3:0]    tape    IBM      ULT3580-TD4      550V  /dev/st2   
  31.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  32. [9:0:4:0]    tape    IBM      ULT3580-TD4      550V  /dev/st3   
  33.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  34. [9:0:8:0]    mediumx SPECTRA  PYTHON           550V  /dev/sch1  
  35.   state=running queue_depth=32 scsi_level=6 type=8 device_blocked=0 timeout=0 
  36. [9:0:9:0]    tape    IBM      ULT3580-TD4      550V  /dev/st4   
  37.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  38. [9:0:10:0]   tape    IBM      ULT3580-TD4      550V  /dev/st5   
  39.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  40. [9:0:11:0]   tape    IBM      ULT3580-TD4      550V  /dev/st6   
  41.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  42. [9:0:12:0]   tape    IBM      ULT3580-TD4      550V  /dev/st7   
  43.   state=running queue_depth=32 scsi_level=6 type=1 device_blocked=0 timeout=900 
  44.     
  45. [root@rhel6 ~]# mtx -f /dev/sg11 status  
  46.   Storage Changer /dev/sg11:4 Drives, 43 Slots ( 4 Import/Export )  
  47. Data Transfer Element 0:Empty  
  48. Data Transfer Element 1:Empty  
  49. Data Transfer Element 2:Empty  
  50. Data Transfer Element 3:Empty  
  51. ————————輸出省略————————————  
  52.  
  53. [root@rhel6 ~]# mtx -f /dev/sg11 load 1 0  //將磁帶從1號槽位裝入driver 0
  54. Loading media from Storage Element 1 into drive 0...done  
  55.  
  56. [root@rhel6 ~]# mtx -f /dev/sg11 status  
  57.   Storage Changer /dev/sg11:4 Drives, 43 Slots ( 4 Import/Export )  
  58. Data Transfer Element 0:Full (Storage Element 1 Loaded):VolumeTag = E01001L4                              
  59. Data Transfer Element 1:Empty  
  60. Data Transfer Element 2:Empty  
  61. Data Transfer Element 3:Empty       
  62. ————————輸出省略———————————— 

三:使用磁帶機,nst0代表不回卷設備

  1. 1.將數據歸檔到模擬磁帶機  
  2. [root@rhel6 media]# mt -f /dev/nst0 tel  
  3. At block 0.  
  4. [root@rhel6 media]# tar -cvf /dev/nst0 張敬軒\ -\ 定局\ -\ 盛世仁傑主題曲.mp3   
  5. 張敬軒 - 定局 - 盛世仁傑主題曲.mp3  
  6. [root@rhel6 media]# mt -f /dev/nst0 tel  
  7. At block 350.  
  8.  
  9. 2.倒帶至磁帶頭並查看磁帶內容,查看完內容後,會把磁帶指針停止在內容位置後  
  10. [root@rhel6 media]# mt -f /dev/nst0 rewind  
  11. [root@rhel6 media]# mt -f /dev/nst0 tel  
  12. At block 0.  
  13. [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 tel  
  16. At block 349.  
  17.  
  18. 3.繼續添加文件至磁帶機  
  19. [root@rhel6 media]# tar -cvf /dev/nst0 /boot/vmlinuz-2.6.32-71.el6.x86_64   
  20. /boot/vmlinuz-2.6.32-71.el6.x86_64  
  21. [root@rhel6 media]# mt -f /dev/nst0 tel  
  22. At block 721.  
  23.  
  24. 4.從磁帶機中導出歸檔文件  
  25. [root@rhel6 media]# mt -f /dev/nst0 rewind       
  26. [root@rhel6 media]# tar -tvf /dev/nst0  
  27. -rw-r--r-- nobody/nobody 3569715 2010-07-26 04:54 張敬軒 - 定局 - 盛世仁傑主題曲.mp3  
  28.  
  29. [root@rhel6 media]# mt -f /dev/nst0 rewind  
  30. [root@rhel6 media]# rm -i 張敬軒\ -\ 定局\ -\ 盛世仁傑主題曲.mp3    //刪除本地文件  
  31. rm: remove regular file `張敬軒 - 定局 - 盛世仁傑主題曲.mp3'? y  
  32.  
  33. [[root@rhel6 media]# tar -xvf /dev/nst0          //導出第一個文件  
  34. 張敬軒 - 定局 - 盛世仁傑主題曲.mp3  
  35.  
  36. [root@rhel6 media]# tar -xvf /dev/nst0           //導出第二個文件  
  37. boot/vmlinuz-2.6.32-71.el6.x86_64  
  38.  
  39. 驗證:  
  40. [root@rhel6 media]# ls  
  41. boot  張敬軒 - 定局 - 盛世仁傑主題曲.mp3  
  42. [root@rhel6 media]# ls boot/  
  43. vmlinuz-2.6.32-71.el6.x86_64  
  44.  
  45.  
  46. 5.清除磁帶機中的數據並倒帶至磁帶頭  
  47. [root@rhel6 media]# mt -f /dev/nst0 erase  
  48. [root@rhel6 media]# mt -f /dev/nst0 tel  
  49. At block 0. 

四:卸載磁帶機

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

附上HP磁帶機的簡單使用說明,見 http://www.linuxidc.com/Linux/2011-12/49156p2.htm

Copyright © Linux教程網 All Rights Reserved