Vous êtes sur la page 1sur 10

RMAN RECOVERY METHODS

MOHAMED DINAZ

Different Types of RMAN Recovery Steps: 1. Restoring and Recovering All Datafiles 2. Restoring Specific Tablespaces 3. Restoring Specific Datafiles 4. Restoring Control Files 5. Restoring Online Redologs 6. Time-Based, Change-Based, or SCN-based Incomplete Recovery 7. Recovering Archived Logs only

1.Restoring and Recovering All Datafiles :


If database is not down, make sure that the target database is shutdown.We need to startup our 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, we 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. Connect to Target database using RMAN. $. oraenv Enter oracle_sid : mxisme $ rman target / nocatalog RMAN> restore database; RMAN> recover database; RMAN> exit $ sqlplus /as sysdba SQL> alter database open; OR RMAN> run { allocate channel d1 type disk; restore database; recover database; }

alter database open; 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. NOTE: Full RMAN backup has to be taken after recovery is successfully completed

2.Restoring Specific Tablespaces :


Assuming our control files are still accessible and Full backup has been taken with archivelog. 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 the database and restore in mount mode. a) Take the tablespace offline: $ sqlplus "/ as sysdba" SQL> alter tablespace <tablespace_name> offline; If this works, continue with the RMAN recovery: $ rman target / nocatalog RMAN> restore tablespace <tablespace_name>; RMAN> recover tablespace <tablespace_name>; $ sqlplus /as sysdba SQL> alter tablespace <tablespace_name> online; If taking the tablespace offline fails, follow these steps: $ sqlplus / as SYSDBA SQL> shutdown immediate; SQL> startup mount; $ rman target / nocatalog RMAN> restore tablespace <tablespace_name>; RMAN> recover tablespace <tablespace_name>; RMAN> exit;

$ sqlplus /as sysdba SQL> alter database open; NOTE: Full RMAN backup has to be taken after recovery is successfully completed

3.Restoring Specific Datafiles :


Assuming our control files are still accessible and Full backup has been taken with archivelog. 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 the database and restore in mount mode. a)Take the datafile offline: SQL> alter database datafile <'Datafile_Path'> offline; If this works, continue with the RMAN recovery: $ rman target / nocatalog RMAN> restore datafile <'Datafile_Path'>; RMAN> recover datafile <'Datafile_Path'>; RMAN> exit; $ sqlplus /as sysdba SQL> alter database datafile <'Datafile_Path'> online; If taking the datafile offline fails, follow these steps: $ sqlplus /as SYSDBA SQL> shutdown immediate; SQL> startup mount; $ rman target / nocatalog RMAN> restore datafile <'Datafile_Path'>; RMAN> recover datafile <'Datafile_Path'>; RMAN> exit; $ sqlplus /as sysdba

SQL> alter database open; NOTE: Full RMAN backup has to be taken after recovery is successfully completed

4.Restoring Control Files:


Assuming our control files are still accessible and Full backup has been taken with archivelog. Following are the steps assuming that CATALOG database has been used : $ sqlplus /as sysdba SQL> shutdown immediate; SQL> startup nomount; $ rman target / 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 we must perform a recover database: SQL> shutdown immediate; SQL> startup mount; $ rman target / RMAN> recover database; $ sqlplus /as sysdba SQL> alter database open resetlogs; RMAN> reset database; Note :All offline archivelogs are now useless, perform a full back ASAP.

5.Restoring Online Redologs :


Assuming our control files are still accessible and Full backup has been taken with archivelog. $ sqlplus "/ as sysdba" SQL> shutdown immediate; SQL> startup nomount; $ rman target / RMAN> set dbid = xxxxxxxxxx; RMAN> restore controlfile; Open Another terminal: SQL> sqlplus /as sysdba SQL> alter database mount; From RMAN terminal: RMAN> restore database; RMAM> recover database; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 07/28/2010 11:03:23 RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 8448414 Since the online logs were lost, complete recovery is not possible. Open the database with resetlogs to continue. RMAN> alter database open resetlogs; --------IMPORTANT-----------During this type of recovery, if you receive error messages like this: RMAN> restore database; Starting restore at 11-JUL-05 using channel ORA_SBT_TAPE_1 using channel ORA_DISK_1 RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of restore command at 07/11/2005 14:25:22 RMAN-06026: some targets not found - aborting restore RMAN-06023: no backup or copy of datafile 10 found to restore RMAN-06023: no backup or copy of datafile 9 found to restore RMAN-06023: no backup or copy of datafile 8 found to restore RMAN-06023: no backup or copy of datafile 7 found to restore RMAN-06023: no backup or copy of datafile 6 found to restore RMAN-06023: no backup or copy of datafile 5 found to restore RMAN-06023: no backup or copy of datafile 4 found to restore RMAN-06023: no backup or copy of datafile 3 found to restore RMAN-06023: no backup or copy of datafile 2 found to restore RMAN-06023: no backup or copy of datafile 1 found to restore use the following directions to recover (recreate the controlfile): 1.With the database mounted, execute alter database backup controlfile to trace resetlogs; 2.Perform a shutdown abort on the database, but remain at the SQL> prompt. 3.In another telnet session, go to the udump directory to retrieve the resulting trace file and copy it to another location to edit it. 4.Edit the file and add the phrase until cancel to the recover database command at the end.The phrase should read recover database until cancel using backup controlfile. Remove the alter database open command after the recover command. Save the file with a .sql extension. 5.Back at the SQL> prompt, execute the modified trace file.When prompted for an archived log, type in cancel and the reply should be media recovery cancelled. 6.Issue alter database open resetlogs.The database should open after a few moments. 7.Connect to the RMAN recovery catalog and issue the reset databasecommand. 8.Perform a full RMAN backup as soon as possible.

6.Time-Based, Change-Based, or SCN-based Incomplete Recovery :


Incomplete recovery of the whole database is performed in the following situations: Media failure destroys some or all of the online redo logs. A user error causes data loss, for example, a user inadvertently drops a table. We cannot perform complete recovery because an archived redo log is missing. We lose our current control file and must use a backup control file to open the database. To perform incomplete media recovery, we must restore all datafiles from backups created prior to the time to which we want to recover and then open the database with the RESETLOGS option when recovery completes. The RESETLOGS operation creates a new incarnation of the database; in other words, a database with a new stream of log sequence numbers starting with log sequence 1. NOTE Start every RMAN incomplete recovery with the following commands: $ sqlplus "/ as sysdba" SQL> shutdown immediate; SQL> startup mount; $ rman target / --For time-based recovery, use these commands: Ex: $ sqlplus "/ as sysdba" SQL> shutdown immediate; SQL> startup mount; $ rman target / RMAN> restore database until time "to_date('07/12/05 12:0:00','MM/DD/YY HH24:MI:SS')"; RMAN> recover database until time "to_date('07/12/05 12:0:00','MM/DD/YY HH24:MI:SS')"; media recovery complete. SQL> alter database open resetlogs;

--For SCN-based recovery, user these commands: Ex: $ sqlplus "/ as sysdba" SQL> shutdown immediate; SQL> startup mount; $ rman target / RMAN> restore database until scn 1000; RMAN> recover database until scn 1000; media recovery complete. SQL> alter database open resetlogs; --For change-based recovery, user these commands: Ex: $ sqlplus "/ as sysdba" SQL> shutdown immediate; SQL> startup mount; $ rman target / RMAN> restore database until sequence 9923; --Archived log sequence number RMAN> recover database until sequence 9923; --Archived log sequence number media recovery complete. SQL> alter database open resetlogs; Once the recovery has been completed, execute the following steps: > Delete prior backups with this command (from the RMAN prompt): RMAN> delete force backup; This command removes all prior backups from the RMAN catalog as they can no longer be used once the database has been restarted with the resletlogs option. After completing this command, create a new RMAN backup to establish a new baseline.

7.Recovering Archived Logs only :


When we want to recover the database archived redo logs until a desired time, we can use the following commands: $ rman target / RMAN> restore ARCHIVELOG FROM TIME 'SYSDATE-1' UNTIL TIME 'SYSDATE'; or

RMAN> restore ARCHIVELOG FROM TIME "to_date('07/11/05 00:00:01','MM/DD/YY HH24:MI:SS')UNTIL TIME 'SYSDATE';