How to Register an Oracle Database with RMAN Catalog
How to Register an Oracle Database with RMAN Catalog
Purpose
The RMAN register database command adds a target database to the recovery catalog so that Recovery Manager can track and maintain backup metadata. This allows RMAN to store backup information, recovery points, and database structure details in a central repository instead of relying only on the control file.
Prerequisites
Before registering a database with RMAN catalog, the target database must have a password file created. The password file enables remote authentication for SYSDBA or SYSBACKUP privileges, which RMAN requires to connect and manage backups. You can create a password file with the orapwd utility. On Oracle 19c, the documented example is
orapwd FILE=$ORACLE_HOME/dbs/orapw<SID> FORMAT=12.2
(12.2 is the default format). On Oracle 11.2, the syntax is orapwd FILE=orapw<SID> ENTRIES=<number>, and the command prompts for the SYS password.
The recovery catalog itself must exist before you can register a database in it. The catalog lives in the schema of an ordinary user, because privileged users such as SYS cannot own a recovery catalog. On Oracle 19c, create the owner with a quota on its default tablespace, then grant it the RECOVERY_CATALOG_OWNER role. That role gives the owner the privileges it needs to maintain and query the catalog. The 19c procedure also runs the dbmsrmansys.sql script, which grants extra privileges to that role. Since Oracle Database 12.1.0.2, the catalog database must run Enterprise Edition.
1CREATE USER rco IDENTIFIED BY password
2 TEMPORARY TABLESPACE temp
3 DEFAULT TABLESPACE tools
4 QUOTA UNLIMITED ON tools;
5
6GRANT RECOVERY_CATALOG_OWNER TO rco;
Next, connect RMAN to the catalog database as that owner and create the catalog tables. CREATE CATALOG builds them in the owner's default tablespace, or in a tablespace you name with the TABLESPACE clause.
1rman catalog rco@catdb
2
3create catalog;
Each target must also have a DBID that is unique inside the catalog. Two databases may share a name if their DBIDs differ.
Code Breakdown
Original Code
1rman catalog user/pass@rmandb target user/pass@db
2
3register database;
Command Explanation
Connection String: rman catalog user/pass@rmandb target user/pass@db
catalog user/pass@rmandbconnects RMAN to the recovery catalog database where backup metadata is storedtarget user/pass@dbconnects to the database you want to register and backup- Both connections must be established before running the register command
Register Command: register database;
- This command creates entries in the catalog tables for the target database
- RMAN copies all relevant information from the target database control file into the recovery catalog
- The database must be mounted or open when running this command
- The target database cannot already be registered in the recovery catalog
Expected Output:
1database registered in recovery catalog
2starting full resync of recovery catalog
3full resync complete
The first line confirms the registration. The next two lines show RMAN copying the control file metadata into the catalog in a full resync. If the target is shut down, run STARTUP MOUNT at the RMAN prompt first, then run REGISTER DATABASE.
Key Points
- The recovery catalog database and target database run on separate instances
- RMAN must be connected to both the catalog and target database simultaneously before registration
- After registration, RMAN performs a full resynchronization using the control file information
- You can verify successful registration by running
REPORT SCHEMAcommand - The target database must not be currently registered in the recovery catalog to avoid RMAN-20002 error
Best Practices
The RMAN client can run on any host that reaches the target through Oracle Net, but disk backups are always written in the target database instance's file system, so paths in FORMAT clauses refer to that server. Use the SYSBACKUP privilege instead of SYSDBA for backup operations when possible, which requires password file format 12 or later. You can verify your password file format using orapwd describe file=<filename>.
To keep passwords out of scripts, consider using Oracle External Password Store with wallet configuration to avoid storing passwords in scripts. Create a dedicated backup user with SYSBACKUP privilege instead of using the SYS account.
Keep Control File Records Long Enough
The database stores records of redo log switches and archived redo logs only in the control file. Most RMAN commands resync the catalog automatically when the target control file is mounted and the catalog is available. If backups run without a catalog connection for some time, those records exist only in the control file. The CONTROL_FILE_RECORD_KEEP_TIME parameter sets the minimum number of days a control file record is kept before it can be overwritten. Set it longer than the gap between backups or resyncs; an extra week is a safe margin. Never set it to 0, because backup records can then be overwritten before RMAN adds them to the catalog. To force a full resync, connect to the target and the catalog and run RESYNC CATALOG;.
Catalog Older Backups
A newly registered database brings only the history its control file still holds. If older data file copies, backup pieces, or archived logs are still on disk, add them with the CATALOG command, for example CATALOG START WITH '/disk1/backups/';. RMAN lists the files it will add and asks for confirmation. RMAN can then use those older backups during a restore, even after they have aged out of the control file. Do not run CATALOG and BACKUP at the same time against the same disk location.
After Registration
Once the database is registered, RMAN maintains synchronization between the control file and recovery catalog. You can manage backups, perform recovery operations, and generate reports using the catalog metadata. To unregister a database, connect RMAN to the target and the catalog and run UNREGISTER DATABASE;. If the target no longer exists, connect to the catalog only, run SET DBID <dbid>;, and then run UNREGISTER DATABASE;.
Checking the Registration with SQL
REPORT SCHEMA shows that RMAN can read the catalog. To see the catalog rows directly, query the RC_ views. Start on the target and note its identity in V$DATABASE:
1SELECT dbid, name, db_unique_name, database_role, open_mode, controlfile_type
2FROM v$database;
DBID is calculated when the database is created and is stored in all file headers. It is the value the catalog uses to tell databases apart. DATABASE_ROLE shows PRIMARY or a standby type. OPEN_MODE shows MOUNTED, READ WRITE, or READ ONLY. CONTROLFILE_TYPE reads CURRENT when the database is available for general use. BACKUP, CREATED, or CLONE means a restored, re-created, or cloned control file, so confirm which database you are about to register.
Then connect to the catalog database as the catalog owner and list the registered databases:
1SELECT db_key, dbinc_key, dbid, name, resetlogs_change#, resetlogs_time
2FROM rc_database
3ORDER BY name;
RC_DATABASE has one row for each registered database and corresponds to V$DATABASE on the target. DB_KEY is the primary key, and you use it to join to almost every other catalog view. DBINC_KEY points to the current incarnation. NAME is the DB_NAME of the current incarnation. RESETLOGS_CHANGE# and RESETLOGS_TIME mark the RESETLOGS that started that incarnation. Match the DBID here to the DBID from V$DATABASE.
To see the incarnation history for one database, query RC_DATABASE_INCARNATION:
1SELECT dbinc_key, parent_dbinc_key, name, resetlogs_change#, resetlogs_time,
2 current_incarnation, status, con_id
3FROM rc_database_incarnation
4WHERE dbid = &dbid
5ORDER BY resetlogs_change#;
STATUS is CURRENT for the live incarnation, PARENT for a direct ancestor of it, and ORPHAN for an incarnation that is not on the current path. PARENT_DBINC_KEY is NULL for the first incarnation recorded. CON_ID is 0 for a non-CDB and 1 for a CDB. If the database went through a RESETLOGS before you registered it, the older incarnations show NAME as UNKNOWN. This is expected, and you should not try to remove those records.
Data Guard Databases
In a Data Guard configuration, the primary and its standby databases share one DBID and one database name. Each database needs its own DB_UNIQUE_NAME to be eligible for the catalog. Register the primary with REGISTER DATABASE while connected to it as TARGET. RMAN then runs a full resync from the primary control file.
Once the primary is registered, RMAN registers a new standby automatically in two cases: when RMAN connects to an instance whose DB_UNIQUE_NAME the catalog does not know, or when you run CONFIGURE DB_UNIQUE_NAME for a database the catalog does not know. In Oracle 19c you can also connect to a physical standby as TARGET and run REGISTER DATABASE to register it explicitly. RMAN then runs a full resync from the standby control file, so the resync does not need a connection to the primary.
To list the sites the catalog holds, query RC_SITE:
1SELECT db_key, site_key, db_unique_name, database_role, cf_create_time
2FROM rc_site
3ORDER BY db_key, db_unique_name;
Each row is one DB_UNIQUE_NAME. DATABASE_ROLE is the Data Guard role, and CF_CREATE_TIME is the creation date of that database's control file. SITE_KEY joins to the RC_SITE column of other catalog views, which tells you which site took a given backup. To remove one standby from the catalog, run UNREGISTER DB_UNIQUE_NAME <name>;.
When to Run This
- Once for each database, right after you create the catalog with
CREATE CATALOG - When you want backup history kept longer than
CONTROL_FILE_RECORD_KEEP_TIMEallows in the control file - When you want RMAN stored scripts, which are kept in the catalog and not in the control file
- After you copy a database by file copy and give the copy a new DBID with the DBNEWID utility
- For a physical standby on Oracle 19c, when you want it registered and resynced without connecting to the primary
Troubleshooting Common Issues
RMAN-20002 on a database you thought was new: Query V$DATABASE on the target for its DBID, then search RC_DATABASE for that DBID. If the row is there and it is the same database, it is already registered and nothing more is needed. If the target is a copy made by copying files instead of with DUPLICATE, it keeps the source DBID, and REGISTER DATABASE fails on the duplicate. Change the copy's DBID with the DBNEWID utility, then run REGISTER DATABASE again.
Same name and DBID in different catalogs: If you run RMAN against different target databases that share a name and DBID, always give the correct catalog schema when you start RMAN.
Unregister and re-register as a fix: Avoid it. Unregistering deletes every RMAN repository record for that database in the catalog. A new registration holds only what the control file contains at that moment. Records older than the control file keep time are lost, and so are stored scripts.
References
- REGISTER DATABASE - Oracle Help Center (19c) - Official Oracle documentation for the REGISTER DATABASE command, including syntax and prerequisites
- REGISTER DATABASE - Oracle Help Center (21c) - Updated Oracle 21c documentation for database registration with RMAN
- Registering/Unregistering Database with RMAN Catalog - Practical guide with examples for registering and unregistering databases
- Configure RMAN Recovery Catalog - DBA Genesis Support - Step-by-step tutorial for setting up RMAN recovery catalog from scratch
- Starting and Interacting with the RMAN Client - Oracle Help Center - Authentication methods and connection requirements for RMAN
- Creating and Maintaining a Password File - Oracle Documentation - Oracle 11.2 guide to creating password files with the orapwd utility
- orapwd tool for password file in oracle - dbaclass - Tutorial on password file creation with syntax examples
- Script your RMAN backups using Oracle External Password Store - Wallet configuration for RMAN authentication
- Managing a Recovery Catalog - Oracle Help Center (19c) - Catalog owner setup, CREATE CATALOG, registration, Data Guard rules, resync, CONTROL_FILE_RECORD_KEEP_TIME, and unregistering
- RC_DATABASE - Oracle Help Center (19c) - Column reference for the catalog view that lists registered databases
- RC_DATABASE_INCARNATION - Oracle Help Center (19c) - Column reference for incarnation history, including STATUS and the UNKNOWN name case
- RC_SITE - Oracle Help Center (19c) - Column reference for Data Guard sites known to the catalog
- V$DATABASE - Oracle Help Center (19c) - DBID, DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE, and CONTROLFILE_TYPE definitions on the target
Posts in this series
- How to Create Oracle RMAN Recovery Catalog Step by Step
- How to Register an Oracle Database with RMAN Catalog
- Oracle RMAN Unregister Database from Recovery Catalog
- Oracle RMAN Reset Database After RESETLOGS Recovery
- Oracle RMAN CROSSCHECK BACKUP Command Explained
- Oracle RMAN Resync Catalog Command Guide
- Oracle RMAN: Delete Backup Pieces with Manual Channel
- Oracle RMAN Database Backup Commands Guide
- Oracle RMAN Database Restore and Recovery Guide
- Delete Archive Log Older Than 5 Days in Oracle RMAN
- Oracle RMAN Crosscheck Archivelog - Fix RMAN-06059 Error
- Oracle RMAN List Backupset Command Guide
- Oracle RMAN List Backup of Database Command
- List Backup of Archivelog All: Oracle RMAN Command Guide
- Oracle RMAN Report Obsolete Command Guide
- Oracle RMAN Report Obsolete Redundancy Command Guide
- Oracle RMAN Delete Obsolete - Remove Unneeded Backups
- Oracle RMAN RESTORE DATABASE VALIDATE Backup Check
- Oracle RMAN REPORT SCHEMA Command: Display Database Files
- Oracle RMAN Delete Expired Backup: Repository Cleanup
- LIST BACKUPSET OF DATABASE: Oracle RMAN Command Guide
- Oracle RMAN Delete Obsolete Backups with Maintenance Channel
- Find Oracle Archive Logs Older Than N Days with find -mtime
- Audit RMAN Backup Job History with V$RMAN_BACKUP_JOB_DETAILS