Setting Up The Recovery Catalog
Setting Up The Recovery Catalog
Setting Up The Recovery Catalog
The recovery catalog is a schema that is created in a separate db. It contains the RMAN
metadata obtained from target db controlfile, you should use recovery catalog db when
you have multiple target db’s and manage RMAN stores, users & maintain the
information in the recovery catalog db.
It contains:-
1)Datafile & archive redolog file, backupsets & backup pieces.
2)Datafile copies
3)The physical structure of the target db.
4)Frequently used job scripts.
To use RMAN, a recovery catalog is not necessary. Remember that RMAN will always
use the control file of the target database to store backup and recovery operations. To use
a recovery catalog, you will first need to create a recovery catalog database and create a
schema for it. The catalog (database objects) will be located in the default tablespace of
the schema owner. Please note that the owner of the catalog cannot be the SYS user.
The recovery catalog database should be created on a different host, on different disks,
and in a different database from the target databse you will be backing up. If you do not,
the benefits of using a recovery catalog are lost if you loose the database and need to
restore.
The first step is to create a database for the recovery catalog. For the purpose of this
example, I created an Oracle 9.2.0 database named CATDB. The database has the
following installed:
1. Start SQL*Plus and then connect with SYSDBA privileges to the database
containing the recovery catalog:
Before using RMAN using a recovery catalog, you will need to register the taget
database(s) in the recovery catalog. RMAN will obtain all information it needs to register
the target database from the database itself.
As long as each target database has a distinct DBID, you can register more than one
target database in the same recovery catalog. Each database registered in a given catalog
must have a unique database identifier (DBID), but not necessarily a unique database
name.
You can use either the command-line utilities provided by RMAN or the Oracle
Enterprise Manager GUI to register the target database. For the purpose of this example, I
will be using the command-line utilities. I will be registering a database named TARGDB to
a recovery catalog within a database named CATDB. The target database must be either
mounted or opened in order to register it.
% . oraenv
ORACLE_SID = [TARGDB] ? TARGDB
This section describes the steps on how to remove (unregister) a database (the target
database) from the recovery catalog.
You can unregister a database by running the following procedure from the while logged
into the recovery catalog:
NOTE: If the target database does not exists anymore, the only steps to execute are (1) and
(3). Because the backupsets cannot be deleted from the catalog (requires to connect to the
target database) they are not be deleted from disk or tape either. So you have to remove
these backupsets manually. A list of the related backupsets are:
SQL> select handle from rc_backup_piece where db_id = <see step (1)>;
1. Identify the database that you want to unregister. Run the following query from
the recovery catalog using Server Manager or SQL*Plus (connected as the
RMAN user):
2. SQL> select * from rc_database;
3.
4. DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE#
RESETLOGS
5. ---------- ---------- ---------- -------- -----------------
---------
6. 1 2 2498101982 TARGDB 1 15-
JAN-04
7. 105 106 2457750772 OIDDB 1 14-
DEC-03
8. 128 129 2351019032 OMSDB 1 15-
JAN-04
301 302 2498937635 TARGDB 140831 25-
JAN-04
For this example, I want to unregister all databases with this catalog.
9. Remove the backupsets that belong to the database that you want to unregister.
o Find the backupsets of the database that you want to unregister.
The "db_key" and "db_id" values you will get by running the following query
from the recovery catalog:
C:>
Register Database
RMAN>
Existing user-created backups can be added to the catalog using:
RMAN> catalog datafilecopy 'C:\Oracle\Oradata\TSH1.dbf';
RMAN> catalog archivelog 'log1', 'log2', 'log3', ... 'logN';
Full Backup
If the controlfiles and online redo logs are still present a whole database recovery can be
achieved by running the following script:
run {
shutdown immediate; # use abort if this fails
startup mount;
restore database;
recover database;
alter database open;
}
This will result in all datafiles being restored then recovered. RMAN will apply archive logs as
necessary until the recovery is complete. At that point the database is opened. If the tempfiles are
still present you can issue a command like like the following for each of them:
sql "ALTER TABLESPACE temp ADD
TEMPFILE ''C:\Oracle\oradata\W2K2\temp01.dbf''
REUSE";
If the tempfiles are missing they must be recreated as follows:
sql "ALTER TABLESPACE temp ADD
TEMPFILE ''C:\Oracle\oradata\W2K2\temp01.dbf''
SIZE 100M
AUTOEXTEND ON NEXT 64K";
Incomplete Recovery
As you would expect, RMAN allows incomplete recovery to a specified time, SCN or sequence
number:
run {
shutdown immediate;
startup mount;
set until time 'Nov 15 2000 09:00:00';
# set until scn 1000; # alternatively, you can specify SCN
# set until sequence 9923; # alternatively, you can specify log
sequence number
restore database;
recover database;
alter database open resetlogs;
}
The incomplete recovery requires the database to be opened using the RESETLOGS option.
Disaster Recovery
In a disaster situation where all files are lost you can only recover to the last SCN in the archived
redo logs. Beyond this point the recovery would have to make reference to the online redo logs
which are not present. Disaster recovery is therefore a type of incomplete recovery. To perform
disaster recovery connect to RMAN:
C:>rman catalog=rman/rman@w2k1 target=sys/password@w2k2
Once in RMAN do the following:
startup nomount;
restore controlfile;
alter database mount;
From SQL*Plus as SYS get the last archived SCN using:
SQL> SELECT archivelog_change#-1 FROM v$database;
ARCHIVELOG_CHANGE#-1
--------------------
1048438
1 row selected.
SQL>
Back in RMAN do the following:
run {
set until scn 1048438;
restore database;
recover database;
alter database open resetlogs;
}
If the "until scn" were not set the following type of error would be produced once a redo log was
referenced:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/18/2003 09:33:19
RMAN-06045: media recovery requesting unknown log: thread 1 scn 1048439
With the database open all missing tempfiles must be replaced:
sql "ALTER TABLESPACE temp ADD
TEMPFILE ''C:\Oracle\oradata\W2K2\temp01.dbf''
SIZE 100M
AUTOEXTEND ON NEXT 64K";
Once the database is fully recovered a new backup should be perfomed.
The recovered database will be registered in the catalog as a new incarnation. The current
incarnation can be listed and altered using the following commands:
list incarnation;
reset database to incarnation x;
RMAN has extensive listing and reporting functionality allowing you to monitor you backups and
maintain the recovery catalog. Here are a few useful commands:
# Show all backup details
list backup;