• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Beginners Guide to RMAN compression for backups

by admin

As the databases keep growing, so does the space occupied by their backups. Fortunately, RMAN has built-in support to compress such large-sized backups which can be handy rather than using an OS utility such as TAR or so on. The following are the 3 kinds of compression techniques used by RMAN:

  1. Null compression
  2. Unused block compression
  3. Binary compression

RMAN uses block compression by default and that’s why you can’t set it off (or on either). Two modes of block compression are available, Unused Block Compression (UBC) and Null Block Compression (NBC). In NBC, all the empty blocks which were not used are skipped. This mode is always used in level 0 and for full backups. In UBC, blocks which are not used by any object are not read or included in the backups. Even the blocks which were used in the past but are empty now (for example, blocks after a truncate table or drop table operation) are skipped. Unlike NBC, which works for all the backups, UBC only works for disk-based backups and tape backups done with Oracle Secure Backup.

Since block level compression works out of the box, there is no special reason to mention it in the BACKUP command.

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 have never been 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.

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. Skipping unused data blocks where possible enables RMAN to back up datafiles using less space, and can make I/O more efficient. 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.

Unused Block Compression is done, if all of the following conditions apply:

  • The COMPATIBLE initialization parameter is set to 10.2
  • There are currently no guaranteed restore points defined for the database
  • 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
  • The backup set is being created on DISK
  • backup is done to TAPE using “OSB” (Oracle Secure Backup)!
Note: Unused block compression is NOT used if backup done to tape using a THIRD PARTY BACKUP SOFTWARE! Unused block compression is ONLY used in Enterprise Edition.

3. Binary Compression

Binary Compression can be done by specifying “AS COMPRESSED” clause in backup command, this compression is called as binary compression.

RMAN can apply a binary compression algorithm as it writes data to backup sets. This compression is similar to the compression provided by many tape vendors when backing up data to tape. But we cannot give exact percentage of compression. This binary compression algorithm can greatly reduce the space required for disk backup storage. It is typically 2x to 4x, and greater for text-intensive databases.

The command to take the compressed backup :

RMAN> backup as compressed backupset database;

There is some CPU overhead associated with compressing backup sets. If the database being backed up is running at or near its maximum load, you may find the overhead from using AS COMPRESSED BACKUPSET unacceptable. In most other circumstances, compressing backupsets saves enough disk space to be worth the CPU overhead.

There is no special command to restore a database from the compressed backupsets, the restore command will be the same as with uncompressed backups. The restore from the compressed backpuset will take more time than uncompressed backupsets.

In addition to the existing binary compression of backup in Oracle 10G, RMAN 11G executable offers a wider range of compression levels with the Advanced Compression Option (ACO). The default compression algorithm setting is BASIC and does not require the Advanced Compression Option.

If, however, you have enabled the Oracle Database 11g Release 2 Advanced Compression Option, you can choose from the following compression levels:

  • LOW – Least impact on backup throughput and suited for environments where CPU resources are the limiting factor.
  • MEDIUM – Recommended for most environments. Good combination of compression ratios and speed
  • HIGH – Best suited for backups over slower networks where the limiting factor is network speed

The following table summarizes all the compression modes:

Compression Mode Default ACO Required Backup size CPU overhead
Basic Yes No Small between Medium to High
Low No Yes Small Low
Medium No Yes Medium Medium
High No Yes Smallest Very High
NOTE: Only BASIC compression is allowed in Standard Edition

Compression can be used for backupset of datafile, archive log and controlfiles. For example:

RMAN> backup as compressed backupset archivelog all;
RMAN> backup as compressed backupset database;
RMAN> backup as compressed backupset current controlfile;

RMAN compress the backupset contents before writing to disk. No extra decompression steps are required during recovery for rman compressed backup;

To configure the compression algorithm:

RMAN> CONFIGURE COMPRESSION ALGORITHM '[alg_name]';

Various Compression Types

For various compression types you can refer to V$RMAN_COMPRESSION_ALGORITHM view.

SQL> select ALGORITHM_NAME, ALGORITHM_DESCRIPTION, ALGORITHM_COMPATIBILITY from V$RMAN_COMPRESSION_ALGORITHM ;

ALGORITHM_NAME  ALGORITHM_DESCRIPTION                                        ALGORITHM_COMPATIB
--------------- ------------------------------------------------------------ ------------------
BZIP2           good compression ratio                                       9.2.0.0.0
BASIC           good compression ratio                                       9.2.0.0.0
LOW             maximum possible compression speed                           11.2.0.0.0
ZLIB            balance between speed and compression ratio                  11.0.0.0.0
MEDIUM          balance between speed and compression ratio                  11.0.0.0.0
HIGH            maximum possible compression ratio                           11.2.0.0.0

6 rows selected.

Undo Block Compression/Optimization

Starting 11g, RMAN performs undo block optimization. In backup undo optimization, RMAN excludes undo not needed for recovery of a backup, that is, for transactions that have been committed. Undo optimization is only possible if:

  • This is a backup set backup.
  • Full or incremental level 0.
  • Not a validate.
  • Backup piece version is 11.0 or above.
  • User has not disabled undo optimization with “_undo_block_compression = FALSE“
  • Backup is going to DISK or OSB tape.
  • No Guaranteed Restore Point (This check is enabled from 11.2 onwards).

Filed Under: oracle, Oracle 10g, Oracle 11g, oracle 12c, RMAN

Some more articles you might also be interested in …

  1. How to Delete ASM Disk on Multipath Device in CentOS/RHEL
  2. ORA-01666: control file is for a standby database – failover over standby as primary
  3. What is spfile in Oracle Database
  4. SLES 12: Database Startup Error with ORA-27300 ORA-27301 ORA-27303 While Starting using Srvctl
  5. How to Drop Existing Temporary Tablespace and create new in Oracle 11g
  6. Using Rule Sets in Oracle Database Vault
  7. How To Add New Disk to An Existing Diskgroup on RAC Cluster or Standalone ASM Configuration
  8. Oracle Dataguard 12c: How to perform Switchover using DGMGRL
  9. How to Monitor SGA Memory on Oracle Pluggable Databases
  10. How To Set the Permission of the Files Created Using UTL_FILE

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright