RMAN備份檔案遠大於資料庫大小的原因分析

來源:互聯網
上載者:User

RMAN備份檔案遠大於資料庫大小的原因分析

在跟客戶進行交流的時候,客戶提出有一套資料庫只有40G的大小,但是通過RMAN備份出來的檔案有80GB,使用expdp匯出來的DUMP檔案小於40GB,感覺有些詫異,RMAN不是只備份有資料的資料區塊嗎?怎麼備份也不應該超過40GB啊,難道跟高水位線有關?帶著這些疑問通過在MOS上查閱了一些文章,發現確實有出現RMAN備份檔案遠大於資料庫所佔用空間的問題出現的可能性。

首先要明白RMAN的壓縮類型:

By default RMAN has three types of compression : 

1.  Null compression

2.  Unused block compression

3. Binary compression    <<<< 這是我們最常用到的壓縮類型,backup as compressed backupset ....

Till Oracle Version 10.1 only 'Null' compression is done by default but from Oracle Version 10.2 'Null' and 'unused block' compression is done.  The types of compression are done automatically, no special command is required.  

'Null' and 'unused block' compression are filtering which blocks are send to the backups. 'Binary' compression is an additional compression on the blocks send to the backup. 

1. Null Compression: 

When backing up datafiles into backup sets, RMAN does not back up the contents of data blocks that have never been allocated. (In previous releases, this behavior was referred to as NULL compression). This means RMAN will never backup the blocks that are ever used.  RMAN, through Oracle version 9i and forward has performed null compression. 

Example : You have a tablespace having one datafile of size 100MB and out of 100MB only 50 MB is used. Then RMAN will backup only 50MB.  <<<< 在10.2之前的版本(準確的說是10.2.0.2之前的版本),Oracle預設都是這種壓縮類型,RMAN不備份從未分配的資料區塊,換句話說,RMAN不備份從來沒使用過的塊。例如:如果一個資料表空間有一個大小為100MB的資料檔案,該檔案使用了50MB,RMAN只備份50MB(RMAN的備份和是不是高水位線下的空塊沒關係,和資料區塊有沒有被分配過有關係)。

NOTE:  
   Null Compression also applies to SE and SE ONE 

2. Unused Block Compression:

From Oracle version 10.2 forward, RMAN skips the blocks that do no currently contain data and this is called 'Unused Block Compression'. RMAN now creates more compact backups of datafiles, by skipping datafile blocks that are not currently used to store data. In previous releases, RMAN only supported NULL compression, which skipped space in datafiles that had never been allocated. No extra action is required on the part of the DBA to use this feature. 

Example : You have a tablespace having one datafile of size 100MB and out of 100MB, 50MB is used by the user tables. Then user dropped a table belonging to that tablespace which was of 25MB, with the new unused block compression on 25MB of the files is backed up. In this example if null compression is used then it would have backed up 50MB because null compression will consider the blocks that are formatted/ever used.   <<<< 從10.2版本開始(準確的說是10.2.0.2版本),出現了一種新的壓縮類型-Unused Block Compression,這種備份類型將跳過當前不包含資料的塊(即使曾經使用過該塊),這是新版本RMAN預設的壓縮方式。例如:如果一個資料表空間有一個大小為100MB的資料檔案,50MB用於使用者表,使用者drop了一個屬於該空間的25MB大小的表,新的預設的UNUSED BLOCK COMPRESSION壓縮類型將只備份25MB的資料區塊。如果在NULL COMPRESSION的壓縮類型,將備份50MB的資料區塊,因為NULL COMPRESSION的壓縮類型會考慮塊被格式化過,或者說曾經被使用過。

Unused Block Compression is done, if all of the following conditions apply:     <<<< 雖然UNUSED BLOCK COMPRESSION是10.2的預設壓縮類型,但不是說10.2的版本通過RMAN備份就一定使用這種壓縮類型,使用它必須滿足以下5個條件。

+ The COMPATIBLE initialization parameter is set to 10.2     <<<< 即使將Oracle資料庫升級到10.2.0.2以上的版本,預設情況下COMPATIBLE初始化參數的值為空白,要使用UNUSED BLOCK COMPRESSION功能必須手動設定該參數。

+ There are currently no guaranteed restore points defined for the database <<<< 沒有FLASHBACK中的強制還原點。

+ The datafile is locally managed <<<< 本地化資料檔案管理方式,預設即是。

+ The datafile is being backed up to a backup set as part of a full backup or a level 0 incremental backup <<<< 資料檔案作為全庫備份的一部分,或者是基於0層級備份的增量備份。

+ The backup set is being created on DISK <<<< 備份組建立在磁碟上。
    or
  backup is done to TAPE using "OSB" (Oracle Secure Backup)!    <<<< 或者使用OSB將資料備份到磁帶,其他第三方的備份軟體無法使用這種壓縮類型,只能是NULL COMPRESSION。

 

  Note:
  Unused Block Compression is NOT used if backup done to tape using a THIRD PARTY BACKUP SOFTWARE !  
  Unused block compression IS executed in Standard Edition.   <<<< 標準版也可以使用這種類型的壓縮方式。

 

Skipping unused data blocks where possible enables RMAN to back up datafiles using less space, and can make I/O more efficient.


以上內容摘取自《A Complete Understanding of RMAN Compression (文檔 ID 563427.1)》

以下的內容說明在10.2.0.1版本中,UNUSED BLOCK COMPRESSION壓縮類型不可用:

Unused block compression is NOT available with the Base Release of 10gR2 (10.2.0.1). 

It only became available in the first Patch Set Release (10.2.0.2) for NEW tablespaces only.

So for tablespaces  created:

  • before 10.2.0.2 was applied
  • before compatible was set to 10.2

we cannot use Unused Block Compression.

The cause of this problem has been identified and verified in an 'unpublished' Bug 4720762 - Fixed in Product Version 11.0 


以上內容摘自:《Why is RMAN not using Unused Block Compression during backup? (文檔 ID 798844.1)》

   總結:後經過和客戶的確認,客戶資料庫的版本為10.2.0.4,所以我們大膽的推測,雖然客戶的版本高於10.2.0.2,但是由於預設情況下資料庫初始化參數COMPITABLE為空白,或不符合其他條件導致UNUSED BLOCK COMPRESSION壓縮類型無法在RMAN中使用到,所以凡是曾經使用到的資料區塊RMAN都會進行備份(NULL COMPRESSION),80GB可能是客戶曾經用到過的空間大小,後來釋放了相應空間,所以當前備份才呈現出40GB的資料庫RMAN備份出來有80GB。

--end--

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.