Monday, August 31, 2009
RMAN Restore and recovery scenarios
Test Case1:
1. Startup the database in nomount mode
sql> startup nomount
2. Restore the control file from the backup you want to restore
RMAN> set DBID=XXXXXXXXXX
RMAN> restore controlfile from '/backups/rman/ctlback'
3. Mount the database
SQL> startup mount;
4. Find out the max sequence of the archive file and restore max+1 as its an incomplete recovery,
You can find it either using RMAN or through SQL,
RMAN> list backup of archivelog all;
SQL> set serverout on;
SQL> set num 50;
SQL> select sequence#,NEXT_CHANGE# from v$archived_log order by next_change# desc;
5. Restore and recover the database upto the archive log we have,
RMAN>
run
{
set until sequence 2337;
restore database;
recover database;
sql 'alter database open resetlogs';
}
Test Case 2:
Move the datafile tx_data7.dbf to another name after shutting down the database
2. startup the database, you will get the following error
ORA-01113: file 33 needs media recovery
ORA-01110: data file 33: '/u01/oracle/visndata/tx_data7.dbf'
3. Offline the datafile and open the database
4. Restore it using RMAN as follows,
RMAN> restore datafile 44;
or
SQL> alter database datafile '/u01/oracle/visndata/tx_data7.dbf' online;
alter database datafile '/u01/oracle/visndata/tx_data7.dbf' online
*
ERROR at line 1:
ORA-01113: file 33 needs media recovery
ORA-01110: data file 33: '/u01/oracle/visndata/tx_data7.dbf'
SQL>
SQL> recover datafile '/u01/oracle/visndata/tx_data7.dbf';
Media recovery complete.
SQL> alter database datafile '/u01/oracle/visndata/tx_data7.dbf' online;
Database altered.
Test Case: 3
Restore of datafiles from a full hot backup and complete recovery
RMAN offline or online database backup
Target database mode: Archivelog
Loss: All current datafiles have been lost. Current controlfiles and redo logs are still available.
Requirement: Restore and complete recovery
This example simulates the loss of the current database datafiles.
The current controlfile and redo logs are still intact.
Target database mode: Database mounted
RMAN> run {
restore database;
recover database;
sql "alter database open";
}
Notes:
Archived logs will be restored automatically as required.It is possible, but not necessary, to manually restore from an archivelog backupset
Test Case: 4
Restore of datafiles from a full hot backup and complete recovery
RMAN offline or online database backup
Target database mode: Archivelog
Loss: All current datafiles have been lost, current and inactive redolog groups member has been lost, controlfiles are also lost
Requirement: Restore and complete recovery of control files and open the database with resetlogs
select FIRST_CHANGE#,sequence# from v$archived_log order by FIRST_CHANGE# desc;
In our example we restored the control file from an incremental backup, but the latest archive log sequence is 70 and which is available on the disk, so in order for a complete recovery we need
RMAN> catalog archivelog '/u01/arch/NGIND_arch_70_1_672703990.arc';
cataloged archive log
archive log filename=/u01/arch/NGIND_arch_70_1_672703990.arc recid=4 stamp=678426497
Target database mode: Database mounted
RMAN> list archivelog all;
RMAN> run {
restore database;
recover database;
sql "alter database open resetlogs";
}
Notes:
Archived logs will be restored automatically as required if they are cataloged.It is possible, but not necessary, to manually restore from an archivelog backupset
Test Case: 5
Restore of datafiles from a full hot backup and complete recovery
RMAN offline or online database backup
Target database mode: Archivelog
Loss: All current datafiles have been lost, inactive and one current redo log is lost, current file is still available
Requirement: Restore and complete recovery of control files and open the database with resetlogs
RMAN> run {
restore database;
recover database;
sql "alter database open resetlogs";
}
Notes:
Archived logs will be restored automatically as required if they are cataloged.It is possible, but not necessary, to manually restore from an archivelog backupset
Subscribe to:
Post Comments (Atom)
1 comment:
thanks. you may also try the recover mdf files program, it quickly parses corrupted files of specified format and retrieves the source data from affected documents when possible. It may become a good addition to other ways of keeping your data safe
Post a Comment