Oracle11g 新特性:優化Rman備份UNDO表空間

Oracle11gR1的新特性,Rman備份UNDO表空間時排除已經提交的會話對應的數據,提高了Rman備份的效率。

官方文檔:http://docs.oracle.com/cd/B28359_01/server.111/b28279/chapter1.htm#AREANO02323

我們知道,UNDO表空間主要用於存儲前鏡像數據,這些數據在回滾以及恢復過程中可能被用到。但是一個生產數據庫的UNDO表空間可能會變得非常巨大,而備份完整的UNDO數據文件在恢復時一般可能用到的比例很小。

測試一下:

--數據庫版本
sys@ORCL>select * from v$version;

BANNER
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE	11.2.0.4.0	Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
--創建環境
zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>insert into t1 select * from dba_segments;

5887 rows created.

zx@ORCL>commit;

Commit complete.

zx@ORCL>delete from t1;

288463 rows deleted.

zx@ORCL>select status,sum(bytes)/1024/1024 from dba_undo_extents group by status;

STATUS			    SUM(BYTES)/1024/1024
--------------------------- --------------------
UNEXPIRED				   9.125
EXPIRED 				   .4375
ACTIVE					  89.125

zx@ORCL>commit;

Commit complete.

--兩次備份undo表空間文件
RMAN> backup datafile 5;

Starting backup at 2016-12-22 13:09:27
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u02/app/oracle/oradata/orcl/undotbs2_01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-12-22 13:09:27
channel ORA_DISK_1: finished piece 1 at 2016-12-22 13:09:28
piece handle=/u02/app/oracle/product/11.2.4/db1/dbs/3aro4007_1_1 tag=TAG20161222T130927 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-22 13:09:28

Starting Control File and SPFILE Autobackup at 2016-12-22 13:09:28
piece handle=/u02/app/oracle/product/11.2.4/db1/dbs/c-1444351641-20161222-0f comment=NONE
Finished Control File and SPFILE Autobackup at 2016-12-22 13:09:31
--查看備份後的文件大小
RMAN> list backup of datafile 5;


List of Backup Sets
===================
--第一次備份文件大小99.27M
BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
87      Full    99.27M     DISK        00:00:03     2016-12-22 12:11:54
        BP Key: 87   Status: AVAILABLE  Compressed: NO  Tag: TAG20161222T121151
        Piece Name: /u02/app/oracle/product/11.2.4/db1/dbs/36ro3sk7_1_1
  List of Datafiles in backup set 87
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  5       Full 9042031    2016-12-22 12:11:51 /u02/app/oracle/oradata/orcl/undotbs2_01.dbf
--第二次備份文件大小2.16M
BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
89      Full    2.16M      DISK        00:00:01     2016-12-22 12:34:42
        BP Key: 89   Status: AVAILABLE  Compressed: NO  Tag: TAG20161222T123441
        Piece Name: /u02/app/oracle/product/11.2.4/db1/dbs/38ro3tv1_1_1
  List of Datafiles in backup set 89
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  5       Full 9042576    2016-12-22 12:34:41 /u02/app/oracle/oradata/orcl/undotbs2_01.dbf
--查看操作系統文件大小
[oracle@rhel6 release]$ ls -lh /u02/app/oracle/product/11.2.4/db1/dbs/36ro3sk7_1_1
-rw-r----- 1 oracle oinstall 100M Dec 22 12:11 /u02/app/oracle/product/11.2.4/db1/dbs/36ro3sk7_1_1
[oracle@rhel6 release]$ ls -lh /u02/app/oracle/product/11.2.4/db1/dbs/38ro3tv1_1_1
-rw-r----- 1 oracle oinstall 2.2M Dec 22 12:34 /u02/app/oracle/product/11.2.4/db1/dbs/38ro3tv1_1_1

這個新特性也有一些限制

- Compatible parameter must be set to 11.0 or higher 
- Backup must use a disk or OSB channel
- For 'backup copy of <object>' or 'backup datafilecopy' the database must be open for undo optimization to be used. 
- Not active for LEVEL 1 incremental backups, only for LEVEL 0 and FULL backups

MOS文檔:RMAN 11G : RMAN UNDO backup optimization (文檔 ID 406468.1)

A Complete Understanding of RMAN Compression (文檔 ID 563427.1)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章