Contents:-Register database in to Recovery Catalog Database, Virtual Private
Catalog Database, Resynchronization Recovery Catalog, Backup Recovery Catalog,
Export and Import Recovery Catalog Database.
Recovery Catalog Database Concept/ Features
A
Recovery catalog database preserves the backup information in a separate
database which is useful in the event of loss of control file.
A single
recovery catalog database is used to store backup information (rman repository
information) for multiple target database.
A
Recovery catalog can also store rman scripts.
Enables
you to create customized reports for all registered target database.
Allows
you to list the data files and tablespaces that are or were in the target
database at a given time.
Enables
you to use KEEP FOREVER Clause of the backup command
(means backup will never expires)
Commands and
Practicals
Rman> Report Schema -- is used to lists the tablespace and
datafiles in the target database.
Rman > Report Schema at <time/scn/log
sequence> (Can
only used at clause in recovery catalog database) . lists the tablespace and
datafiles of a particular time.
Creating Recovery Catalog
Steps
Allocate
Space for Recovery Catalog ( Consider number of database supported by
recovery catalog, rman script stored, number of archive log file and backups
recorded)
Create a Tablespace for Recovery Catalog
Sql> conn sys as sysdba
SQL>create tablespace rec_tablespace Datafile
‘+data(Datafile)’ size 10m autoextend on maxsize unlimited extent management
local segment space management auto;
Create the Recovery Catalog Owner
SQL> Create user rcowner identified by rcowner
temporary tablespace temp default tablespace rec_tabspace quota unlimited on
rec_tabspace;
SQL> Grant recovery_catalog_owner to rcowner;
Create the Recovery Catalog.
$> rman catalog rcowner/welcome@demo
Rman> Create catalog ( it will create the catalog tables in
the tablespace of the catalog owner.)
Managing Target Database Records in the Recovery
Catalog
Registering a Target Database
into Recovery Catalog ( if you use OEM then you have to additionally create
catalog and register or unregister database by OEM also even if you registered
or unregistered it manually)
It will create a row in the
recovery catalog table for the target database.
Synchronize the recovery catalog
with the control files.
$ rman target / catalog rcowner/welcome@demo
Rman> register database
Now check files regarding target
database orcl into recovery catalog database table.
$ sqlplus rcowner/welcome@demo
Sql> select * from rc_database;
Un-Registering a Target Database into Recovery Catalog
It will removes the information
about target database from recovery catalog.
When you unregister the database,
all rman repository information from recovery catalog will lost.
$ rman target / catalog username/pwd@servicename
Rman> unregister Database;
or
$sqlplus rcowner/welcome@demo
Sql> EXECUTE
dbms_rcvcat.unregisterdatabase(1,777592246);
Cataloging Additional Backup Files.
Catalog
command is used to catalog existing metadata backup files information that are
no longer listed in the control file.Catalog command can be use to add the
following types of backup files to the recovery catalog.
Control files
Rman> catalog controlfilecopy
‘/u01/app/oracle/control01.ctl’;
Data files
RMAN > catalog datafilecopy
‘/u01/app/oracle/user01.dbf’;
Backup Pieces
RMAN > catalog backuppiece ‘/u01/app/oracle/backup/backup_820.bkp’;
Archived Redo Log Files.
RMAN> catalog archivelog
‘/u01/app/oracle/archivelog/archive_031.log’;
Catalog all Files in the Currently enabled Fast Recovery Area as
follows
RMAN> catalog recovery area noprompt;
Catalog with START WITH Option / Recatalogs any available
backups
RMAN > catalog start with ‘/tmp/arch_logs/’ ( All types of backup files that
are found in the specified
directory and subdirectories are cataloged)
RMAN > catalog start with ‘/tmp/bset’ ( Catalog only those files in the /tmp
directory whose files names start with the string bset)
Notes:- Catalog Command can be
used without being connected to recovery catalog.
Recovery Catalog Resynchronization / Re-creating an
unrecoverable Recovery Catalog
When RMAN
performs resynchronization, it compares the recovery catalog to either the
current control file of the target database or a backup/standby control file
and updates the recovery catalog with information that is missing or changed.
There are
two types of Resynchronization
Partial
For
Partial Resynchronization, RMAN Compares the control file to the recovery
catalog and updates the recovery catalog with any metadata concerning backups,
archived redo logs, data file copies and so on.
Full
For a
Full Resynchronization, RMAN first creates the control file snapshot, which is
a temporary copy of the control file. It uses the snapshot to make the
comparison to the recovery catalog.
It
compares and updates all the data that a partial resynchronization does, but it
also includes the any database structure changes. For example, Database Schema
changes or new tablespaces are included in a full Resynchronization
Note:- IF
the only changes to the control file are those records are governed by
CONTROL_FILE_RECORD_KEEP_TIME, then a partial resynchronization is done.
Otherwise, a full resynchronization is done. A Full Resynchronization is also
done when you issue the RESYNC CATALOG Command.
Manually Resynchronizing the Recovery Catalog
RMAN > resync catalog;
Requirements
If the
recovery catalog was unavailable when you issued RMAN commands that cause
a partial resynchronization.
If you
perform infrequent backups of your target database because the recovery catalog
is not updated automatically when a redo log switch occurs or when a redo log
is archived.
After
making any changes to the physical structure of the target database.
RMAN Stored Scripts
Local:- Associated with the target database to which
RMAN is connected when the script is created.
RMAN >
Create script script_name { <RMAN Command> }
Global :- Can be executed against
any registered database in the recovery catalog.
RMAN >
Create Global script script_name { <RMAN Command> }
Creating from a Text File.
RMAN > Create Global script script_name
FROM file ‘file_name’;
Executing Script / Maintaining RMAN Stored Scripts
Execute Script
RMAN> RUN { Execute Script script_name ;}
RMAN> RUN { Execute Global Script script_name ;}
Displaying a script
RMAN >PRINT [GLOBAL] Script script_name
Sending the Contents of a script to a file.
RMAN >PRINT [GLOBAL] Script script_name to file
‘file_name’;
Displaying names of a defined script
RMAN >LIST [GLOBAL] SCRIPT NAMES;
Updating Script
RMAN > REPLACE [GLOBAL] SCRIPT script_name {
<RMAN Command> ;}
RMAN > REPLACE [GLOBAL] Script script_name from
FILE ‘file_name’;
Deleting a Script
RMAN> Delete script script_name;
View Detail Script
Sql> select * from rs_stored_script;
Sql> select * from rs_stored_script_line;
Backup the recovery Catalog
Recovery
Catalog is the database so take backup of the recovery catalog as the same as
normal database. But take backup of rman repository in control file instead of
recovery catalog.
Configure
control file autobackup so that the control file is backed up every time a
backup is made of the recovery catalog.
Steps
Run the
recovery catalog in archivelog mode.
Set the
retention policy to redundancy value greater than one
Backup
the recovery catalog to disk and tape.
To make
the backups, use the BACKUP DATABASE PLUS ARCHIVELOG command.
Use the
control file (NOCATALOG) , not another recovery catalog, as the RMAN Repository.
Configure
Controlfile autobackup to be on
Exporting and Importing the Recovery Catalog
Export/import
utilities is used to export and import the recovery catalog database.
Export
Recovery Catalog Database Schema and Import it to Another Recovery Catalog
Schema into Same Database.
First
Create another Recovery Catalog Schema and Grant Privileges.
Sql> create
user rcowner identified by welcome temporary tablespace temp default tablespace
rec_tablespace1 quota unlimited on rec_tablespace;
Sql> grant recovery_catalog_owner to rcowner;
1st Way
Export Recovery Catalog Source Schema and
import the source recovery catalog schema into another recovery catalog schema.
$> expdp
rconwer1/welcome directory=expdir dumpfile=full_catalog.dmp
$> impdp rcowner_dup/welcome directory=expdir dumpfile=full_catalog.dmp
remap_schema=rcowner1:rcowner_dup
2nd Way
Connect to Target Recovery Catalog Schema and
Create Catalog.
$> rman catalog rcowner_dup/welcome@demo
Rman > Create Catalog;
Import from source recovery catalog schema
using various option.
$>import catalog rcowner1/welcome@demo
db_id=<db_id>;
OR
$>import catalog rcowner1/welcome@demo db_name=orcl;
OR
$>import catalog rcowner1/welcome@demo db_name=orcl
unregister – registered database will not unregister from the source recovery
catalog schema.
Export
Recovery Catalog Database Schema and Import it to Another Recovery Catalog
Schema into another database.
First Create Recovery Catalog Schema into
target database and Grant Privileges.
Sql> create user rcowner identified by welcome
temporary tablespace temp default tablespace rec_tablespace1 quota unlimited on
rec_tablespace;
Sql> grant recovery_catalog_owner to rcowner;
Connect target database recovery catalog
schema and import Source database recovery catalog.
$> rman catalog rcowner/welcome@rdb
Rman> create catalog;
Rman > import catalog rcowner_dup/welcome@demo
db_name=orcl no unregister;
Note:-
You should not execute the CREATE
CATALOG Command before or
after importing the catalog into database. The import operation creates the
catalog in the second database.
With
import catalog command , you can import the metadata from one recovery catalog
schema into a different recovery catalog schema.
DBID/DB_NAME:- you
can specify the list of Database IDs or Database Names whose metadata should be
imported from the source catalog schema. When not specified, RMAN merges
metadata for all database IDs from the source catalog schema into the
destination catalog schema.
NO UNREGISTER : By default, the imported
database IDs are unregistered from the source recovery catalog schema after a
successful import. By using NO UNREGISTER option, you can force RMAN to keep
the imported database IDs in the source catalog schema.
Upgrading the Recovery Catalog
Requirements:-
if you use a version of the recovery catalog that is older than the
required by the RMAN Client, then you must upgrade it by following
command.
RMAN>
upgrade catalog;
Drop the Recovery Catalog Schema
RMAN > drop catalog;
Dropping
the catalog deletes the recovery catalog record of backup for all target
database registered in the catalog.
Debug Connection to Catalog Database
$> rman target / catalog rcowner/welcome@rdb debug
trace trace.log
Virtual Private Catalog Concept
RMAN
Catalog has been enhanced to create virtual private RMAN Catalogs for groups of
database and users.
The
Catalog owner creates the base catalog and grants the Recovery_catalog_owner
privilege to the owner of the virtual catalog.
The
catalog owner can either grant access to a registered database or grant the
REGISTER privilege to the virtual catalog owner.
The
virtual catalog owner can then connect to the catalog for a particular target
or register a target database.
After
this configuration, the VPC owner uses the virtual private catalog just like a
standard base catalog.
As a
virtual catalog owner, you can see only the database to which you have been
granted access. Note” if a catalog owner has not been granted sysdba or sysoper
on the target database, most RMAN operations cannot be performed.
Query to
show how many database Registered in Recovery Catalog
SQL> select distinct db_name from DBINC;
Configure Separate Virtual Private Catalog Database
Target Database:- ORCL Catalog Database:- rdb
Target Database:- demo (we will create demo database as a
virtual private catalog database)
Steps
Create tablespace for recovery_catalog
information and create new recovery catalog schema and grant privilege in
target database to which we want to make virtual private catalog database.
$> . oraenv
Demo
$> sqlplus sys as sysdba
Sql> create tablespace rec_tablespace Datafile
‘+data(Datafile)’ size 10m autoextend on maxsize unlimited extent management
local segment space management auto;
Sql> create user rcowner_dup identified by welcome
temporary tablespace temp default tablespace rec_tablespace quota unlimited on
rec_tablespace;
Sql> grant recovery_catalog_owner to rcowner_dup;
Now connect to target database, base recovery
catalog database and connect to target database to which we want to make
virtual private catalog database and create it to virtual private catalog
database.
$> . oraenv
Orcl
$> rman target /
Rman> connect catalog rcowner/welcome@rdb
Rman> connect catalog rcowner_dup/welcome@demo
Rman> create virtual catalog;
Configure
Virtual Private Catalog Schema on the same Base Catalog Database .
Catalog Database:- rdb
Steps
Create new virtual private catalog schema on
the same base catalog database and grant privileges.
$> sqlplus
sys/rdb@rdb as sysdba
Sql> create user rcowner_vpc identified by welcome
temporary tablespace temp default tablespace rc_tablespace quota unlimited on
rc_tablespace;
Sql> grant recovery_catalog_owner to rcowner_vpc;
Connect to the Base recovery catalog schema
and grant either access to registered database or grant register privilege to
register a target database to Virtual Private Catalog Schema.
$> rman
catalog rcowner/welcome@rdb
Rman > grant catalog for database orcl to
rcowner_vpc; -- grant access
to registered database.
Or
Rman > grant register database to
rcowner_vpc; -- grant
Register privilege to register a target database.
Connect to virtual private catalog schema and create the virtual
private catalog
$> rman catalog rcowner_vpc/welcome@rdb
Rman> create virtual catalog;
Or if earlier version than 11g the create
virtual catalog by following command
Connect
to virtual private catalog schema
$>sqlplus
rcowner_vpc/welcome@rdb
Sql> EXEC
rcowner.DBMS_RCVCAT.CREATE_VIRTUAL_CATALOG; -- here rcowner is the base catalog
owner.
Revoke catalog privilege from Virtual Private Recovery
Catalog schema within same catalog database.
Connect to base catalog schema and
revoke privilege from virtual private catalog schema
$>rman
catalog rcowner/welcome@rdb
Rman> revoke catalog for database orcl from
rcowner_vpc;
Drop virtual private catalog schema owner.
Connect to virtual private catalog schema and drop virtual
private catalog;
$> rman catalog rcowner_vpc/welcome@rdb
Rman> drop catalog;