Wednesday, March 17, 2010

RMAN Recovery Methods

RMAN Recovery Methods

Process to follow if your control files are still accessible.

Restoring and Recovering All Datafiles

Assumed that your control files are still accessible. You have a backup, done using command

backup database plus archivelog;

Make sure that the target database is shut down:

#sqlplus “/ as SYSDBA”
SQL> shutdown abort;
ORACLE instance shut down
.

You need to start up your target database in mount mode. RMAN cannot restore datafiles unless the database is at least in mount mode, because RMAN needs to be able to access the control file to determine which backup sets are necessary to recover the database. If the control file isn't available, you have to recover it first. Issue the STARTUP MOUNT command shown in the following example to mount the database:

SQL> startup mount;
Oracle instance started.

Database mounted.

Since backup set files are created in an RMAN-specific format, you must use RMAN to restore the datafiles. To use RMAN, connect to the target database:

#rman target / oracle oracle/oracle@test

When the restore command is executed, RMAN will automatically go to its last good backup set and restore the datafiles to the state they were in when that backup set was created.

When restoring database files, RMAN reads the datafile header and makes the determination as to whether the file needs to be restored. The recovery is done by allocating a channel for I/O and then issuing the RMAN restore database command.

There have been major change onwards Oracle9i and above version, you don't need to allocate a channel explicitly. Instead, you can use the default channel mode:

RMAN> restore database;
RMAN> recover database;
SQL> alter database open;

For Oracle 8i

RMAN> run {
allocate channel d1 type disk;
restore database;
recover database;
}
alter database open;

Restoring Specific Tablespaces

Take the tablespace that needs recovery offline, restore the tablespace, recover the tablespace, and bring the tablespace online. If you cannot take the tablespace offline, then shutdown abort the database and restore in mount mode.

First try to take the tablespace offline;

$ sqlplus "/ as sysdba"
SQL> alter tablespace test offline;

If this works, continue with the RMAN recovery:

$ rman target / oracle oracle/oracle@test
RMAN> restore tablespace test;
RMAN> recover tablespace test;
SQL> alter tablespace test online;

If taking the tablespace offline fails, follow these steps:

$ sqlplus “/ as SYSDBA”
SQL> shutdown abort;
SQL> startup mount;
$ rman target / oracle oracle/oracle@test
RMAN> restore tablespace test;
RMAN> recover tablespace test;
SQL> alter database open;

Restoring Specific Datafiles

Take the datafile that needs recovery offline, restore the datafile, recover the datafile, and bring the datafile online. If you cannot take the datafile offline, then shutdown abort the database and restore in mount mode.

Take the datafile offline:

SQL> alter database datafile '/u01/oracle/db/test/test/dbI1_tab.dbf' offline;

If this works, continue with the RMAN recovery:

$ rman target / oracle oracle/oracle@test

RMAN> restore datafile '/u01/oracle/db/test/test/dbI1_tab.dbf’
RMAN> recover datafile '/u01/oracle/db/test/test/dbI1_tab.dbf'

SQL> alter database datafile '/u01/oracle/db/test/test/dbI1_tab.dbf’ online;

If taking the datafile offline fails, follow these steps:

$ sqlplus “/ as SYSDBA”
SQL> shutdown abort;
SQL> startup mount;
$ rman target / oracle oracle/oracle@test
RMAN> restore datafile '/u01/oracle/db/test/test/dbI1_tab.dbf’
RMAN> recover datafile '/u01/oracle/db/test/test/dbI1_tab.dbf'
SQL> alter database open;

Restoring Control Files

To recover Control Files follow the below

$ sqlplus “/ as SYSDBA”
SQL> shutdown abort;
SQL> startup nomount;
$ rman target / oracle oracle/oracle@test

Set the database id (DBID) with the following command. The number can be obtained from any previous RMAN backup log file.

RMAN> set dbid = xxxxxxxxxx;

RMAN> restore controlfile;
SQL> alter database mount;
SQL> alter database open;

If this fails with ...

ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

... then you must perform a recover database:

SQL> shutdown abort;
SQL> startup mount;
$ rman target / oracle oracle/oracle@test
RMAN> recover database;
SQL> alter database open resetlogs;

RMAN> reset database;

Restoring Online Redologs

Will add latter

No comments:

Post a Comment