gototopgototop
User Rating: / 0
PoorBest 
Article Index
1. RMAN Repository
2. Types of Records in the Control File
3. Recovery Catalog
4. Managing RMAN Repository

RMAN maintain metadata in repository about target database, its backup and recovery operations. For example (own configuration setting, target database schema, archived redo logs and backup files on disk or tap).

1. RMAN Repository

  • RMAN maintain metadata about target DB, it backup and recovery operations. For example (own configuration setting, target DB schema, archived redo logs and backup files on disk or tap.
  • Primary storage is control file of the target DB.
  • Another copy of RMAN repository can also saved in recovery catalog.
  • LIST, REPORT, SHOW displays repository information.
  • CONTROL_FILE_RECORD_KEEP_TIME parameter specifies in days after how record will be reused for new records in a control file. Default is 7 days.

    - If you back up the whole database once a week, then you need to set value at least 7 days
    - If the file is eligible for deletion then database attempts to delete file from flash recovery area. Otherwise, the database expands the size of the control file, logging the expansion in the alert log with a message like this example:

    kccwnc: trying to expand control file section nnnn for Oracle Managed Files - If the control file is at the maximum size supported under the host operating system, then the database cannot expand the control file. This warning appears in the alert log

    WARNING: Oracle Managed File filename is unknown to control file.

Recovery Without a Recovery catalog :  Oracle recommends that you:

  • Enable control file autobackup feature
  • Keep a record of your DBID
  • Use a minimum of two multiplexed or mirrored control files on separate disks
  • Keep all Recovery Manager backup logs.

2. Types of Records in the Control File

Circular Reuse Records:
Contain noncritical information that is eligible to be overwritten. The CONTROL_FILE_RECORD_KEEP_TIME initialization parameter specifies the minimum age in days of a record before it can be reused.

 

Noncircular Reuse Records: 
Contain critical information that can not be overwritten such as (datafiles, online redo logs, and redo threads)

3. Recovery Catalog

  • Preserve RMAN repository information if control file is lost.
  • Can store much more history of backup then control file.
  • Can also hold RMAN stored scripts and sequence of RMAN commands for common backup tasks.
  • Except of stored scripts all features works well in both options.
  • Can hold data for one or more databases in a separate DB schema.
  • The tablespace that holds the repository database requires at least 125MB to hold recovery catalog entries; Starting out with available free space of 125MB will in most cases be sufficient for the first year, and enabling additional extents of 50MB each will be sufficient in the long term depending on how many databases you manage in the recovery catalog.

Contents of the Recovery Catalog :

The recovery catalog contains information about RMAN operations, including:

  • Datafile and archived redo log backup sets and backup pieces
  • Datafile copies
  • Archived redo logs and their copies
  • Tablespaces and datafiles on the target database
  • Stored scripts, which are named user-created sequences of RMAN commands
  • Persistent RMAN configuration settings

Operations of Recovery Catalog

Create recovery catalog  [ CREATE CATALOG ]:

  • SYS can not be the owner of catalog.
  • Don’t use target DB for recovery catalog. Must be protected.
  • ARCHIVE log mode is recommended for catalog.
  • Ensure catalog and target DB do not reside on same disk.
  • Assign separate table-space for recovery catalog schema.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CONNECT SYS/DEV@DEVDB AS SYSDBA
 
-- [1] Create user for recovery catalog ]-----------------
CREATE TABLESPACE "TOOLS"
DATAFILE 'D:\ORACLE_DATA_FILES\ORADATA\DEVDB\TOOLS'
SIZE 100M AUTOEXTEND ON NEXT 10M;
 
CREATE USER "RMAN" IDENTIFIED BY CAT
DEFAULT TABLESPACE "TOOLS"
QUOTA UNLIMITED ON "TOOLS";
 
GRANT "CONNECT" TO "RMAN";
 
 
-- [2] Create recovery catalog owner ]-----------------
GRANT "RECOVERY_CATALOG_OWNER" TO "RMAN";
 
 
-- [3] Create recovery catalog ]-----------------
RMAN > (enter RMAN at OS command prompt OR at Run)
RMAN > CONNECT CATALOG RMAN/CAT@DEVDB
RMAN > CREATE CATALOG;

Register DB in Recovery catalog [ REGISTER DATABASE / CATALOG ]:

  • Registering database copies all repository data about target DB control file to recovery catalog.
  • Multiple targets can be catalog.
  • RMAN uses DBID to distinguish one DB from another.
1
2
3
4
5
6
RMAN> CONNECT TARGET SYS/SRDC@TEST1       -- connect with target database
RMAN> CONNECT CATALOG RMAN/CAT@DEVDB -- connect with recovery catalog
 
RMAN> STARTUP MOUNT; -- if target DB not mounted mount it
RMAN> REGISTER DATABASE; -- Register database
RMAN> REPORT SCHEMA; -- to verify that registration was successful
  • Older file (data-file copies back-up piece, archive-log) can also be cataloged.
  • Only oracle 8 and higher files can be cataloged.
  • Oracle 7 files can also be cataloged but must be consistent.
1
2
3
4
5
RMAN> CATALOG DATAFILE 'C:\OLDBACKUP\USER01.DBF';   -Single DATA file  
RMAN> CATALOG ARCHIVELOG 'C:\OLDBACKUP\USER02.DBF';-Single archivelog file
RMAN> CATALOG BACKUPPIECE 'C:\OLDBACKUP\USER01.BKP';-Single backup peice file
RMAN> CATALOG START WITH 'C:\OLDBACKUP\'; -Multiple backup files
-specify only Directory name

Un-Register target database [ UNREGISTER DATABASE / DELETE ]:

  • When database is un-registered from the catalog all records in recovery catalog are lost.
  • Can be registering again based on the contents of the control files at the time registration.
  • It is not necessary to connect the target database, but if you do not use        SET DBID
1
2
3
4
5
RMAN> CONNECT TARGET SYS/SRDC@TEST1       -- connect with target database
RMAN> CONNECT CATALOG RMAN/CAT@DEVDB -- connect with recovery catalog
RMAN> UNREGISTER DATABASE;
 
 
  • If you want to delete all backups of the database. These following commands will delete file physically and removes entries from catalog.
1
2
3
RMAN> DELETE BACKUP DEVICE TYPE sbt;   --Delete all backups from tap drive
RMAN> DELETE BACKUP DEVICE TYPE DISK; --Delete all backups from disk drive
RMAN> DELETE COPY;

Resetting DB Incarnation in the recovery catalog

  • The SQL statement ALTE DATABASE OPEN RESTLOGS create new incarnation of the DB.
  • Records of new incarnation can be access using V$DATABASE_INCARNATION view
  • When you issue command ALTE DATABASE OPEN RESTLOGS incarnation record automatically created in catalog.
  • And DB issue RESET DATABASE command automatically.
  • All subsequent backups and log archiving done by the target DB associated with the new DB incarnation.
  • You may need to change the current incarnation for some recovery tasks.
1
2
RMAN> LIST INCARNATION OF DATABASE TEST1;-- Obtain incarnation key (Inc Key)
RMAN> RESET DATABASE TO INCARNATION 2; -- Reset database to old incarnation

Removing DELETED records form catalog after Upgrade; [ PRGRMANC.SQL ]:

  • In oracle 9i and later RMAN always removes catalog records on deleting files.
  • In releases prior to oracle 9i RMAN show status DELETED after deleting the physical files.
  • If you upgrade repository prior to oracle 9i then you need to set DELETED status. By using a SQL scripts
  • This script removes all records with the status DELETED.
1
2
SQL> CONNECT RMAN/CAT@DEVDB              -- Connect to recovery catalog
SQL> @C:\ORACLE\PRODUCT\10.2.0\CLIENT_1\RDBMS\ADMIN\PRGRMANC.SQL --Run script

Resynchronize the Recovery Catalog; [ RESYNC CATALOG ]:

  • When RMAN performs a resynchronization it compares recovery catalog to control file with information that is missing or changed.
  • RMAN perform resynchronization automatically as needed. But resynchronization can also do manually.
  • In partial resynchronization RMAN reads current control file to update change information (new backups, new archive log) and does not resynchronize metadata (physical schema, data-file, table-spaces, redo-threads, rollback-segments).
  • In full resynchronization RMAN updates all changed records.
  • Resynchronize after physical database change.
  • If you maintain recovery catalog the use RESYNC CATALOG often enough before they are reused.
  • If set CONTROL_FILE_RECORD_KEEP_TIME = 7 days you muse resynchronize before 7 days
1
2
3
4
RMAN> CONNECT TARGET SYS/SRDC@TEST1       -- connect with target database
RMAN> CONNECT CATALOG RMAN/CAT@DEVDB -- connect with recovery catalog
 
RMAN> RESYNC CATALOG;

Backing up and recovering the recovering catalog:

If you do not backup the recovery catalog and a disk failure occurs and destroy recovery catalog then it will be very difficult to recovery the database. There are three possible ways to recover the recovery catalog.

  1. Enable Archive log mode and take backups like any other DB and recover the recovery catalog in case of failure.
  2. Use export and import utility to recreate or move catalog.
  1. Re-Create Recovery Catalog from existing backups
  • Create new catalog in the new database.
  • Register target database.
  • Use RESYNC CATALOG command.
  • Issue CATLOG START WITH …. Commands to re-catalog any backups

Backup the recovery catalog as the same frequency as you backup.

4. Managing RMAN Repository

RMAN repository metadata is always stored in the control file of the target database. You can also create a recovery catalog in a separate database, and RMAN will record its metadata there as well.

Monitoring Control File Records

If you do not use a recovery catalog, then eventually RMAN control file records are overwritten. Set this initialization parameter in the parameter file of the target database to determine how long records are kept:

1
CONTROL_FILE_RECORD_KEEP_TIME = number_of_days_to_keep

Crosschecking Backups

The CROSSCHECK command checks whether RMAN backups and copies in the repository are still readable by RMAN. Assuming that you have configured automatic channels, you can run these commands:

1
2
RMAN> CROSSCHECK BACKUP; # checks RMAN backups on configured devices
RMAN> CROSSCHECK COPY; # checks RMAN image copies on configured devices

If backups are stored with a media manager and sbt channels are not configured, then you must allocate a maintenance channel before CROSSCHECK and DELETE commands on sbt devices:

1
2
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
RMAN> CROSSCHECK BACKUP;

Deleting Backups Created with RMAN

The DELETE command removes RMAN backups and copies from DISK and sbt devices, marks the objects as DELETED in the control file, and removes the records from the recovery catalog (if you use a catalog). For example:

1
2
3
4
5
6
RMAN> DELETE BACKUPSET 101, 102, 103;
RMAN> DELETE CONTROLFILECOPY '/tmp/cf.cpy';
RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 7300;
RMAN> DELETE BACKUP OF SPFILE TABLESPACE users DEVICE TYPE sbt;
RMAN> DELETE BACKUP OF DATABASE LIKE '/tmp%'; # pattern match
RMAN> DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;

The following options of the DELETE command are also useful:


Parameter

Example

Explanation

EXPIRED

DELETE EXPIRED

Deletes the backups and copies marked as EXPIRED (that is, "not found") by the CROSSCHECK command.

OBSOLETE

DELETE OBSOLETE

Deletes the backups and copies that are obsolete under the retention policy. REDUNDANCY and RECOVERY WINDOW parameters override the configured policy.

NOPROMPT

DELETE NOPROMPT OBSOLETE

Specifies that you do not want to be prompted to confirm the files to be deleted.

 

Cataloging and Uncataloging Backups and Copies

The CATALOG command adds information about useable backups to the RMAN repository. Use this command to record backups created with tools other than RMAN, such as datafile copies created with operating system-level utilities. You can also use this command if you have backups which are created using RMAN but which are no longer listed in the RMAN repository. RMAN can use these backups in restore and recovery operations. For example:

1
2
3
## copy made with operating system copy cmd
RMAN> CATALOG DATAFILECOPY '/backup/users01.bak';
RMAN> CATALOG LIKE '/backup'

Note: that the second example adds all usable backups where the filepath begins with /backup to the RMAN repository, including files in the directory /backup/users01.bak, files in subdirectories such as /backup/tuesday/users01.bak.old, and files in directories whose name starts with /backup, such as /backup-2001/users01.bak.old. Take care when choosing your argument for CATALOG LIKE.

The CHANGE ... UNCATALOG syntax lets you remove information about backups and copies from the RMAN repository. If you manually delete a backup using operating system commands, CHANGE...UNCATALOG updates the repository to reflect that change. For example:

RMAN> CHANGE CONTROLFILECOPY '/tmp/cf.cpy' UNCATALOG;
RMAN> CHANGE BACKUPSET 121,122,127,203,300 UNCATALOG;

 

Related Articals:

  1. Introduction to RMAN [Part-1]
  2. Backup and recovery operations using RMAN (Part-2)
  3. Using RMAN Repository (Part-3)


Last Updated (Tuesday, 24 November 2009 11:57)