Setting Up The Recovery Catalog

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 9

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.

Setting up the Recovery Catalog

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:

 You have access to the SYS password for the database.


 A temporary tablespace named TEMP already exists.
 A normal tablespace named TOOLS exists and will be used to store the recovery
catalog.
 The database is configured in the same way as all normal databases, for example,
catalog.sql and catproc.sql have been successfully run.

Now, let's create the recovery catalog:

1. Start SQL*Plus and then connect with SYSDBA privileges to the database
containing the recovery catalog:

% sqlplus "sys/change_on_install as sysdba"


2. Create a user and schema for the recovery catalog:
3. SQL> CREATE USER rman IDENTIFIED BY rman
4. 2 DEFAULT TABLESPACE tools
5. 3 TEMPORARY TABLESPACE temp
6. 4 QUOTA UNLIMITED ON tools;
7.
User created.
8. Grant the RECOVERY_CATALOG_OWNER role to the schema owner. This role
provides the user with privileges to maintain and query the recovery catalog:
9. SQL> GRANT RECOVERY_CATALOG_OWNER TO rman;
10.
Grant succeeded.
11. Grant other desired privileges to teh RMAN user:
12. SQL> GRANT CONNECT, RESOURCE TO rman;
13.
Grant succeeded.
14. After creating the catalog owner you should now create the catalog itself by using
the CREATE CATALOG command within the RMAN interface. This command will
create the catalog in the default tablespace of the catalog owner. you will need to
connect to the database that will contain the catalog as teh catalog owner as
follows:
15. % rman catalog rman/rman@catdb
16.
17. Recovery Manager: Release 9.2.0.1.0 - Production
18.
19. Copyright (c) 1995, 2002, Oracle Corporation. All rights
reserved.
20.
21. connected to recovery catalog database
recovery catalog is not installed
22. Now, run the CREATE CATALOG command to create the catalog. Note that this
process can take several minutes to complete.
23. RMAN> create catalog;
24.
recovery catalog created

Registering the Target Database

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

% rman target backup_admin/backup_admin catalog rman/rman@catdb

Recovery Manager: Release 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: TARGDB (DBID=2457750772)


connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog


starting full resync of recovery catalog
full resync complete

Unregister a Database From the Recovery Catalog

Taken from Metalink: Doc ID: Note:1058332.6

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:

SQL> execute dbms_rcvcat.unregisterdatabase(db_key, db_id)

To unregister a database, do the following:

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.

RMAN> list backupset of database;


o Remove the backupsets that belongs only to the database you want to
unregister.
o RMAN> allocate channel for delete type disk;
RMAN> change backupset XXX delete;
NOTE: You need to allocate a channel for the delete. In this example a disk drive is being
used and not a tape. The procedure for a backup done to tape is the same except you have
to allocate a different channel for tape. Example:
RMAN> allocate channel for delete type 'sbt_tape';
The XXX value is the 'list of key' value from the 'list backupset of database' command
10. Unregister the database by executing the following procedure from the recovery
catalog:

SQL> execute dbms_rcvcat.unregisterdatabase(db_key, db_id)

The "db_key" and "db_id" values you will get by running the following query
from the recovery catalog:

SQL> select * from rc_database;


DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE#
RESETLOGS
---------- ---------- ---------- -------- -----------------
---------
1 2 2498101982 TARGDB 1 15-
JAN-04
105 106 2457750772 OIDDB 1 14-
DEC-03
128 129 2351019032 OMSDB 1 15-
JAN-04
301 302 2498937635 TARGDB 140831 25-
JAN-04
Make sure you are using the correct values by looking at the 'NAME' column of
the "rc_database" table. Here is an example of how to unregister all databases
within this catalog:

SQL> execute dbms_rcvcat.unregisterdatabase(1, 2498101982)

PL/SQL procedure successfully completed.

SQL> execute dbms_rcvcat.unregisterdatabase(105, 2457750772)

PL/SQL procedure successfully completed.

SQL> execute dbms_rcvcat.unregisterdatabase(128, 2351019032)

PL/SQL procedure successfully completed.

SQL> execute dbms_rcvcat.unregisterdatabase(301, 2498937635)

PL/SQL procedure successfully completed.

Create Recovery Catalog

First create a user to hold the recovery catalog:


CONNECT sys/password@w2k1 AS SYSDBA

-- Create tablepsace to hold repository


CREATE TABLESPACE "RMAN"
DATAFILE 'C:\ORACLE\ORADATA\W2K1\RMAN01.DBF' SIZE 6208K REUSE
AUTOEXTEND ON NEXT 64K MAXSIZE 32767M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;

-- Create rman schema owner


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

GRANT connect, resource, recovery_catalog_owner TO rman;


Then create the recovery catalog:
C:>rman catalog=rman/rman@w2k1

Recovery Manager: Release 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to recovery catalog database


recovery catalog is not installed

RMAN> create catalog tablespace "RMAN";

recovery catalog created


RMAN> exit

Recovery Manager complete.

C:>

Register Database

Each database to be backed up by RMAN must be registered:


C:>rman catalog=rman/rman@w2k1 target=sys/password@w2k2

Recovery Manager: Release 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: W2K2 (DBID=1371963417)


connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog


starting full resync of recovery catalog
full resync complete

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

First we configure several persistant parameters for this instance:


RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure channel device type disk format
'C:\Oracle\Admin\W2K2\Backup%d_DB_%u_%s_%p';
Next we perform a complete database backup using a single command:
RMAN> run {
2> backup database plus archivelog;
3> delete noprompt obsolete;
4> }
The recovery catalog should be resyncronized on a regular basis so that changes to the database
structure and presence of new archive logs is recorded. Some commands perform partial and full
resyncs implicitly, but if you are in doubt you can perform a full resync using the follwoing
command:
RMAN> resync catalog;

Restore & Recover The Whole Database

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";

Restore & Recover A Subset Of The Database

A subset of the database can be restored in a similar fashion:


run {
sql 'ALTER TABLESPACE users OFFLINE IMMEDIATE';
restore tablespace users;
recover tablespace users;
sql 'ALTER TABLESPACE users ONLINE';
}

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;

Lists And Reports

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;

# Show items that beed 7 days worth of


# archivelogs to recover completely
report need backup days = 7 database;

# Show/Delete items not needed for recovery


report obsolete;
delete obsolete;
# Show/Delete items not needed for point-in-time
# recovery within the last week
report obsolete recovery window of 7 days;
delete obsolete recovery window of 7 days;

# Show/Delete items with more than 2 newer copies available


report obsolete redundancy = 2 device type disk;
delete obsolete redundancy = 2 device type disk;

# Show datafiles that connot currently be recovered


report unrecoverable database;
report unrecoverable tablespace 'USERS';

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy