[20221028]rman使用tape與增量備份測試2.txt

lfree發表於2022-11-02

[20221028]rman使用tape與增量備份測試2.txt

--//參考連結:2017/201702/[20170208]rman tape.txt 2017/201702/[20170213]rman tape測試.txt
--//生產系統採用虛擬磁帶庫的備份方式,我以前發現不支援壓縮.參考連線http://blog.itpub.net/267265/viewspace-2645144/
--//最近遇到增量不能使用BLOCK CHANGE TRACKING檔案的情況,最後發現對方備份指令碼執行
alter database disable block change tracking;
--//導致的情況.奇葩的運維人員....無語啊.
--//前幾天測試使用的資料檔案沒有資料寫入,換成資料檔案1測試看看,當時的測試有點亂.

1.環境:
SCOTT@book> @ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--//先做一些清理工作.
ALTER DATABASE disable BLOCK CHANGE TRACKING;
--//RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' clear;
--//RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
--//並且刪除以前測試做的全部備份集.

$ cat ckfile.txt
SELECT file#
    , incremental_level
    , completion_time
    , datafile_blocks
    , blocks_read
    , blocks_read/datafile_blocks* 100 AS PCT_READ_FOR_BACKUP
    , blocks
  FROM v$backup_datafile
 WHERE  file# in (&&1) order by 3;

2.建立測試環境:
--//測試前清理全部備份檔案集略.
--//在rman下執行,模擬tape方式:
RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS  'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/backup)';

using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS  'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/backup)';
new RMAN configuration parameters are successfully stored

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT_TAPE;
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored

3.測試1:
--//採用模擬tape方式,沒有開啟BLOCK CHANGE TRACKING:
RMAN> backup incremental level=0 datafile 1 ;

Starting backup at 2022-10-28 09:04:00
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=53 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
channel ORA_SBT_TAPE_1: starting incremental level 0 datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2022-10-28 09:04:00
channel ORA_SBT_TAPE_1: finished piece 1 at 2022-10-28 09:04:03
piece handle=gs1bd1k0_1_1 tag=TAG20221028T090400 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:03
Finished backup at 2022-10-28 09:04:03

Starting Control File and SPFILE Autobackup at 2022-10-28 09:04:03
piece handle=c-1337401710-20221028-00 comment=API Version 2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 2022-10-28 09:04:10

--//繼續測試,採用模擬tape方式,開啟BLOCK CHANGE TRACKING:
SYS@book> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING using file '/u01/app/oracle/fast_recovery_area/block_change_tracking.f' ;
Database altered.

SYS@book> SELECT * FROM V$BLOCK_CHANGE_TRACKING
  2  @ pr
==============================
STATUS                        : ENABLED
FILENAME                      : /u01/app/oracle/fast_recovery_area/block_change_tracking.f
BYTES                         : 11599872
PL/SQL procedure successfully completed.
--//已經開啟塊跟蹤特性.

RMAN> backup incremental level=1 datafile 1 ;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting backup at 2022-10-28 09:05:06
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting incremental level 1 datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2022-10-28 09:05:06
channel ORA_SBT_TAPE_1: finished piece 1 at 2022-10-28 09:05:07
piece handle=gu1bd1m2_1_1 tag=TAG20221028T090506 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-10-28 09:05:07

Starting Control File and SPFILE Autobackup at 2022-10-28 09:05:07
piece handle=c-1337401710-20221028-01 comment=API Version 2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 2022-10-28 09:05:08

SYS@book> @ ckfile.txt 1
     FILE# INCREMENTAL_LEVEL COMPLETION_TIME     DATAFILE_BLOCKS BLOCKS_READ PCT_READ_FOR_BACKUP     BLOCKS
---------- ----------------- ------------------- --------------- ----------- ------------------- ----------
         1                 0 2022-10-28 09:04:02           99840       99840                 100      83579
         1                 1 2022-10-28 09:05:07           99840       99840                 100          5
--//BLOCKS_READ並沒有減少,因為BLOCK CHANGE TRACKING後才可是記錄塊scn的變化.而level=0備份在啟用之前.

$ ll /u01/backup/[g]*
-rw-r--r-- 1 oracle oinstall 687865872 2022-10-28 09:04:02 /u01/backup/gs1bd1k0_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:05:07 /u01/backup/gu1bd1m2_1_1
--//僅僅備份變化的部分,備份檔案減少了

RMAN> backup incremental level=1 datafile 1 ;
Starting backup at 2022-10-28 09:06:26
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting incremental level 1 datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2022-10-28 09:06:26
channel ORA_SBT_TAPE_1: finished piece 1 at 2022-10-28 09:06:27
piece handle=h01bd1oi_1_1 tag=TAG20221028T090626 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-10-28 09:06:27

Starting Control File and SPFILE Autobackup at 2022-10-28 09:06:27
piece handle=c-1337401710-20221028-02 comment=API Version 2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 2022-10-28 09:06:28

SYS@book> @ ckfile.txt 1
     FILE# INCREMENTAL_LEVEL COMPLETION_TIME     DATAFILE_BLOCKS BLOCKS_READ PCT_READ_FOR_BACKUP     BLOCKS
---------- ----------------- ------------------- --------------- ----------- ------------------- ----------
         1                 0 2022-10-28 09:04:02           99840       99840                 100      83579
         1                 1 2022-10-28 09:05:07           99840       99840                 100          5
         1                 1 2022-10-28 09:06:26           99840           1          .001001603          1
--//可以使用這時塊跟蹤檔案.BLOCKS_READ=1.因為這次增量備份之前做了一次增量在啟動塊跟蹤特性之前(有點繞口).

$ ll /u01/backup/[gh]*
-rw-r--r-- 1 oracle oinstall 687865872 2022-10-28 09:04:02 /u01/backup/gs1bd1k0_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:05:07 /u01/backup/gu1bd1m2_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:06:26 /u01/backup/h01bd1oi_1_1

--//如果使用累積增量,可能不行,可以如下驗證:
RMAN> backup incremental level 1 cumulative datafile 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting backup at 2022-10-28 09:08:53
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting incremental level 1 datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2022-10-28 09:08:53
channel ORA_SBT_TAPE_1: finished piece 1 at 2022-10-28 09:08:54
piece handle=h21bd1t5_1_1 tag=TAG20221028T090853 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-10-28 09:08:54

Starting Control File and SPFILE Autobackup at 2022-10-28 09:08:54
piece handle=c-1337401710-20221028-03 comment=API Version 2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 2022-10-28 09:08:55

SYS@book> @ ckfile.txt 1
     FILE# INCREMENTAL_LEVEL COMPLETION_TIME     DATAFILE_BLOCKS BLOCKS_READ PCT_READ_FOR_BACKUP     BLOCKS
---------- ----------------- ------------------- --------------- ----------- ------------------- ----------
         1                 0 2022-10-28 09:04:02           99840       99840                 100      83579
         1                 1 2022-10-28 09:05:07           99840       99840                 100          5
         1                 1 2022-10-28 09:06:26           99840           1          .001001603          1
         1                 1 2022-10-28 09:08:54           99840       99840                 100          7
--//可以發現累積cumulative模式無法使用,當前這樣的情況下.

--//再次執行累積備份也是一樣的情況.
RMAN> backup incremental level 1 cumulative datafile 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting backup at 2022-10-28 09:10:15
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting incremental level 1 datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2022-10-28 09:10:16
channel ORA_SBT_TAPE_1: finished piece 1 at 2022-10-28 09:10:17
piece handle=h41bd1vo_1_1 tag=TAG20221028T091015 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2022-10-28 09:10:17

Starting Control File and SPFILE Autobackup at 2022-10-28 09:10:17
piece handle=c-1337401710-20221028-04 comment=API Version 2.0,MMS Version 8.1.3.0
Finished Control File and SPFILE Autobackup at 2022-10-28 09:10:18

SYS@book> @ ckfile.txt 1
     FILE# INCREMENTAL_LEVEL COMPLETION_TIME     DATAFILE_BLOCKS BLOCKS_READ PCT_READ_FOR_BACKUP     BLOCKS
---------- ----------------- ------------------- --------------- ----------- ------------------- ----------
         1                 0 2022-10-28 09:04:02           99840       99840                 100      83579
         1                 1 2022-10-28 09:05:07           99840       99840                 100          5
         1                 1 2022-10-28 09:06:26           99840           1          .001001603          1
         1                 1 2022-10-28 09:08:54           99840       99840                 100          7
         1                 1 2022-10-28 09:10:16           99840       99840                 100          7

$ ll /u01/backup/[gh]*
-rw-r--r-- 1 oracle oinstall 687865872 2022-10-28 09:04:02 /u01/backup/gs1bd1k0_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:05:07 /u01/backup/gu1bd1m2_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:06:26 /u01/backup/h01bd1oi_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:08:54 /u01/backup/h21bd1t5_1_1
-rw-r--r-- 1 oracle oinstall   4194320 2022-10-28 09:10:16 /u01/backup/h41bd1vo_1_1

4.收尾還原:
RMAN> delete backupset completed after 'sysdate -1';
RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' clear;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
RMAN> CONFIGURE DEVICE TYPE 'SBT_TAPE' clear;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2921600/,如需轉載,請註明出處,否則將追究法律責任。

相關文章