在中,大型系統應用中,使用磁帶備份是很常見的,也是很關鍵的動作。現將本人日常會用到的命令簡單記錄一下,作個總結吧,加深印象。
下面命令在aix環境下,ibm 磁帶機上已作過驗證,其他環境和磁帶機,除一些ibm專有命令外,其它幾乎一樣。如引用,最好親自動手驗證一下。
磁帶機簡單介紹
磁帶機設備名在unix/linux環境下,一般是/dev/rmtx,系統還為每個磁帶驅動器設備生成7個子設備:
/dev/rmtx.N N=A+B+C
A = 密度 B = 訪問時保持原位 C = 讀寫完倒帶
4 = 低密度 2 = 是 1 = 否
0 = 高密度 0 = 否 0 = 是
磁帶機基本操作
tctl command
rewind --磁帶倒帶
eg: #tctl -f /dev/rmt0 rewind
fsf --跳過磁帶上的文件
eg: #tctl -f /dev/rmt0.1 fsf 3
offline --彈出磁帶
eg: #tctl -f /dev/rmt0 offline
rewoffl --倒帶並彈出磁帶
eg: #tctl -f /dev/rmt0 rewoffl
mt command
主要參數和作用與上tctl命令一樣.
磁帶機基本備份操作
tar command
#tar -cvf /dev/rmt0.3 /home
--生成一個 tar 備份到磁帶設備/dev/rmt0,後面.3的意思是訪問磁帶時保持原位,且讀寫完后不到倒帶.
#tar -xvf /dev/rmt0 /home/team01/mydir
--從/dev/rmt0磁帶設備裏,提取出/home/team01/mydir的tar複件。
#tar -tvf /dev/rmt0
--列出磁帶設備裏tar複件的?容。
-c 創建一個tar備份
-x 從tar備份裏提取文件
-t 查看tar備份文件裏的?容
-v 顯示backup and restore時的文件
-f 標識文件或tar複件所在設備名稱。
pax command
#pax -wvf /dev/rmt0 /home(pax -x pax -wvf /dev/rmt0 /home)
--在指定的歸檔格式下,寫文件到磁帶設備/dev/rmt0裏。
#pax -rvf /dev/rmt0 /home
--在磁帶設備/dev/rmt0裏,提取/home目錄?容到當前目錄。
#pax -rw olddir newdir
-複製舊目錄到新目錄。
-w 在指定歸檔格式下,寫文件到標準輸出。
-x 指定歸檔格式。
-r 從備份或歸檔文件裏提取出文件。
-v 顯示backup and restore時的文件。
其它常用參數:
-a 寫文件時,追加在已有歸檔文件後面。不過要保證格式相同,負責立即退出。
-k 防止pax命令覆蓋已存在的文件。
-u 忽略比它遲的已存在文件。
tcopy comman
#tcopy /dev/rmt0 /dev/rmt1
--將磁帶設備/dev/rmt0裏文件cp到磁帶設備/dev/rmt1裏。
#tcopy /dev/rmt0
--讀磁帶設備/dev/rmt0信息,如文件大小,數量等。一般等待60s,還沒有結果出來,可ctrl + c取消。
tapeutil command (AIX 專有命令)
#tapeutil
--直接打上訴命令,會出現tape控制的字符接口,有很強大磁帶和介質控制功能。
#tapeutil -f /dev/rmt0 rewind
--倒帶。
#tapeutil -f /dev/rmt0 erase
--擦除磁帶?容。
以上注意事項:
1,注意7個字設備的使用方法。
2,注意一般備份到磁帶時,沒有特殊指定都會覆蓋原磁帶?容。
3,注意磁帶大小,塊大小。
在AIX中如何改变LTO设备的参数
如果在AIX中需要改变默认的参数如压缩、块大小、缓冲区等,可以使用
smit工具。
具体的方法如下:
1)确定AIX中要修改的设备
# lsdev -Cc tape
smc0 Available 14-08-00-6,0 IBM 3583 Library Medium Changer
rmt0 Available 14-08-00-0,0 IBM 3580 Ultrium Tape Drive
rmt1 Available 14-08-00-1,0 IBM 3580 Ultrium Tape Drive
rmt2 Available 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
smc1 Available 30-68-01 IBM 3584 Library Medium Changer (FCP)
rmt3 Available 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
smc2 Available 30-68-01 IBM 3584 Library Medium Changer (FCP)
rmt4 Available 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
smc3 Available 30-68-01 IBM 3584 Library Medium Changer (FCP)
通过上面的信息我们可以知道系统连接了两个磁带库:
a)用SCSI连接的3583,smc0带两个驱动器rmt0,rmt1。
smc0 Available 14-08-00-6,0 IBM 3583 Library Medium Changer
rmt0 Available 14-08-00-0,0 IBM 3580 Ultrium Tape Drive
rmt1 Available 14-08-00-1,0 IBM 3580 Ultrium Tape Drive
b)用光纤连接的3584,三个驱动器各自的control path都被使能。
rmt2 Available 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
smc1 Available 30-68-01 IBM 3584 Library Medium Changer (FCP)
rmt3 Available 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
smc2 Available 30-68-01 IBM 3584 Library Medium Changer (FCP)
rmt4 Available 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
smc3 Available 30-68-01 IBM 3584 Library Medium Changer (FCP)
1.1)假设我们要修改SCSI连接的3583上的SCSI ID=2的驱动器的参数:
通过分析我们可以确定rmt1的SCSI ID是1,正是我们要修改的对象。
1.2)假设我们要修改光纤连接的3584上的驱动器的参数:
我们还要通过三个驱动器的WWN来区分他们。首先驱动器的WWN可以
通过驱动器上面的标签得到,然后你可以使用lsattr命令得到WWN和
设备名的对应关系:
#lsattr -El rmt2
block_size 0 Block Size (0=Variable Length) True
compress yes Use Hardware Compression on Tape True
autoload no Use Autoloading Feature at End-of-Tape True
logging no Activate volume information logging True
max_log_size 500 Maximum size of log file (in # of entries) True
space_mode SCSI Backward Space/Forward Space Record Mode True
rew_immediate no Use Immediate Bit in Rewind Commands True
trailer_labels no Trailer Label Processing True
retain_reserve no Retain Reservation False
devtype ULT3580- Device Type False
scsi_id 0x213ca SCSI Target ID True
lun_id 0x0 Logical Unit Number True
location Location True
ww_name 0x5005076300410803 World Wide Name False
new_name New Logical Name True
1.3)如果驱动器上没有WWN标签,或复杂的SAN环境,或使用FC-SCSI-GATAWAY
的情况我们可以通过SAN交换机来确定,限于篇幅这里不做介绍。
2)参数:
3.1)显示现有参数的命令:
# lscfg -vl rmt1
DEVICE LOCATION DESCRIPTION
rmt7 30-68-01 IBM 3580 Ultrium Tape Drive (FCP)
Manufacturer................IBM
Machine Type and Model......ULT3580-TD1
Serial Number...............6811288675
Device Specific.(FW)........25D4
#lsattr -El rmt2
block_size 0 Block Size (0=Variable Length) True
compress yes Use Hardware Compression on Tape True
autoload no Use Autoloading Feature at End-of-Tape True
logging no Activate volume information logging True
max_log_size 500 Maximum size of log file (in # of entries) True
space_mode SCSI Backward Space/Forward Space Record Mode True
rew_immediate no Use Immediate Bit in Rewind Commands True
trailer_labels no Trailer Label Processing True
retain_reserve no Retain Reservation False
devtype ULT3580- Device Type False
scsi_id 0x213ca SCSI Target ID True
lun_id 0x0 Logical Unit Number True
location Location True
ww_name 0x5005076300410803 World Wide Name False
new_name New Logical Name True
3.2)设置参数的方法:
我们可以使用SMIT工具修改某一个指定的LTO设备。
具体方法是:
3.2.1)#SMITTY
3.2.2)选择菜单Devices -> Tape Drive -> Change/Show
Characteristics of a Tape Drive.
3.2.3)选择我们指定的设备
3.2.4)修改参数:
Change / Show Characteristics of a Tape Drive
Type or select values in entry fields.
Press Enter AFTER making all desired changes.
[Entry Fields]
Tape Drive rmt0
Tape Drive type 3580
Tape Drive interface scsi
Description IBM 3580 Ultrium Tape
Status Available
Location 14-08-00-0,0
Parent adapter scsi1
Connection address 0,0
Block Size (0=Variable Length) [0]
Use Hardware Compression on Tape yes
Activate volume information logging no
Maximum size of log file (in # of entries) [500]
Backward Space/Forward Space Record Mode SCSI
Use Immediate Bit in Rewind Commands no
Trailer Label Processing no
比如我们可以修改不使用硬件压缩
Use Hardware Compression on Tape no
这种修改是永久生效的。
必須符合下列條件:
1、檔案系統必須支援『Large File Enabled』。
(Large File Enabled Journaled File System)
(或是Enhanced Journaled File System:JFS2)
2、使用者的系統資源權限:『fsize = -1』
(/etc/security/limits)
二、『tar』指令並不支援超過8GB的檔案備份。
可使用:dd、cpio、backup…………
缺點一次只能備份一個目錄。
三、超過8GB的檔案可以用PAX指令
使用『pax』備份超過8GB的檔案:
pax –wvf /dev/rmtx –x pax /PATH1 /PATH2
使用『pax』檢視備份內容:
pax –vf /dev/rmtx –x pax
使用『pax』還原檔案:
pax –rvf /dev/rmtx –x pax (PATH_file_name)
[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8119050/viewspace-1006220/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/8119050/viewspace-1006220/