DBA Tips Archive for Oracle

  


Configuring RMAN Default Settings

by Jeff Hunter, Sr. Database Administrator


Contents

  1. Overview
  2. Viewing Values
  3. Using Substitution Variables
  4. Using the configure Command to Clear Values
  5. PARAM:   Retention Policy  
  6. PARAM:   Backup Optimization
  7. PARAM:   Default Device Type  
  8. PARAM:   Controlfile Autobackup  
  9. PARAM:   Controlfile Autobackup Format  
  10. PARAM:   Parallelism
  11. PARAM:   Database Backup Copies
  12. PARAM:   Archivelog Backup Copies
  13. PARAM:   Channel Configuration  
  14. PARAM:   Maxsetsize
  15. PARAM:   Snapshot Controlfile
  16. PARAM:   Exclude Tablespace

NOTE: Items marked with an are those that I typically set for any environment. All others, I generally keep set to their default value.



Overview

RMAN (Oracle9i and higher) now allows the DBA to perform automated database backup and recovery. This feature is supported by RMAN with its ability to define default values for a number of settings, (i.e. channel configuration). Setting RMAN settings is performed with the configure command.

This article presents an overview of all Oracle9i RMAN configuration parameters and examples of how they can be set.



Viewing Values

Before getting into the configure command, lets first take a look at our default settings by using the show command:
RMAN> SHOW ALL;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/9.2.0/dbs/snapcf_TARGDB.f'; # default
From the above listing, you can see that the RMAN allows you to set default values for some of the following:

This article will provide detailed information on all of these RMAN configuration parameters and how they can be defined.



Using Substitution Variables

RMAN can make use of substitution variables in creating format strings to generate filenames. Without due care, non-unique filenames can be generated and, under certain circumstances, this can cause backup data to be overwritten and therefore lost. So be careful; this is not a bug with Oracle, but rather a usage error.

Format Description
%p specifies the backup piece number within the backup set. This value starts at 1 for each backup set and is incremented by 1 as each backup piece is created.
%s specifies the backup set number. This number is a counter in the control file that is incremented for each backup set. The counter value starts at 1 and is unique for the lifetime of the control file. If you restore a backup control file, then duplicate values can result. Also, CREATE CONTROLFILE initializes the counter back to 1.
%d specifies the database name.
%n specifies the database name, padded on the right with 'x' characters to a total length of 8 characters. For example, if PROD1 is the database name, then PROD1xxx is the padded database name.
%t specifies the backup set timestamp, which is a 4-byte value derived as the number of seconds elapsed since a fixed reference time. The combination of %s and %t can be used to form a unique name for the backup set.
%u specifies an 8-character name constituted by compressed representations of the backup set number and the time the backup set was created.
%c (Oracle8i or higher) - specifies the copy number of the backup piece within a set of duplexed backup pieces. If you did not issue the set duplex command, then this variable will be 1 for regular backup sets and 0 for proxy copies. If you issued set duplex, the variable identifies the copy number: 1, 2, 3, or 4.
%U (Oracle8i or higher) - specifies a convenient shorthand for %u_%p_%c that guarantees uniqueness in generated backup filenames. If you do not specify a format, RMAN uses %U by default. %U is the default in Oracle8i.



Using the configure Command to Clear Values

Before discussing each of the RMAN configuration parameters in detail, let's first take a look at how to clear values. (Setting these configuration parameters to their default values) Like setting an RMAN configuration parameter, you use the configure command, but will use the clear option.

To set the MAXSETSIZE parameter back to its default value of UNLIMITED:

RMAN> configure maxsetsize clear;
Here is a list of commands that clear several RMAN settings back to their default values:
RMAN> CONFIGURE RETENTION POLICY CLEAR;
RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR;
RMAN> CONFIGURE DEFAULT DEVICE TYPE CLEAR;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP CLEAR;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT CLEAR;
RMAN> CONFIGURE DEVICE TYPE DISK CLEAR;
RMAN> CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
RMAN> CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT  CLEAR;
RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT CLEAR;
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR;
RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT CLEAR;
RMAN> CONFIGURE MAXSETSIZE CLEAR;
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME CLEAR;
RMAN> # CONFIGURE EXCLUDE FOR TABLESPACE USERS_READ_TBS;



RETENTION POLICY

Used to control how long RMAN will keep backups. This can be configured by the "number" of backups taken, or by the numbers of "days" to keep. Here is an example of both:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
Note that when configuring a retention policy, RMAN will not cause backups to be automatically deleted. The retention policy will, however, mark backups as OBSOLETE that have fallen outside the retention period. RMAN commands like "REPORT OBSOLETE" and "DELETE OBSOLETE" will work with these obsolete backups.

If back up your database infrequently, you probably will prefer a redundancy policy that is stated in terms of number of backups rather than backups later than n days old. In this case, you would use the redundancy parameter as follows:

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
Finally, if you do not want to use a retention policy, simply use:
RMAN> CONFIGURE RETENTION POLICY TO NONE;



BACKUP OPTIMIZATION

Used to enable or disable backup optimization. Backup file optimization can assist in reducing the space used to backup the database. When performing an RMAN backup, a check is done on the file before backup to see if the file already exists in a backupset with the same information: (dbid, checkpoint, and resetlogs data).

For archive logs, the same file means the same dbid, thread, sequence, and resetlogs data. If the DELETE INPUT option is used, RMAN deletes all the files that would have been backed up, even when the file is not included due to file optimization.

The two possible values for backup optimization is ON and OFF as shown in the following example syntax:

CONFIGURE BACKUP OPTIMIZATION OFF;

CONFIGURE BACKUP OPTIMIZATION ON;
Use caution when enabling backup optimization if you use a media manager that has an expiration policy. The media manager can expire tapes containing backups (using its media control software), and RMAN will not make new backups because of optimization. One way to protect from this is to run CROSSCHECK periodically to synchronize the repository with the media manager.

Also note that you should consider how backup optimization works with regards to the RETENTION POLICY. RMAN will only work with files within the retention period. For example, consider performing a backup with optimization enabled and a retention period of 3 days. RMAN will only compare the datafile with backup sets within the 3 day period - even if the datafile it is about to backup hasn't changed within that 3 days.



DEFAULT DEVICE TYPE

Configures the default backup / restore device type for automatic channels. The two values for now are TAPE (SBT) and DISK (DISK) - the default being DISK. By default, the BACKUP and COPY commands only allocate channels of the default device type. For example, if you configure automatic channels for DISK and sbt and set the default device type to DISK, then RMAN only allocates disk channels when you run the BACKUP DATABASE command. You can override this behavior either by manually allocating channels in a RUN command, or by specifying DEVICE TYPE on the BACKUP command itself. The RESTORE command allocates automatic channels of all configured device types, regardless of the default device type. The RESTORE command obeys the PARALLELISM setting for each configured device type.

The following two examples show the syntax for configuring the default device type to TAPE (SBT) - then another command to re-configure the default device type to DISK:

CONFIGURE DEFAULT DEVICE TYPE TO DISK;

CONFIGURE DEFAULT DEVICE TYPE TO SBT;



CONTROLFILE AUTOBACKUP

Starting with Oracle9i, RMAN offers the ability to backup the control file and the database parameter file (SPFILE only) and have this take place automatically by default after EACH backup. By default, this feature is not enabled. This feature can be enabled or disabled using the example syntax below:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP OFF;
When the CONTROLFILE AUTOBACKUP feature is enabled, then RMAN performs a control file autobackup in the following circumstances:

The "first channel" allocated during the BACKUP or COPY job creates the autobackup and places it "into its own backup set"; for post-structural autobackups, the "default disk channel" makes the backup.

RMAN writes both the CONTROLFILE and the SPFILE (if the database was started with an SPFILE) to the same backup piece. After the CONTROLFILE AUTOBACKUP completes, Oracle writes a message containing the complete path of the backup piece and the device type to the alert log.

RMAN automatically backs up the current control file using the default format of %F (see entry for CONFIGURE CONTROLFILE AUTOBACKUP FORMAT for an explanation of this substitution variable). You can change this format using the CONFIGURE CONTROLFILE AUTOBACKUP FORMAT and SET CONTROLFILE AUTOBACKUP FORMAT commands.

When this feature is disabled, any BACKUP command that includes datafile 1 (including BACKUP DATABASE) automatically includes the current control file and server parameter file in the backup set. Otherwise, RMAN does not include these files.

NOTE: You may see occasions where RMAN will sometimes automatically include the CONTROLFILE and SPFILE in the backupsets during a backup. This is normal and is documented (above). When CONTROLFILE AUTOBACKUP is not enabled, the CONTROLFILE and SPFILE, (if the database was started with an spfile), are included automatically when datafile 1 is backed up. Consider the following backup:
RMAN> backup datafile 1;
It will include the CONTROLFILE and the SPFILE (when the database is started with a spfile).



CONTROLFILE AUTOBACKUP FORMAT

Configures the default filename format for the control file autobackup on the specified device type. By default, the initial format is %F for all devices. Any default format string specified with CONFIGURE must include the %F substitution variable (see BACKUP). This variable translates into c-IIIIIIIIII-YYYYMMDD-QQ, where:

Specify CLEAR to return the format to the default %F.

NOTE: The %F tag is essential for RMAN to be able to restore the file without a recovery catalog.

Here is an example of how to set the format of the autobackup controlfile:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/orabackup/rman/ORA920/%F';



PARALLELISM

Configure RMAN to use [n] number of disk channels for backup, restore, recovery, and maintenance operations. Device types that are eligible for use in jobs that use automatic channels can sets the degree of channel parallelism. (The DISK device type is the default)

The PARALLELISM parameter specifies the number of automatic channels of the specified device type allocated for RMAN jobs. RMAN always allocates the number of channels specified by PARALLELISM, although it may actually use only a subset of these channels. By default, PARALLELISM = 1.

Take the following example; you can set PARALLELISM for DISK backups to 3. If you configure automatic channels of type disk and tape, and set the default device type as disk, then RMAN allocates three disk channels when you run BACKUP DATABASE at the RMAN prompt.

To change the parallelism for a device type to [n], run:

CONFIGURE DEVICE TYPE [DISK | SBT] PARALLELISM [n];

Here are several examples of how to configure PARALLELISM to 3 for sbt and then change it to 2:

CONFIGURE DEVICE TYPE sbt PARALLELISM 3;
CONFIGURE DEVICE TYPE sbt PARALLELISM 2;

Another example that configures parallelism to 2 for automatic disk channel.

CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

NOTE: If you configure [n] manually numbered channels, the PARALLELISM setting can be greater than or less than [n]. For example, you can manually number 10 automatic channels and configure PARALLELISM to 2 or even 12.



DATABASE (and ARCHIVELOG) BACKUP COPIES

Specifies the number of copies of each backup set for DATAFILE (both datafiles and control files) or ARCHIVELOG files on the specified device type, from 1 (default) to 4. If duplexing is specified in the BACKUP command or in a SET BACKUP COPIES command, then the CONFIGURE setting is overridden.

Here is the general syntax:

    {ARCHIVELOG| DATAFILE}
        BACKUP COPIES FOR DEVICE
        TYPE deviceSpecifier
        TO integer;

NOTE: Control file autobackups on disk are a special case and are never duplexed. RMAN always writes one and only copy.


Here are several examples of how to set this parameter:

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 2;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 2;


To clear this parameter, use the following:

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK CLEAR;



CHANNEL CONFIGURATION

Specifies the standard or AUXILIARY channel that you are configuring or clearing, as well as the device type (DISK or sbt) of the channel. You can either configure a "generic channel" or specify a channel by number, where "integer" is less than 255.

Next let's look at setting defaults for channels. You can either set default settings for all channels with the configure channel device type command or you can set defaults for a specific channel using the configure channel n device type, where n is the channel you want to set for.

Now, let's take a look at the general syntax:

    CHANNEL integer DEVICE TYPE deviceSpecifier allocOperandList;

            integer              You can specify a channel by number. You may
                                 also exclude an integer, in which case you
                                 are specifying a general channel.
            deviceSpecifier      {DISK | SBT}
            allocOperandList     /* Specifies control options for the  */
                                 /* allocated channel                  */
                                 [PARMS         = 'channel_parms']
                                 [CONNECT       = (quoted string)]
                                 [FORMAT        = 'format_sring']
                                 [MAXPIECESIZE  = integer [K|M|G]]
                                 [RATE          = integer [K|M|G]]
                                 [MAXOPENFILES  = integer]
                                 [SEND          = 'command']
I generally use this parameter to configure the location (directory) and file format where RMAN will write disk backups to. Here are some of the substitution variables that can be used in the backup set file name: |
    %d      Database name
    %s      Backup set number
    %p      Backup piece number
    %t      4-byte timestamp
When automated channels are allocated, Oracle assigns default names to these channels. These default names depend on the type of default device used. The following table provides the default name format that will be used for each device:

Default Device Type Default Name Format Example
Disk ORA_DISK_n ORA_DISK_1, ORA_DISK_2
Tape ORA_SBT_TAPE_n ORA_SBT_TAPE_1, ORA_SBT_TAPE_1


Now let's look at setting the number of channels to be allocated during an automated backup or recovery operation. This example will set the default level of parallelism for disk operations to two. Now, if an automated backup is started, two channels will be allocated to perform the backup in parallel:

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/orabackup1/rman/ORA920/backup_db_%d_S_%s_P_%p_T_%t';
RMAN> CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/orabackup2/rman/ORA920/backup_db_%d_S_%s_P_%p_T_%t';
NOTE: When setting the default level of parallelism, you should set it to the number of disks or tape drives attached to which you will be backing up.


You can also control the size of a backup set piece or the entire backup itself. In the following example, I will limit channel 1 to create each individual backup piece at a maximum size of 1024MB. Take note that this command does not limit the overall size of the backup:

RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/orabackup1/rman/ORA920/backup_db_%d_S_%s_P_%p_T_%t' MAXPIECESIZE 1024m;


You can also set to limit all channels to have a limit of 1024MB by using:

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/orabackup/rman/ORA920/backup_db_%d_S_%s_P_%p_T_%t' MAXPIECESIZE 1024m;


You can also limit the speed or rate of the backup channel:

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/orabackup/rman/ORA920/backup_db_%d_S_%s_P_%p_T_%t' MAXPIECESIZE 1024m RATE 5m;


NOTE: If you configure a generic channel (that is, if you do not specify a channel number), then RMAN uses the generic settings for every parallelized channel except any channel number that you have explicitly configured. In other words, a generic channel setting specifies options for all channels not configured explicitly.

NOTE: The RATE parameter is intended to slow down a backup so that you can run it in the background with as little effect as possible on OLTP operations. The RATE parameter specifies units of bytes/second. Test to find a value that improves performance of your queries while still letting RMAN complete the backup in a reasonable amount of time. Note that RATE is not designed to increase backup throughput, but to decrease backup throughput so that more disk bandwidth is available for other database operations.

NOTE: The CONNECT parameter specifies a connect string to the database instance where RMAN should conduct the backup or restore operations. Use this parameter to spread the work of backup or restore operations across different instances in an Oracle Real Application Clusters configuration. If you do not specify this parameter, and if you did not specify the AUXILIARY option, then RMAN conducts all operations on the target database instance specified by the command-line parameter or the instance connected to when you issued the CONNECT command. Typically, you should not use the CONNECT parameter in conjunction with the AUXILIARY option.

NOTE: We can also assign specify an assigned name to channels that you allocate when using the allocate channel command. For example the following command will create a channel named c1:
RMAN> run {...
allocate channel c1 device type disk;
...}

NOTE: If AUXILIARY is specified, then this configuration is used only for channels allocated at the auxiliary instance. If no auxiliary device configuration is specified, and if RMAN needs to automatically allocate auxiliary channels, then RMAN uses the target database device configuration. It is not necessary to specify configuration information for auxiliary channels unless they require different parameters from the target channels.

NOTE: For generic channels of a specified device type, a new command erases previous settings for this device type. Assume that you run these commands:
CONFIGURE CHANNEL DEVICE TYPE sbt MAXPIECESIZE 1G;
CONFIGURE CHANNEL DEVICE TYPE sbt RATE 1700K;
The second command erases the MAXPIECESIZE setting of the first command.

NOTE: It is useful to understand how the CLEAR command works for this parameter. CLEAR Clears the specified channel. For example, CONFIGURE CHANNEL 1 DEVICE TYPE DISK CLEAR returns only channel 1 to its default, whereas CONFIGURE CHANNEL DEVICE TYPE DISK CLEAR returns the generic disk channel to its default. Note that you cannot specify any other channel options (for example, PARMS) when you specify CLEAR.



MAXSETSIZE

Specifies the maximum size of each backup set created on a channel. By default MAXSETSIZE is set to UNLIMITED, meaning that it is disabled.

Here is the general syntax:

    CONFIGURE MAXSETSIZE TO { integer [K|M|G] | UNLIMITED | CLEAR };

        TO integer       Specifies the maximum set size in bytes, kilobytes (K),
                         megabytes (M), or gigabtyes (G). The default setting is
                         in bytes and is rounded down to kilobtyes. For example,
                         if you set MAXSETSIZE to 5000, RMAN sets the maximum set
                         size at 4 kilobytes (that is, 4096 bytes), which is the
                         lower kilobyte boundary of 5000. The minimum value must
                         be greater than or equal to the database block size.
        TO UNLIMITED     Specifies that there is no size limit for backup sets.
        CLEAR            Resets the maximum set size to its default value.


The following command will set the maximum size of a backup set to 1.5GB:

RMAN> CONFIGURE MAXSETSIZE TO 1500m;
NOTE: Take careful note when setting this parameter. While the size of your database may be small enough for MAXSETSIZE, your database may grow beyond beyond MAXSETSIZE which will cause your database backups to fail.

For some time, there have been some question as to what this parameter limits. While the documentation states that it limits the size of a backup set, it seems to place limits on the datafile sizes - even though I am using backup sets and not image copies. For example, I have set MAXSETSIZE to 500m and attempted to backup a database, only to get the error:

RMAN-06183: datafile or datafilecopy larger than SETSIZE: file# 1 /u10/app/oradata/TARGDB/users01.dbf
The file (users01.dbf) is larger than 500MB but the backupset is considerably smaller than that (there is very little data in there at present). The Oracle documentation states that MAXSETSIZE limits the size of the backupsets, NOT the size of the datafiles which can be backed-up. All I can say, is that Oracle states that this is expected behavior, and I think it is a bug in the documentation.

If you want to set the value backup to its default, use:

RMAN> CONFIGURE MAXSETSIZE CLEAR;



SNAPSHOT CONTROLFILE

A snapshot control file is created by RMAN during the backup process that serves as a point-in-time copy of the database control file. This will ensure that that backups being taken is consistent to a given point in time. For example, if you add a datafile or tablespace to a database after the backup has started, (assuming an online backup and before the backup has ended), that datafile and/or tablespace will not be included in the backup. It is sometimes required that the location and name of the snapshot control file be changed from its default.

To set the snapshot control file to a different location (and name) use the following:

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/orabackup/rman/ORA920/scontrolfile.ctl';

NOTE: The default value for the snapshot control file name is platform-specific and dependent on the Oracle home. For example, the default on some UNIX system is ?/dbs/snapcf_@.f. If you clear the control file name, and you change the Oracle home, then the default location of the snapshot control file changes as well.



EXCLUDE TABLESPACE

Excludes the specified tablespace from BACKUP DATABASE commands. Note that you cannot exclude the SYSTEM tablespace. By default, each tablespace is not excluded, that is, the exclude functionality is disabled.

The exclusion is stored as an attribute of the tablespace, not the individual datafiles, so the exclusion applies to any files that are added to this tablespace in the future.

If you run CONFIGURE ... CLEAR on a tablespace after excluding it, then it returns to the default configuration of "not excluded."

You can still back up the configured tablespace by explicitly specifying it in a BACKUP command or by specifying the NOEXCLUDE option on a BACKUP DATABASE command.

The general syntax is:

EXCLUDE FOR TABLESPACE tablespace_name;
In this example, I want to exclude the tablespace named 'READ_ONLY_TBS' from the backup:
RMAN> CONFIGURE EXCLUDE FOR TABLESPACE READ_ONLY_TBS;


Copyright (c) 1998-2017 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Thursday, 18-Nov-2010 18:30:08 EST
Page Count: 12789