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。

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/27fa7cf28cf42e9f7290a325e25ded7a.html