Tuesday, October 3, 2017

Configuring Oracle Database 11g R2 to use Recovery Catalog

1. Creating a Tablespace that will hold Recovery Catalog Meta Data, rman stored scripts and other information.

SQL> create tablespace catalogtbs
  2  datafile '/home/oracle/Desktop/recovery/catalog.dbf'     
  3  size 200M;
Tablespace created.

2. Creating a User who will be the owner of the recovery catalog.

SQL> create user rcuser identified by rcuser
  2  temporary tablespace temp
  3  default tablespace catalogtbs
  4  quota unlimited on catalogtbs;
User created.

3. Grant the the recovery_catalog_owner to the created user grants full ownership of the recovery catalog

SQL> grant recovery_catalog_owner to rcuser;
Grant succeeded.

4. Connecting to the Recovery catalog  schema and creating a new recovery catalog for our databases

 [oracle@pc1 ~]$ rman catalog rcuser/rcuser@orcl;
RMAN> create catalog;
recovery catalog created

5. Connecting to the target database and also connecting to the recovery catalog at the same time and register the database with the recovery catalog to resync with the database control file.

[oracle@pc1 ~]$ rman target / catalog rcuser/rcuser@orcl;
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

 [oracle@pc1 ~]$ sqlplus rcuser/rcuser;
SQL> desc rc_stored_script
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 DB_KEY                                             NUMBER
 DB_NAME                                            VARCHAR2(8)
 SCRIPT_NAME                               NOT NULL VARCHAR2(100)
 SCRIPT_COMMENT                                     VARCHAR2(255)

6. Creating rman script and storing them to the recovery catalog.

RMAN> create script backup_db
2> {backup database plus archivelog;}  
created script backup_db

7. Running the stored RMAN script from the recovery catalog.

RMAN> run {execute script backup_db;};
executing script: backup_db
Viewing the content of the RMAN stored Scripts.
RMAN> print script backup_db;
printing stored script: backup_db
{backup database plus archivelog;}

8. How to edit the content of the stored rman scripts

RMAN> replace script backup_db
2> {backup database plus archivelog delete input;}
replaced script backup_db

9. How to View the rman Stored Scripts 

RMAN> list all script names;
List of Stored Scripts in Recovery Catalog
    Scripts of Target Database ORCL
       Script Name
       Description
       -----------------------------------------------------------------------
       backup_db