加快RMAN增量備份的速度(block change tracking特性)

perfychi發表於2012-08-31

9i的增量備份,要掃描所有使用過的塊,應該沒啥辦法吧,10g有了新特性block change tracking就好點

這不能說是10g新特性,只是10g對增備的完善,10g的增備是實際意義上的增備,速度提升明顯。不像9i如果是oltp系統增備時間往往會比全備長,10g對於增備推出了BLOCK change tracking 日誌,其實就是在日誌裡維護了一個全庫塊的點陣圖。點陣圖操作快,而且不大。就是最繁忙的庫,相對大的庫,這個BLOCK change tracking 日誌也很難到10m,所以說10g的增備相當值得應用!在資料量超過2t以後,效果更好!

引用自:http://www.itpub.net/thread-395435-1-1.html

在10g之前的版本,使用rman做增量備份,rman在做1級備份的時候怎麼來確定0級備份之後都有哪些資料塊做了修改呢?看下面一段
Each data block in a datafile contains a system change number (SCN), which is the
SCN at which the most recent change was made to the block. During an incremental
backup,
RMAN reads the SCN of each data block in the input file and compares it to
the checkpoint SCN of the parent incremental backup. If the SCN in the input data
block is greater than or equal to the checkpoint SCN of the parent, then RMAN copies
the block.
也就是說在做level 1級備份的時候,需要掃描所有的資料塊並且用塊中記錄修改的SCN跟level 0備份時的SCN做比較,來確定什麼是需要備份的。
所以掃描整個資料檔案是不可避免的 !(這是10g以前的版本)

Block change tracking是
Oracle
10g的一個新特性,Block change tracking程式記錄自從上一次備份以來資料塊的變化,並把這些資訊記錄在跟蹤檔案中。RMAN使用這個檔案判斷增量備份中需要備份的變更資料。這極大的促進了備份效能,RMAN可以不再掃描整個檔案以查詢變更資料。
RMAN's change tracking feature for incremental backups improves incremental
backup performance by recording changed blocks in each datafile in a change tracking
file.
If change tracking is enabled, RMAN uses the change tracking file to identify
changed blocks for incremental backup, thus avoiding the need to scan every block in
the datafile.
估計又是使用的點陣圖!沒找到依據呢,看書不太仔細。

讓我們來對它們的速度做一下測試,
不使用block change tracking,看看備份需要的時間

 

首先關閉block change tracking
> select status , filename, bytes from v$block_change_tracking;

STATUS     FILENAME                                      BYTES
---------- ---------------------------------------- ----------
DISABLED

然後讓我們來做個0級增量備份,和一個1級備份,注意它們使用的時間

RMAN> backup incremental level 0 format '/u01/level0_%U.bak' database;

Starting backup at 30-AUG-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=136 devtype=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA1/ch/datafile/system.268.792554517
input datafile fno=00003 name=+DATA1/ch/datafile/sysaux.267.792554563
input datafile fno=00005 name=+DATA1/ch/datafile/example.266.792554587
input datafile fno=00004 name=+DATA1/ch/datafile/users.265.792554603
input datafile fno=00002 name=+DATA1/ch/datafile/undotbs1.264.792554609
input datafile fno=00008 name=+DATA2/ch/datafile/test2.256.792657081
input datafile fno=00009 name=+DATA3/ch/datafile/test4.256.792658607
input datafile fno=00006 name=+DATA1/ch/datafile/test01.dbf
input datafile fno=00007 name=+DATA1/ch/datafile/test02.dbf
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level0_0jnjv5d8_1_1.bak tag=TAG20120830T172352 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level0_0knjv5eb_1_1.bak tag=TAG20120830T172352 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-AUG-12

RMAN> backup incremental level 1 format '/u01/level1_%U.bak' database;

Starting backup at 30-AUG-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA1/ch/datafile/system.268.792554517
input datafile fno=00003 name=+DATA1/ch/datafile/sysaux.267.792554563
input datafile fno=00005 name=+DATA1/ch/datafile/example.266.792554587
input datafile fno=00004 name=+DATA1/ch/datafile/users.265.792554603
input datafile fno=00002 name=+DATA1/ch/datafile/undotbs1.264.792554609
input datafile fno=00008 name=+DATA2/ch/datafile/test2.256.792657081
input datafile fno=00009 name=+DATA3/ch/datafile/test4.256.792658607
input datafile fno=00006 name=+DATA1/ch/datafile/test01.dbf
input datafile fno=00007 name=+DATA1/ch/datafile/test02.dbf
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level1_0lnjv5go_1_1.bak tag=TAG20120830T172544 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level1_0mnjv5i5_1_1.bak tag=TAG20120830T172544 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-AUG-12

level 0備份後其實我根本就沒有對資料庫做什麼更改,level 1備份居然也使用了45秒(大部分時間是耗費在掃描變化上了)

然後讓我們把block change tracking啟用後測試一下level 1需要的時間

> alter database enable block change tracking using file '/u01/BLOCK_CHANGE_TRACE.LOG';

Database altered.

> select status , filename, bytes from v$block_change_tracking;

STATUS     FILENAME                                                                      BYTES
---------- ----------------------------------------                                          ----------
ENABLED    /u01/BLOCK_CHANGE_TRACE.LOG                     11599872

block change tracing啟用後對應作業系統上的ora_ctwr_程式:

[oracle@yitai ~]$ ps -ef | grep -i ctwr
oracle    7292     1  2 17:31 ?        00:00:00 ora_ctwr_CH
oracle    7294  7260  0 17:31 pts/7    00:00:00 grep -i ctwr


 

先刪除原來的備份
RMAN> delete backupset ;(刪除當前為止所有的備份集

RMAN> backup incremental level 0 format '/u01/level0_%U.bak' database;

Starting backup at 30-AUG-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA1/ch/datafile/system.268.792554517
input datafile fno=00003 name=+DATA1/ch/datafile/sysaux.267.792554563
input datafile fno=00005 name=+DATA1/ch/datafile/example.266.792554587
input datafile fno=00004 name=+DATA1/ch/datafile/users.265.792554603
input datafile fno=00002 name=+DATA1/ch/datafile/undotbs1.264.792554609
input datafile fno=00008 name=+DATA2/ch/datafile/test2.256.792657081
input datafile fno=00009 name=+DATA3/ch/datafile/test4.256.792658607
input datafile fno=00006 name=+DATA1/ch/datafile/test01.dbf
input datafile fno=00007 name=+DATA1/ch/datafile/test02.dbf
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level0_0nnjv5vn_1_1.bak tag=TAG20120830T173343 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level0_0onjv61o_1_1.bak tag=TAG20120830T173343 comment=NONE
channel ORA_DISK_1: backup set complete,
elapsed time: 00:00:03
Finished backup at 30-AUG-12

 

RMAN> backup incremental level 1 format '/u01/level1_%U.bak' database;

Starting backup at 30-AUG-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA1/ch/datafile/system.268.792554517
input datafile fno=00003 name=+DATA1/ch/datafile/sysaux.267.792554563
input datafile fno=00005 name=+DATA1/ch/datafile/example.266.792554587
input datafile fno=00004 name=+DATA1/ch/datafile/users.265.792554603
input datafile fno=00002 name=+DATA1/ch/datafile/undotbs1.264.792554609
input datafile fno=00008 name=+DATA2/ch/datafile/test2.256.792657081
input datafile fno=00009 name=+DATA3/ch/datafile/test4.256.792658607
input datafile fno=00006 name=+DATA1/ch/datafile/test01.dbf
input datafile fno=00007 name=+DATA1/ch/datafile/test02.dbf
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level1_0pnjv628_1_1.bak tag=TAG20120830T173503 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-AUG-12
channel ORA_DISK_1: finished piece 1 at 30-AUG-12
piece handle=/u01/level1_0qnjv629_1_1.bak tag=TAG20120830T173503 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-AUG-12

顯然level 1備份用了1秒就完成了,比起沒有啟用block change tracking快了幾十倍


 

 

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

相關文章