Monday, 28 December 2015

RMAN Catalog database


RECOVERY CATALOG:

A recovery catalog is an optional database schema consisting of tables and views, and RMAN uses it to store its repository data.


Controlfile to store the RMAN metadata. 
However the recovery catalog provides a large storage capacity, thus enabling access to a longer history of backups, and it is an ideal solution when dealing with a large number of databases.

We can create and store RMAN scripts in the recovery catalog. 
Recovery catalog based stored scripts aren't the same as operating system scripts that invoke RMAN or RMAN command scripts, which are available only if the RMAN client can access the filesystem.

NOTE: Even when you choose to use a recovery catalog, backup information will continue to be stored in the control file as well by default. 
The recovery catalog contains information about both RMAN backups and the target database.

* RMAN Configuration settings.
* RMAN stored scripts that you create.
* Target database tablespace and datafile information.
* Information pertaining to datafile and archived redo log backup sets and backup pieces, as well as datafile and archived redo log copies.

--------------------------------------------------------------

We must create it manually. Since the recovery catalog instance is a regular oracle database like any other, You must also regularly backup this critical database.

Some times you may have to export and import or restore and recover the recovery catalog.

Recovery Catalog Creation:

Below are some steps for Creating and Configuring Recovery Catalog for our Database which might be production,test or Development:

Step 1:Create a new database for RMAN – Recovery catalog database->'CATDB' Database created using dbca.

Note: We can create a small database with minimal sizes of tablespaces and others, and we can name the database as CATDB for naming convention and to avoid the confusion between our production and rman databases.

Step 2:Create a new tablespace in the new database (CATDB)

$ sqlplus /nolog

CONNECT SYS/welcome@catdb AS SYSDBA;

CREATE TABLESPACE rman
DATAFILE 'D:\rafi\catdb\rman\rman01.dbf' size 200m;


Step 3:Create the Recovery Catalog Owner in the new database (CATDB)

CREATE USER rman IDENTIFIED BY rman
DEFAULT TABLESPACE rman
QUOTA UNLIMITED ON rman;

Step 4:Grant the necessary privileges to the schema owner

SQL> GRANT recovery_catalog_owner TO rman;

Here the role "RECOVERY_CATALOG_OWNER" provides the user with all privileges required to maintain and query the recovery catalog.RECOVERY_CATALOG_OWNER role has the CREATE_SESSION privileges so need to grant separately.

Step 5:Creating the Recovery Catalog

Connect to the database which will contain the catalog as the catalog owner. 
For example:'rman' user is catalog owner in our example.

On Linux(UNIX):
------------------
Run the 'CREATE CATALOG' command to create the catalog

$ rman target / catalog rman/rman@catdb

RMAN> CREATE CATALOG;

recovery catalog created

On Windows:
--------------------

C:\Windows\system32>rman target / catalog rman/rman@catdb

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 21 00:44:02 2011

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

connected to recovery catalog database

RMAN> CREATE CATALOG;

recovery catalog created


Step 6:Registering a Database in the Recovery Catalog

Connect to the target database and recovery catalog database.

$ export ORACLE_SID=ORCL
$ rman target / catalog rman/rman@catdb

Recovery Manager: Release 11.2.0.1.0 - Production on Sun July 1 14:25:30 2007
Copyright (c) 1982, 2010, Oracle. All rights reserved.
connected to target database: ORCL (DBID=3677528376)
connected to recovery catalog database

windows:
-------------
C:\Windows\system32>set ORACLE_SID=ORCL

C:\Windows\system32> rman target / catalog rman/rman@catdb

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 21 01:03:19 2011

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

connected to target database: ORCL (DBID=1280115002)
connected to recovery catalog database

Step 7:Register and Verify after connection

RMAN> REGISTER DATABASE;

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

On Windows (OR) Linux Environment:
-------------------------------

RMAN> REGISTER DATABASE;

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

Register the target Database using 'REGISTER DATABASE' command as seen above.

Make sure that the registration is successful by running REPORT SCHEMA:

RMAN> REPORT SCHEMA;

Report of database schema

RMAN> REPORT SCHEMA;

Report of database schema for database with db_unique_name ORCL

List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 690 SYSTEM YES D:\APP\RAFIALVI\ORADATA\ORCL\SYSTEM01.DBF
2 570 SYSAUX NO D:\APP\RAFIALVI\ORADATA\ORCL\SYSAUX01.DBF
3 55 UNDOTBS1 YES D:\APP\RAFIALVI\ORADATA\ORCL\UNDOTBS01.DBF
4 6144 USERS NO D:\APP\RAFIALVI\ORADATA\ORCL\USERS01.DBF
5 100 EXAMPLE NO D:\APP\RAFIALVI\ORADATA\ORCL\EXAMPLE01.DBF

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 D:\APP\RAFIALVI\ORADATA\ORCL\TEMP01.DBF

Note:

In Windows:
---------------
For Connecting to recovery catalog Database 'CATDB' with rman for Target Database 'ORCL':
C:\Windows\system32>set ORACLE_SID=ORCL
C:\Windows\system32>rman target / CATALOG rman/rman@CATDB

In Linux:
-----------------
For Connecting to recovery catalog Database 'CATDB' with rman for Target Database 'ORCL':
$export ORACLE_SID=ORCL
$rman target / CATALOG rman/rman@CATDB

Rest all steps are prety much similar in both environment.....


***************************************************************

How to differ out put of list backup summary from target controlfiel or catalog database info.

From target database controlfile:

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
13      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T230953
14      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235112
15      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235119
16      B  0  A DISK        24-DEC-15       1       1       NO         TAG20151224T235230
17      B  0  A DISK        24-DEC-15       1       1       NO         TAG20151224T235230
18      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235457
19      B  A  A DISK        24-DEC-15       1       1       NO         TAG20151224T235502
20      B  A  A DISK        24-DEC-15       1       1       NO         TAG20151224T235502
21      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235503
22      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235505
23      B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235832
24      B  F  A DISK        25-DEC-15       1       1       NO         TAG20151225T000007

RMAN> host

From catalog database repository:

RMAN> list backup summary;


List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
131     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T230953
132     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235112
133     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235119
134     B  0  A DISK        24-DEC-15       1       1       NO         TAG20151224T235230
135     B  0  A DISK        24-DEC-15       1       1       NO         TAG20151224T235230
136     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235457
137     B  A  A DISK        24-DEC-15       1       1       NO         TAG20151224T235502
138     B  A  A DISK        24-DEC-15       1       1       NO         TAG20151224T235502
139     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235503
140     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235505
141     B  F  A DISK        24-DEC-15       1       1       NO         TAG20151224T235832
142     B  F  A DISK        25-DEC-15       1       1       NO         TAG20151225T000007

RMAN> 

********************************************************************************

How to unregister  the catalog database:

connect to target database with catalog:

$rman target / catalog rmancat/rmancat@euro

RMAN> unregister database;

********************************************************************
Resync catalog from target database controlfile:

export ORACLE_SID=prod

$rman target / catalog rmancat/rmancat@catdb

RMAN>startup mount;

RMAN>resync catalog;

To update the recovery catalog using the current control file information, rman will first create a snapshot controlfile. It will then compare the contents of the recovery catalog to the contents of the snapshot control file and update the recovery catalog by adding the missing information and modifying the changed backup and schema related records.

*******************************************************************

DROPING RECOVERY CATALOG:

$rman catalog rmancat/rmancat@catdb

RMAN>drop catalog;

RMAN> drop catalog; -- For confirmation.

When we drop the base recovery catalog, you lose the backup information for all databases registered in the base recovery catalog.

******************************************************************

Viewing backup information from cagtalog db:

Connect catalog database:

export ORACLE_SID=catdb

sqlplus "/as sysdba"

SQL> connect rmancat/rmancat@euro

SQL>

SQL> select dbid from rc_database where dbid='&dbid';
Enter value for dbid: 1322113438
old   1: select dbid from rc_database where dbid='&dbid'
new   1: select dbid from rc_database where dbid='1322113438'

      DBID
----------
1322113438

SQL> select db_key from rc_database where dbid='&dbid';
Enter value for dbid: 1322113438
old   1: select db_key from rc_database where dbid='&dbid'
new   1: select db_key from rc_database where dbid='1322113438'

    DB_KEY
----------
         1

SQL> 

Some important RC views:

RC_STORED_SCRIPT - lists info abour rman scripts stored in the recover catalog.

RC_UNUSABLE_BACKUPFILE_DETAILS - Shows the unusable backup files recorded in the recovery catalog.

RC_RMAN_STATUS - Similar to the V$RMAN_STATUS view and shows the status of all RMAN operations. This view doesn't contain information about any operations that are currently executing.

RC_RMAN_CONFIGURATION - The view provides information about persistent configuration settings.

RC_DATAFILE -  The view shows all datafiles registered in the recovery catalog.

RC_DATABASE - The view shows the databases registered in the recovery catalog.

RC_ARCHIVED_LOG - the view provides historical information on both archived as well as unarchived redo log.

********************************************************************

No comments:

Post a Comment