Oracle11gR1的新特性,Rman备份UNDO表空间时排除已经提交的会话对应的数据,提高了Rman备份的效率。

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

我们知道,UNDO表空间主要用于存储前镜像数据,这些数据在回滚以及恢复过程中可能被用到。但是一个生产数据库的UNDO表空间可能会变得非常巨大,而备份完整的UNDO数据文件在恢复时一般可能用到的比例很小。

测试一下:

--数据库版本sys@ORCL>select*fromv$version;BANNER------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------OracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProductionPL/SQLRelease11.2.0.4.0-ProductionCORE11.2.0.4.0ProductionTNSforLinux:Version11.2.0.4.0-ProductionNLSRTLVersion11.2.0.4.0-Production--创建环境zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>insertintot1select*fromdba_segments;5887rowscreated.zx@ORCL>commit;Commitcomplete.zx@ORCL>deletefromt1;288463rowsdeleted.zx@ORCL>selectstatus,sum(bytes)/1024/1024fromdba_undo_extentsgroupbystatus;STATUSSUM(BYTES)/1024/1024-----------------------------------------------UNEXPIRED9.125EXPIRED.4375ACTIVE89.125zx@ORCL>commit;Commitcomplete.--两次备份undo表空间文件RMAN>backupdatafile5;Startingbackupat2016-12-2213:09:27usingchannelORA_DISK_1channelORA_DISK_1:startingfulldatafilebackupsetchannelORA_DISK_1:specifyingdatafile(s)inbackupsetinputdatafilefilenumber=00005name=/u02/app/oracle/oradata/orcl/undotbs2_01.dbfchannelORA_DISK_1:startingpiece1at2016-12-2213:09:27channelORA_DISK_1:finishedpiece1at2016-12-2213:09:28piecehandle=/u02/app/oracle/product/11.2.4/db1/dbs/3aro4007_1_1tag=TAG20161222T130927comment=NONEchannelORA_DISK_1:backupsetcomplete,elapsedtime:00:00:01Finishedbackupat2016-12-2213:09:28StartingControlFileandSPFILEAutobackupat2016-12-2213:09:28piecehandle=/u02/app/oracle/product/11.2.4/db1/dbs/c-1444351641-20161222-0fcomment=NONEFinishedControlFileandSPFILEAutobackupat2016-12-2213:09:31--查看备份后的文件大小RMAN>listbackupofdatafile5;ListofBackupSets===================--第一次备份文件大小99.27MBSKeyTypeLVSizeDeviceTypeElapsedTimeCompletionTime-----------------------------------------------------------------87Full99.27MDISK00:00:032016-12-2212:11:54BPKey:87Status:AVAILABLECompressed:NOTag:TAG20161222T121151PieceName:/u02/app/oracle/product/11.2.4/db1/dbs/36ro3sk7_1_1ListofDatafilesinbackupset87FileLVTypeCkpSCNCkpTimeName-------------------------------------------5Full90420312016-12-2212:11:51/u02/app/oracle/oradata/orcl/undotbs2_01.dbf--第二次备份文件大小2.16MBSKeyTypeLVSizeDeviceTypeElapsedTimeCompletionTime-----------------------------------------------------------------89Full2.16MDISK00:00:012016-12-2212:34:42BPKey:89Status:AVAILABLECompressed:NOTag:TAG20161222T123441PieceName:/u02/app/oracle/product/11.2.4/db1/dbs/38ro3tv1_1_1ListofDatafilesinbackupset89FileLVTypeCkpSCNCkpTimeName-------------------------------------------5Full90425762016-12-2212:34:41/u02/app/oracle/oradata/orcl/undotbs2_01.dbf--查看操作系统文件大小[oracle@rhel6release]$ls-lh/u02/app/oracle/product/11.2.4/db1/dbs/36ro3sk7_1_1-rw-r-----1oracleoinstall100MDec2212:11/u02/app/oracle/product/11.2.4/db1/dbs/36ro3sk7_1_1[oracle@rhel6release]$ls-lh/u02/app/oracle/product/11.2.4/db1/dbs/38ro3tv1_1_1-rw-r-----1oracleoinstall2.2MDec2212:34/u02/app/oracle/product/11.2.4/db1/dbs/38ro3tv1_1_1

这个新特性也有一些限制

- Compatible parametermust beset to 11.0 or higher
- Backup must use a disk or OSB channel
- For 'backup copy of <object>' or 'backup datafilecopy' thedatabase 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)