0) Restoring Default RMAN Configuration Settings
================================
Let us first learn how we can undo the configuration changes mentioned below and come back to default state
You can return any setting to its default value by using CONFIGURE... CLEAR, as in
these examples:
RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR;
RMAN> CONFIGURE RETENTION POLICY CLEAR;
1) Check DB_RECOVERY_DEST and DB_RECOVERY_DEST_SIZE
========================================
For Oracle RAC and FRA setup make sure that both DB_RECOVERY_DEST and DB_RECOVERY_DEST_SIZE have same values across all cluster instances.
SQL> show parameter DB_RECOVERY
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +RECOVERYDEST
db_recovery_file_dest_size big integer 2G
2) CONFIGURE CHANNELS
=================
RMAN channels (connections to server sessions on the target database) perform all RMAN tasks. By default, RMAN allocates one disk channel for all operations.
A) Oracle RAC 9i
Starting with Oracle RAC 9i rman had to be configured by explicitly configuring a channel connecting to a specific instance. The purpose was to
Balance between instances for parallelism for backup and recovery.
Accessing locally configured archive log destinations. Only when connecting explicitly to an instance an archive log destination can be backed up and restored if it is on a NON-shared location. Also a local backup on the node can be done. Only the node doing the backup can restore.
CONFIGURE CHANNEL 1 DEVICE TYPE sbt CONNECT = ‘SYS/oracle@trgt1′;
CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT = ‘SYS/oracle@trgt2′;
An explicit connection to an instance allows a backup on a location accessible by the node where is the instance. For non-shared archive destinations this is the only option. In Oracle 9i an explicit connection also allows to run a backup in parallel in channels across each RAC instance.
B) Oracle 10gR2
Starting from Oracle 10gR2 rman was enhanced to benefit from dynamic parallelism. That is, RMAN can be configured for automatic load balancing. This configuration is still valid in 11gR2. Note that there is no need to explicitly specify a channel with connect clause. The one time configuration as below is sufficient to perform a backup and recovery.
CONFIGURE DEVICE TYPE [disk | sbt] PARALLELISM number of channels;
Here specify the number of channels that can be used for the backup and restore. The configuration introduced in 9i is still applicable up to 11gR2 ( 10gR2, 11gR1, 11gR2).
Note : If the archived logs are stored on shared storage, then its not required to connect different instance for different channels.
Manually allocated channels (allocated by using ALLOCATE) should be distinguished from automatically allocated channels (specified by using CONFIGURE). Manually allocated channels apply only to the RUN job in which you issue the command. Automatic channels apply to any RMAN job in which you do not manually allocate channels. You can always override automatic channel configurations by manually allocating channels within a RUN command.
Each channel operates on one backup set or image copy at a time. RMAN automatically releases the channel at the end of the job.
You can control the degree of parallelism within a job by allocating the desired number of channels. Allocating multiple channels simultaneously allows a single job to read or write multiple backup sets or disk copies in parallel. If you establish multiple connections, then each connection operates on a separate backup set or disk copy.
Whether ALLOCATE CHANNEL causes operating system resources to be allocated immediately depends on the operating system. On some platforms, operating system resources are allocated at the time the command is issued. On other platforms, operating system resources are not allocated until you open a file for reading or writing.
3) Configuring RMAN Snapshot control file location
================================
Staring from Oracle 10gR2 and into 11gR2 a snapshot control file location needs to be specified .Having the controlfile on a shared system, like the 1GB OCFS files we created for the OCR, votingdisks or spfileasm, would make more sense, if you need to run backup from multiple nodes. Alternatively, you could have the same local file destination on all nodes.
The location is stored as a persistent configuration and therefore needs to be the same on all nodes that are to perform backup. That is, all nodes need to have the same location ( full path name and file name). Like in our case it is set as /u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_brij1.f which is actually default value $ORACLE_HOME/dbs used by RMAN.
The snapshot control file is created only during backup in the following cases.
To re-synchronize the recovery catalog from a read-consistent control file during backup.
Note
Like in our case below, we had registered brij database in the RMAN catalog by connecting to brij1 instance and after registering the database RMAN has performed a re-sync, which created the snap shot file snapcf_brij1.f as shown below
If a backup of the control file is done.
The snapshot file does not need to be globally available.
a) To determine the snapshot file location issue.
SHOW SNAPSHOT CONTROLFILE NAME;
RMAN> SHOW SNAPSHOT CONTROLFILE NAME;
RMAN configuration parameters are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/snapcf_brij1.f'; # default
b) To change the snapshot file location issue.
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘$ORACLE_HOME/dbs/scf/snapcf_brij1.f’;
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/scf/snapcf_brij1.f';
snapshot control file name set to: /u01/app/oracle/product/10.2.0/db_1/dbs/scf/snapcf_brij1.f
new RMAN configuration parameters are successfully stored
c) To delete a snapshot file location change the location and delete the old one.
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘new_name’;
DELETE COPY OF CONTROLFILE;
RMAN> delete copy of controlfile;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=126 instance=brij1 devtype=DISK
RMAN>
RMAN> SHOW SNAPSHOT CONTROLFILE NAME;
RMAN configuration parameters are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_1/dbs/scf/snapcf_brij1.f';
The location can be a raw device, block device, ASM , CFS , local file system or supported NFS.
4) Configure control file and SPFILE autobackup
==============================
> RMAN can be configured to automatically back up the control file and server parameter file whenever the database structure metadata in the control file changes and whenever a backup record is added.
> The autobackup enables RMAN to recover the database even if the current control file, catalog, and server parameter file are lost.
For Oracle RAC 10gR2, 11gR1 and 11gR2 configure control file and SPFILE autobackup and specify the autobackup location. The location should be available from all cluster nodes.
At RMAN prompt issue ‘CONFIGURE CONTROLFILE AUTOBACKUP ON;’ to automatically backup the controlfile and SPFILE whenever issue any backup or copy commend.
Issue at RMAN prompt CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘+DATA’; to specify autobackup location.
Note
You can very well store your backup on ASM disk group. Though you should backup your data into a separate diskgroup, that are physically on different devices than your database files. This is to protect your database, like in case you face any failure of disk and if both your database, backup and archive log files are all on the same diskgroup, than it will means a DATA LOSS!!
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+RECOVERYDEST';
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+RECOVERYDEST';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+RECOVERYDEST';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN>
VERIFICATION >>>>>
Take backup of current control file and see where it gets stored
RMAN> backup current controlfile;
Starting backup at 05-NOV-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=136 instance=brij1 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 05-NOV-11
channel ORA_DISK_1: finished piece 1 at 05-NOV-11
piece handle=+RECOVERYDEST/brij/backupset/2011_11_05/ncnnf0_tag20111105t190825_0.264.766436907 tag=TAG20111105T190825 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
Finished backup at 05-NOV-11
5) Configure Parallelism of backups
=======================
> RMAN can break out certain commands and use multiple, parallel processes to execute the issued command.
> This does not mean that if you issue five RMAN commands, RMAN will try to parallelize and run those five commands at the same time, but rather that each individual command will be parallelized.
> If you allocate multiple channels, RMAN simultaneously uses multiple processes to work on the command, writing data simultaneously through all channels
RMAN> configure device type disk parallelism 3;
RMAN> backup database format '+RECOVERYDEST';
************ this uses three concurrent processes to back up the database**************
6) Tagging a backup
==============
> Sometimes you may want to distinguish between daily or weekly backups, or you may want to distinguish easily between various incremental-level backups
For example :
RMAN> backup incremental level 3 tag inc_level_3
> Tags can be used with the list command to locate backup sets quickly and can also be used with the restore and switch commands.
For example :
RMAN> list backuppiece tag=inc_level_3;
7) Configure Backup Retention Policy
=========================
> RMAN automates the implementation of a backup retention policy
> Basic steps
a) CONFIGURE RETENTION POLICYcommand lets you set the retention policy that will apply to all of your database files by default.
b) REPORT OBSOLETE command lets you list backups currently on disk that are obsolete under the retention policy.
c) DELETE OBSOLETE command deletes the files which REPORT OBSOLETE lists as obsolete.
TYPES OF RETENTION POLICY :
1) Recovery Window-Based Backup Retention Policy
> It guarantees that you can performpoint-in-time recovery to any point in the past, up to a number of days that you specify.
For example :
RMAN> configure retention policy to recovery window of 1 days;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 138 05-NOV-11
Backup Piece 143 05-NOV-11 +RECOVERYDEST/brij/backupset/2011_11_05/ncsnf0_tag20111105t191922_0.269.766437661
RMAN> delete obsolete ;
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 138 05-NOV-11
Backup Piece 143 05-NOV-11 +RECOVERYDEST/brij/backupset/2011_11_05/ncsnf0_tag20111105t191922_0.269.766437661
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=+RECOVERYDEST/brij/backupset/2011_11_05/ncsnf0_tag20111105t191922_0.269.766437661 recid=6 stamp=766437661
Deleted 1 objects
2) Redundancy-Based Backup Retention Policy
> determines whether a backup is obsolete based on how many backups of a file are currently on disk.
> The default retention policy is REDUNDANCY=1
> Assume that you make a backup of datafile 7 on Monday, Tuesday, Wednesday, and Thursday. You now have four backups of the datafile. If REDUNDANCY is 2, then the Monday and Tuesday backups are obsolete. If you make another backup on Friday, then the Wednesday backup becomes obsolete.
> When you disable the retention policy, RMAN does not consider any backup as obsolete. To disable the retention policy, run this command:
CONFIGURE RETENTION POLICY TO NONE;
important point >>> If you are using a flash recovery area, then you should not run your database with the retention policy disabled as you run into risk of filling up your FRA.
for example :
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 31 14-SEP-11 +DG1/brij/1_4_757308535.dbf
Archive Log 32 14-SEP-11 +DG1/brij/1_5_757308535.dbf
Archive Log 33 28-SEP-11 +DG1/brij/1_1_761792516.dbf
Archive Log 34 06-OCT-11 +DG1/brij/2_1_761792516.dbf
Archive Log 35 06-OCT-11 +DG1/brij/1_2_761792516.dbf
Archive Log 36 06-OCT-11 +DG1/brij/1_3_761792516.dbf
Archive Log 37 06-OCT-11 +DG1/brij/2_2_761792516.dbf
Archive Log 38 07-OCT-11 +DG1/brij/1_4_761792516.dbf
Archive Log 39 08-OCT-11 +DG1/brij/2_3_761792516.dbf
Archive Log 40 08-OCT-11 +DG1/brij/1_5_761792516.dbf
Archive Log 41 15-OCT-11 +DG1/brij/1_6_761792516.dbf
Archive Log 42 16-OCT-11 +DG1/brij/2_4_761792516.dbf
Archive Log 43 16-OCT-11 +DG1/brij/1_7_761792516.dbf
backup piece handle=+RECOVERYDEST/brij/backupset/2011_11_05/ncsnf0_tag20111105t192958_0.272.766438281 recid=9 stamp=766438280
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 31 14-SEP-11 +DG1/brij/1_4_757308535.dbf
Archive Log 32 14-SEP-11 +DG1/brij/1_5_757308535.dbf
Archive Log 33 28-SEP-11 +DG1/brij/1_1_761792516.dbf
Archive Log 34 06-OCT-11 +DG1/brij/2_1_761792516.dbf
Archive Log 35 06-OCT-11 +DG1/brij/1_2_761792516.dbf
Archive Log 36 06-OCT-11 +DG1/brij/1_3_761792516.dbf
Archive Log 37 06-OCT-11 +DG1/brij/2_2_761792516.dbf
Archive Log 38 07-OCT-11 +DG1/brij/1_4_761792516.dbf
Archive Log 39 08-OCT-11 +DG1/brij/2_3_761792516.dbf
Archive Log 40 08-OCT-11 +DG1/brij/1_5_761792516.dbf
Archive Log 41 15-OCT-11 +DG1/brij/1_6_761792516.dbf
Archive Log 42 16-OCT-11 +DG1/brij/2_4_761792516.dbf
Archive Log 43 16-OCT-11 +DG1/brij/1_7_761792516.dbf
Archive Log 44 25-OCT-11 +DG1/brij/1_8_761792516.dbf
.
.
backup piece handle=+RECOVERYDEST/brij/backupset/2011_11_05/ncsnf0_tag20111105t192958_0.272.766438281 recid=9 stamp=766438280
Deleted 29 objects
8) Configuring Compressed Backupsets
=========================
To save space on the disk you can store backup in compressed format.
For example :
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1
starting full resync of recovery catalog
full resync complete