Recovery Manager (RMAN) is a utility that can manage all of your
Oracle backup and recovery activities. DBAs are often wary of using
RMAN because of its perceived complexity and its control over
performing critical tasks. The traditional backup and recovery methods
are tried-and-true. Thus, when your livelihood depends on your ability
to back up and recover the database, why implement a technology like
RMAN? The reason is that RMAN comes with several benefits:
o Incremental backups that only copy data blocks that have changed
since the last backup.
o Tablespaces are not put in backup mode, thus there is no extra redo
log generation during online backups.
o Detection of corrupt blocks during backups.
o Parallelization of I/O operations.
o Automatic logging of all backup and recovery operations.
RMAN's architecture is a combination of an executable program (the
RMAN utility) and background processes that interact with one or more
databases and with I/O devices. There are several key architectural
components to be aware of:
o RMAN executable
o Server processes
o Channels
o Target database
o Recovery catalog database (optional)
o Media management layer (optional)
Usage of RMAN in Real Life for Oracle versions 8.x & 9.x
This is the Scripting part of this article which gives you an idea on
how to utilize the RMAN Tool Facility in Oracle.
The Steps for using the RMAN is as follows :
ü We have to create a separate Database
ü A small instance with a minimum configuration should be created
ü After creation of the database, a tablespace should be created
Create a user for rman with default tablespace rman.
e.g. –
# CREATE USER IDENTIFIED BY
DEFAULT TABLESPACE
TEMPORARY TABLESPACE
QUOTA UNILIMITED ON ;
# GRANT CONNECT, RESOURCE, RECOVERY_CATALOG_OWNER TO ;
(Following steps must run in RMAN> prompt)
ü Connecting to the target database (e.g. – LTTEST)
e.g. –
RMAN> CONNECT TARGET sys/change_on_install@LTTEST;
(this step should have system privilage)
ü Creating catalog file
e.g. –
RMAN> CONNECT CATALOG /@;
RMAN> CREATE CATALOG TABLESPACE ;
RMAN> exit
Þ Connecting to the target database
e.g. –
$) rman target=sys/change_on_install@LTTEST catalog rman/rman@RMAN
$) register database (use only first time to register target database
in catalog)
$) exit
Þ sqlplus rman/rman@RMAN (check -> select * from db;) (note down DBID)
Þ Set oracle_sid for target database
$) ORACLE_SID=LTTEST; export $ORACLE_SID
Þ Shutdown target database
$) shutdown immediate
Þ Run script to take backup
$) rman target=sys/change_on_install@LTTEST catalog rman/rman@RMAN
RMAN> run {
2> allocate channel c1 type disk format ‘/ltbdata5/rman/rman_databkup/
bck_%n_%s_%p’;
3> backup database filesperset 3; (backup full database filesperset
3;)
4> release channel c1;
5> }
RMAN> list backup
( above RMAN backup contains full database backup in NOARCHIVELOG
mode)
(Following steps must run in RMAN> prompt)
ü Connecting to the target database (e.g. – LTTEST)
e.g. –
RMAN> CONNECT TARGET sys/change_on_install@LTTEST;
(this step should have system privilage)
ü Creating catalog file
e.g. –
RMAN> CONNECT CATALOG /@;
RMAN> CREATE CATALOG TABLESPACE ;
RMAN> exit
Þ Connecting to the target database
e.g. –
$) rman target=sys/change_on_install@LTTEST catalog rman/rman@RMAN
$) register database (use only first time to register target database
in catalog)
$) exit
Þ sqlplus rman/rman@RMAN (check -> select * from db;) (note down DBID)
Þ Set oracle_sid for target database
$) ORACLE_SID=LTTEST; export $ORACLE_SID
Þ Shutdown target database
$) shutdown immediate
Þ Run script to take backup
$) rman target=sys/change_on_install@LTTEST catalog rman/rman@RMAN
RMAN> run {
2> allocate channel c1 type disk format ‘/ltbdata5/rman/rman_databkup/
bck_%n_%s_%p’;
3> backup database filesperset 3; (backup full database filesperset
3;)
4> release channel c1;
5> }
RMAN> list backup
( above RMAN backup contains full database backup in NOARCHIVELOG
mode)
RESTORING A DATABASE TO A PREVIOUS INCARNATION
Here I will demonstrate you for some specific problems like what to do
when we lost a Data file, Control file and a log fiel from log file
group.
Firstly I go for when the Data File is Lost then how to restore.
Here it goes
Þ Set oracle_sid for target database
$) ORACLE_SID=LTTEST; export $ORACLE_SID
Þ Shutdown target database and move the current data files to another
location
$) rman target=sys/change_on_install@LTTEST catalog rman/rman@RMAN
RMAN> shutdown immediate
RMAN> host;
$) mv BACKUP
$) exit
RMAN> startup mount ( start the target instance in MOUNT state )
RMAN> run {
2> allocate channel c1 type disk;
3> restore database;
4> recover database;
5> sql “alter database open”;
6> }
Now When a Data fiel and Control file is goen then
Þ Set oracle_sid for target database
$) ORACLE_SID=LTTEST; export $ORACLE_SID
Þ Shutdown target database and move the current control files & data
files to another location
$) rman target=sys/change_on_install@LTTEST catalog rman/rman@RMAN
RMAN> shutdown immediate
RMAN> host;
$) mv BACKUP
$) mv BACKUP
$) exit
RMAN> startup nomount ( # start the target instance in NOMOUNT state –
because control files are missing )
RMAN> reset database to incarnation 2; ( this step required if we
rebuild control files from previous incarnation of RMAN – to check the
database incarnation issue following command
RMAN> list incarnation of database; )
RMAN> run {
2> allocate channel c1 type disk;
3> restore controlfile;
4> release channel c1;
5> sql “alter database mount”; ( # mount the db after restoring
control files )
6> allocate channel c2 type disk;
7> restore database;
8> recover database;
9> sql “alter database open resetlogs”;
10> }
Note :
Þ If we use “alter database open resetlogs” command at any point of
time during Recovery & Backup session, then we must use “reset
database” command on RMAN prompt for further proceedings.
Þ The status of catalog database can be found by using following
commands :
RMAN> list incarnation of database; (# this lists all previous
database incarnations)
RMAN> report schema;
RMAN> list backup; or list backupset
Regards,
Mohammed sheriff.s
+919894022554