Oracle11新特性——備份恢復功能增強(四)

yangtingkun發表於2007-11-23

打算寫一系列的文章介紹11g的新特性和變化。

Oracle11g在備份和恢復方面新增了很多的功能,無論是效能、功能性、安全性和可操作性方面都有了不同程度的提高。

這一篇介紹RMAN對於UNDO表空間的最佳化。

Oracle11新特性——備份恢復功能增強(一):http://yangtingkun.itpub.net/post/468/412991

Oracle11新特性——備份恢復功能增強(二):http://yangtingkun.itpub.net/post/468/414647

Oracle11新特性——備份恢復功能增強(三):http://yangtingkun.itpub.net/post/468/414834


11g以前,Oracle並行備份的前提之一是存在多個需要備份的物件。也就是說對於一個大的表空間而言,即使分配了多個CHANNEL也無法並行備份。

11g改變了這種情況,Rman可以透過設定SECTION SIZE的方式來並行執行備份。

$ rman target /

Recovery Manager: Release 11.1.0.6.0 - Production on Fri Nov 23 16:13:41 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: TEST11G (DBID=790993044)

RMAN> run
2> {
3> allocate channel c1 device type disk format '/data/backup/%U';
4> allocate channel c2 device type disk format '/data/backup/%U';
5> allocate channel c3 device type disk format '/data/backup/%U';
6> backup tablespace system;
7> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=151 device type=DISK

allocated channel: c2
channel c2: SID=51 device type=DISK

allocated channel: c3
channel c3: SID=158 device type=DISK

Starting backup at 23-NOV-07
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
channel c1: starting piece 1 at 23-NOV-07
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c3: starting piece 1 at 23-NOV-07
channel c1: finished piece 1 at 23-NOV-07
piece handle=/data/backup/19j1pg3v_1_1 tag=TAG20071123T161454 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:55
including current control file in backup set
channel c2: starting piece 1 at 23-NOV-07
channel c2: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1aj1pg4h_1_1 tag=TAG20071123T161454 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:02
channel c3: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1bj1pg59_1_1 tag=TAG20071123T161454 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:02
Finished backup at 23-NOV-07
released channel: c1
released channel: c2
released channel: c3

RMAN> list backup of tablespace system;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
41 Full 737.63M DISK 00:01:05 23-NOV-07
BP Key: 41 Status: AVAILABLE Compressed: NO Tag: TAG20071123T161454
Piece Name: /data/backup/19j1pg3v_1_1
List of Datafiles in backup set 41
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1120295 23-NOV-07 /data/oracle/oradata/test11g/system01.dbf

RMAN> run
2> {
3> allocate channel c1 device type disk format '/data/backup/%U';
4> allocate channel c2 device type disk format '/data/backup/%U';
5> allocate channel c3 device type disk format '/data/backup/%U';
6> backup section size 300m tablespace system;
7> }

allocated channel: c1
channel c1: SID=151 device type=DISK

allocated channel: c2
channel c2: SID=51 device type=DISK

allocated channel: c3
channel c3: SID=158 device type=DISK

Starting backup at 23-NOV-07
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 1 through 9600
channel c1: starting piece 1 at 23-NOV-07
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c3: starting piece 1 at 23-NOV-07
channel c1: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1cj1pgjq_1_1 tag=TAG20071123T162321 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:39
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 9601 through 19200
channel c1: starting piece 2 at 23-NOV-07
including current control file in backup set
channel c2: starting piece 1 at 23-NOV-07
channel c3: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1ej1pgl1_1_1 tag=TAG20071123T162321 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:18
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 19201 through 28800
channel c3: starting piece 3 at 23-NOV-07
channel c1: finished piece 2 at 23-NOV-07
piece handle=/data/backup/1cj1pgjq_2_1 tag=TAG20071123T162321 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:25
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 28801 through 32768
channel c1: starting piece 4 at 23-NOV-07
channel c2: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1dj1pgkc_1_1 tag=TAG20071123T162321 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:46
channel c3: finished piece 3 at 23-NOV-07
piece handle=/data/backup/1cj1pgjq_3_1 tag=TAG20071123T162321 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:22
channel c1: finished piece 4 at 23-NOV-07
piece handle=/data/backup/1cj1pgjq_4_1 tag=TAG20071123T162321 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 23-NOV-07
released channel: c1
released channel: c2
released channel: c3

RMAN> list backup of tablespace system;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
41 Full 737.63M DISK 00:01:05 23-NOV-07
BP Key: 41 Status: AVAILABLE Compressed: NO Tag: TAG20071123T161454
Piece Name: /data/backup/19j1pg3v_1_1
List of Datafiles in backup set 41
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1120295 23-NOV-07 /data/oracle/oradata/test11g/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
44 Full 738.09M DISK 00:02:01 23-NOV-07
List of Datafiles in backup set 44
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1120885 23-NOV-07 /data/oracle/oradata/test11g/system01.dbf

Backup Set Copy #1 of backup set 44
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:02:01 23-NOV-07 NO TAG20071123T162321

List of Backup Pieces for backup set 44 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
44 1 AVAILABLE /data/backup/1cj1pgjq_1_1
47 2 AVAILABLE /data/backup/1cj1pgjq_2_1
48 3 AVAILABLE /data/backup/1cj1pgjq_3_1
49 4 AVAILABLE /data/backup/1cj1pgjq_4_1

RMAN> run
2> {
3> allocate channel c1 device type disk format '/data/backup/%U';
4> allocate channel c2 device type disk format '/data/backup/%U';
5> allocate channel c3 device type disk format '/data/backup/%U';
6> backup section size 400m tablespace system;
7> }

allocated channel: c1
channel c1: SID=151 device type=DISK

allocated channel: c2
channel c2: SID=51 device type=DISK

allocated channel: c3
channel c3: SID=158 device type=DISK

Starting backup at 23-NOV-07
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 1 through 12800
channel c1: starting piece 1 at 23-NOV-07
channel c2: starting full datafile backup set
channel c2: specifying datafile(s) in backup set
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c3: starting piece 1 at 23-NOV-07
channel c1: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1ij1ph60_1_1 tag=TAG20071123T163303 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:39
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 12801 through 25600
channel c1: starting piece 2 at 23-NOV-07
including current control file in backup set
channel c2: starting piece 1 at 23-NOV-07
channel c3: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1kj1ph78_1_1 tag=TAG20071123T163303 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:19
channel c3: starting full datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/test11g/system01.dbf
backing up blocks 25601 through 32768
channel c3: starting piece 3 at 23-NOV-07
channel c1: finished piece 2 at 23-NOV-07
piece handle=/data/backup/1ij1ph60_2_1 tag=TAG20071123T163303 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:29
channel c2: finished piece 1 at 23-NOV-07
piece handle=/data/backup/1jj1ph6i_1_1 tag=TAG20071123T163303 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:29
channel c3: finished piece 3 at 23-NOV-07
piece handle=/data/backup/1ij1ph60_3_1 tag=TAG20071123T163303 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:03
Finished backup at 23-NOV-07
released channel: c1
released channel: c2
released channel: c3

RMAN> list backup of tablespace system;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
41 Full 737.63M DISK 00:01:05 23-NOV-07
BP Key: 41 Status: AVAILABLE Compressed: NO Tag: TAG20071123T161454
Piece Name: /data/backup/19j1pg3v_1_1
List of Datafiles in backup set 41
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1120295 23-NOV-07 /data/oracle/oradata/test11g/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
44 Full 738.09M DISK 00:02:01 23-NOV-07
List of Datafiles in backup set 44
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1120885 23-NOV-07 /data/oracle/oradata/test11g/system01.dbf

Backup Set Copy #1 of backup set 44
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:02:01 23-NOV-07 NO TAG20071123T162321

List of Backup Pieces for backup set 44 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
44 1 AVAILABLE /data/backup/1cj1pgjq_1_1
47 2 AVAILABLE /data/backup/1cj1pgjq_2_1
48 3 AVAILABLE /data/backup/1cj1pgjq_3_1
49 4 AVAILABLE /data/backup/1cj1pgjq_4_1

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
47 Full 737.88M DISK 00:01:47 23-NOV-07
List of Datafiles in backup set 47
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1121581 23-NOV-07 /data/oracle/oradata/test11g/system01.dbf

Backup Set Copy #1 of backup set 47
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:01:47 23-NOV-07 NO TAG20071123T163303

List of Backup Pieces for backup set 47 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
50 1 AVAILABLE /data/backup/1ij1ph60_1_1
53 2 AVAILABLE /data/backup/1ij1ph60_2_1
54 3 AVAILABLE /data/backup/1ij1ph60_3_1

預設情況單個檔案是無法並行備份的,11g以前的資料庫都是這種情況。在11g中可以指定SECTION SIZE來實現單個資料檔案的並行備份。

但是值得注意的是,如果SECTION SIZE設定的不合適,SECTION數量比CHANNEL的數量大很多,並行備份帶來的負荷會造成效能的下降。如上面例子中第二次備份的情況。

另外,並行備份不一定可以提高備份的效能,上面的三個例子中,直接備份的速度反而最快。這是由於三個CHANNEL備份到相同的磁碟上,會導致IO競爭,而且並行備份本身也會帶來一定的開銷,這個從最終備份集的大小就可以看出來。如果可以將CHANNEL的目的地分散到不同磁碟,或者不同的CHANNEL使用帶庫不同的備份驅動器,那麼並行備份就有可能帶來一定的效能提升。之所以說有可能是因為,並行備份的速度和資料檔案中資料的分佈也是有關係的。而且以兩個CHANNEL並行備份為例,由於第二個CHANNEL首先要定位開始位置,這個就需要消耗一定的時間,因此將SECTION大小設定大於資料檔案的一半可以減少備份所需的時間。希望並行備份體現效能優勢的另外一個條件就是資料檔案足夠大,使得並行備份的開銷可以忽略掉。

如果備份採用並行備份,那麼恢復會自動並行完成。VALIDATE命令也是可以透過同樣的方法實現並行。

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

相關文章