How to Configure Recovery Catalog

Configure Recovery Catalog

In this article, we will learn how to configure the recovery catalog on the Linux environment step by step.

What is Recovery Catalog?

The recovery catalog is a separate database, and totally different from your production environment. Catalog database only stores your backup information in terms of backup metadata. The recovery catalog database could be on same server or on another server.

Why do we need Recovery Catalog?

Whenever you performed the database backup using the RMAN utility, the RMAN store the information in the controlfile. The controlfile has a default 7 days retention policy. That means you have only 7 days old backup information.

Suppose you want the 7 days old backup information then the recovery catalog will help you. The One recovery catalog database can store multiple database backup information.

Recovery Catalog Benefits

We have multiple benefits of the recovery catalog like:

  • If you lose the controlfile, it helps to database recovery.
  • You can write the backup script in the recovery catalog and save it.
  • Store very long-time backup information.
  • Use for backup reporting also.
  • You can store the RMAN backup script also.
  • Cloning with PITR (Point in time recovery) becomes easier as the recovery catalog knows which Control file is required.

Start Recovery catalog configuration

In this practice, we are going to configure the recovery catalog in a separate database on the same machine. You can use a separate machine for the recovery catalog also.

We have created a database with the name "RCAT".

SQL> def
DEFINE _DATE           = "02-JUN-22" (CHAR)
DEFINE _CONNECT_IDENTIFIER = "rcat" (CHAR)
DEFINE _USER           = "SYS" (CHAR)
DEFINE _PRIVILEGE      = "AS SYSDBA" (CHAR)
DEFINE _SQLPLUS_RELEASE = "1202000100" (CHAR)
DEFINE _EDITOR         = "vi" (CHAR)
DEFINE _O_VERSION      = "Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production"                (CHAR)
DEFINE _O_RELEASE      = "1202000100" (CHAR)

Datafile information:

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/rcat/system01.dbf
/u01/app/oracle/oradata/rcat/sysaux01.dbf
/u01/app/oracle/oradata/rcat/undotbs01.dbf
/u01/app/oracle/oradata/rcat/users01.dbf

Step 1: Create a dedicated tablespace.

Create a separate tablespace to store backup information.

SQL> create tablespace rmantab
  2  datafile '/u01/app/oracle/oradata/rcat/rmantab01.dbf' size 100m;

Tablespace created.

Step 2: Create a dedicated User

Here we have created a separate database schema name "RMANCAT" and assigned the newly created tablespace to the user.

SQL> create user rmancat
  2  identified by rmancat
  3  default tablespace rmantab
  4  quota unlimited on rmantab
  5   temporary tablespace temp;

User created.

Step 3: Grant permissions

Grant catalog permissions to the user "RMANCAT". The recovery_catalog_owner role gives the following system privileges to the recovery catalog owner: alter session, create cluster, create database link, create procedure, create sequence, create session, create synonym, create table, create trigger, create type and create view.

SQL> grant connect,resource,recovery_catalog_owner to rmancat;

Grant succeeded.

Register your database with the listener, this optional step.

SQL> alter system register;

System altered.

Step 4: Configure the TNS entry

Both databases must be tns ping to each other. In our case have the below tnsname.ora file location and configuration.

/u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora

DIGITAL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = digital)
    )
  )

LISTENER_DIGITAL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


LISTENER_RCAT =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


RCAT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = rcat)
    )
  )

The listener must be started

[oracle@12cPatching ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 02-JUN-2022 12:36:27

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                02-JUN-2022 12:11:22
Uptime                    0 days 0 hr. 25 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/12cPatching/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=12cPatching.shripal.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/digital/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "digital" has 1 instance(s).
  Instance "digital", status READY, has 1 handler(s) for this service...
Service "digitalXDB" has 1 instance(s).
  Instance "digital", status READY, has 1 handler(s) for this service...
Service "rcat" has 1 instance(s).
  Instance "rcat", status READY, has 1 handler(s) for this service...
Service "rcatXDB" has 1 instance(s).
  Instance "rcat", status READY, has 1 handler(s) for this service...
The command completed successfully

Steps in the Production Environment

Step 5: Connect with the rman catalog

This is our production environment here we just connect with the catalog using the details of the recovery catalog database and create the catalog. We will not create the catalog on the catalog database.

The Create catalog command will create the required table and views in the catalog database which is required to store the database information.

[oracle@12cPatching ~]$ rman catalog rmancat/rmancat@rcat

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Jun 2 12:38:14 2022

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to recovery catalog database

RMAN> create catalog;

recovery catalog created

RMAN> exit

Exit from the rman prompt then connects again with both databases to register the database.

[oracle@12cPatching ~]$ rman target/ catalog rmancat/rmancat@rcat

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Jun 2 12:39:42 2022

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DIGITAL (DBID=768507691)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

In the above message, you see clearly the database resync started.

Connect with the catalog database and check how many tables are created in this catalog environment.

SQL> conn rmancat
Enter password:
Connected.
SQL>
SQL>
SQL> select count(*) from tab;

  COUNT(*)
----------
       158

Resync Recovery Catalog

When RMAN performs the resync, it will compare the recovery catalog either the current controlfile or backup/standby controlfile then update the recovery catalog database with that information that is missing or changed.

Resync types

There are two types of resync methods:

  1. Partial Resynchronization: Rman compare the current controlfile with the recovery catalog and update the information in the catalog database, concerning backup, archive redo logs, and datafile copies.
  2. Full Resynchronization: RMAN first creates a controlfile snapshot which is a temporary copy of the current controlfile and rman use it to compare with the recovery catalog and update the updated information also including any database structure changed. For example, DB schema changes or new tablespace are included.

Take a Backup

Take a backup without a catalog and then verify the details in the catalog using the below steps.

[oracle@12cPatching ~]$ rman target / nocatalog

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Jun 6 05:56:22 2022

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DIGITAL (DBID=768507691)
using target database control file instead of recovery catalog

RMAN> backup spfile;

Starting backup at 06-JUN-22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=66 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 06-JUN-22
channel ORA_DISK_1: finished piece 1 at 06-JUN-22
piece handle=/u02/fast_recovery_area/DIGITAL/backupset/2022_06_06/o1_mf_nnsnf_TAG20220606T055706_k9vmvmlf_.bkp tag=TAG20220606T055706 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 06-JUN-22

Starting Control File and SPFILE Autobackup at 06-JUN-22
piece handle=/u02/fast_recovery_area/DIGITAL/autobackup/2022_06_06/o1_mf_s_1106632628_k9vmvny8_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 06-JUN-22

Verify Details in Catalog Database

Connect with the catalog database and verify the backup details in the catalog.

[oracle@12cPatching ~]$ sqlplus rmancat/rmancat@rcat

SQL*Plus: Release 12.2.0.1.0 Production on Mon Jun 6 05:58:37 2022

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Sat Jun 04 2022 11:19:38 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
SQL>
SQL> select count(*) from rc_backup_spfile;


  COUNT(*)
----------
         3

It is showing 3 counts in the spfile backup table which is old value, let me sync it and check the backup details after that.

[oracle@12cPatching ~]$ rman target / catalog rmancat/rmancat@rcat


Recovery Manager: Release 12.2.0.1.0 - Production on Mon Jun 6 06:01:54 2022

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DIGITAL (DBID=768507691)
connected to recovery catalog database

RMAN> resync catalog;

starting full resync of recovery catalog
full resync complete

Connect with the catalog and check it again.

SQL> select count(*) from rc_backup_spfile;


  COUNT(*)
----------
         5

How to unregister the database from the catalog

If you think the rman catalog is no longer required then you can unregister the database. As we know the rman metadata is always stored in the local controlfile.

[oracle@12cPatching ~]$ rman target / catalog rcatalog/rcatalog@rcat

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Jun 6 06:01:54 2022

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DIGITAL (DBID=768507691)
connected to recovery catalog database


RMAN> UNREGISTER DATABASE;

database name is "DIGITAL" and DBID is 768507691

Do you really want to unregister the database (enter YES or NO)? YES
database unregistered from the recovery catalog

Connect with Catalog Database

Make a connection with the catalog database and verify the details. This time you can't see and records inside the database.

[oracle@12cPatching ~]$ sqlplus rcatalog/rcatalog@rcat

SQL*Plus: Release 12.2.0.1.0 Production on Mon Jun 6 05:58:37 2022

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Sat Jun 04 2022 11:19:38 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select count(*) from rc_backup_spfile;


  COUNT(*)
----------
         0


SQL> select NAME from rc_database;

no rows selected

Drop Catalog

Rman catalog can be removed through the drop catalog command, follow the below steps.

[oracle@12cPatching ~]$ rman catalog rcatalog/rcatalog@rcat

Recovery Manager: Release 12.2.0.1.0 - Production on Mon Jun 6 06:25:31 2022

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to recovery catalog database

RMAN> DROP CATALOG;

recovery catalog owner is RCATALOG
enter DROP CATALOG command again to confirm catalog removal

RMAN>

RMAN>

RMAN> DROP CATALOG;

recovery catalog dropped

Connect with catalog database

Connect with catalog database and check tables. This time you can see the table name starts "BIN" which means all tables dropped but exists in recycle bin.

SQL> select * from tab;

TNAME                                         TABTYPE  CLUSTERID
--------------------------------------------- ------- ----------
BIN$4MXmPHD3USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHDpUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHDxUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHEDUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHESUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHEiUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHEtUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHF8USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHFHUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHFMUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHFYUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHFfUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHFnUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHFtUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHGNUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHGwUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHH1USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHHCUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHHbUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHI2USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHIRUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHJZUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHJtUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHKGUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHKQUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHKZUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHKhUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHKoUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHL7USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHLPUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHLSUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHLfUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHM8USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMIUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMNUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMcUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMhUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMlUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMqUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHMxUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHN3USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHN5USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHNGUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHNWUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHNmUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHNrUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHNyUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHO3USzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHOGUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHOVUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHOdUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHOkUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHOnUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHOyUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHPDUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHPIUSzgUxIaAksCLQ==$0                TABLE
BIN$4MXmPHPVUSzgUxIaAksCLQ==$0                TABLE

57 rows selected.

Let me purge the recyclebin.

SQL> purge recyclebin;

Recyclebin purged.


SQL> select * from tab;

no rows selected

Useful Views for catalogs

rc_resync: Recovery catalog resynchronizations information.
rc_rman_configuration: RMAN configuration settings information.
rc_archived_log: Archived and non-archived redo logs (Corresponds to the v$archived_log view) historical information.
rc_backup_controlfile: control files backup sets information.
rc_backup_piece: Backup pieces information.
rc_backup_set: Database incarnation information.
rc_backup_spfile: Server parameter file information.
rc_controlfile_copy: Controlfile information.
rc_backup_corruption: Information of corrupted blocks in datafile backups. Corresponds to the v$backup_corruption view. 
rc_database_block_corruption: Information of corrupted data blocks after last backup.
rc_backup_datafile: Information of datafiles in backup sets.
rc_database: Information about all databases that registered in the recovery catalog.
rc_database_incarnation: Database incarnation information.
rc_datafile: Information of datafiles which registered in the recovery catalog.
rc_rman_status: Information about all operations on all databases made by connecting to the recovery catalog.
rc_stored_script and rc_stored_script_line: Both has the information of scripts that stored in the recovery catalog.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top