Oracle Database 11g: Disaster Recovery Example
The following is a simple example how to use RMAN to backup a running Oracle 11g database and how to fully restore and recover it when all database files are lost or have been destroyed. It assumes that the database is running in Archive Log mode and that the Fast Recovery Area (FRA) has been configured for easier data management. Please see the Oracle documentation for more information.- [oracle@vm501 ~]$ . oraenv
- ORACLE_SID = [orcle] ? orcl2
- The Oracle base has been set to /u01/app/oracle
- [oracle@vm501 ~]$ rman target /
- connected to target database: ORCL2 (DBID=843703910)
- RMAN> configure controlfile autobackup on;
- RMAN> backup database plus archivelog delete input;
[oracle@vm501 ~]$ . oraenv ORACLE_SID = [orcle] ? orcl2 The Oracle base has been set to /u01/app/oracle [oracle@vm501 ~]$ rman target / connected to target database: ORCL2 (DBID=843703910) RMAN> configure controlfile autobackup on; RMAN> backup database plus archivelog delete input;
- Starting Control File and SPFILE Autobackup at 10-MAY-15
- piece handle=/u03/fast_recovery_area/ORCL2/autobackup/2015_05_10/o1_mf_s_879364591_bnz6yhy5_.bkp comment=NONE
- Finished Control File and SPFILE Autobackup at 10-MAY-15
Starting Control File and SPFILE Autobackup at 10-MAY-15 piece handle=/u03/fast_recovery_area/ORCL2/autobackup/2015_05_10/o1_mf_s_879364591_bnz6yhy5_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 10-MAY-15
Delete all database files:
- [oracle@vm501 ~]$ echo "shutdown abort;" | sqlplus / as sysdba
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_system_bnz5okkg_.dbf
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_sysaux_bnz5okll_.dbf
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_undotbs1_bnz5okn4_.dbf
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_users_bnz5oknl_.dbf
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_example_bnz5okmm_.dbf
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_temp_bnz68bpj_.tmp
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_3_bnz6887c_.log
- [oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_3_bnz688b0_.log
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_2_bnz687so_.log
- [oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_2_bnz687wt_.log
- [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_1_bnz687c6_.log
- [oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_1_bnz687g2_.log
[oracle@vm501 ~]$ echo "shutdown abort;" | sqlplus / as sysdba [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_system_bnz5okkg_.dbf [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_sysaux_bnz5okll_.dbf [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_undotbs1_bnz5okn4_.dbf [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_users_bnz5oknl_.dbf [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_example_bnz5okmm_.dbf [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/datafile/o1_mf_temp_bnz68bpj_.tmp [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_3_bnz6887c_.log [oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_3_bnz688b0_.log [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_2_bnz687so_.log [oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_2_bnz687wt_.log [oracle@vm501 ~]$rm -f /u02/oradata/ORCL2/onlinelog/o1_mf_1_bnz687c6_.log [oracle@vm501 ~]$rm -f /u03/fast_recovery_area/ORCL2/onlinelog/o1_mf_1_bnz687g2_.log
- [oracle@vm501 ~]$rm -f $ORACLE_HOME/dbs/spfileorcl2.ora
[oracle@vm501 ~]$rm -f $ORACLE_HOME/dbs/spfileorcl2.ora
- [oracle@vm501 ~]$ . oraenv
- ORACLE_SID = [orcl2] ? orcl2
- The Oracle base remains unchanged with value /u01/app/oracle
- [oracle@vm501 ~]$ rman target /
- connected to target database (not started)
- RMAN> set DBID 843703910
- RMAN> startup nomount
- RMAN> restore spfile from autobackup
- db_recovery_file_dest='/u03/fast_recovery_area' db_name='ORCL2';
- RMAN> startup force nomount
- RMAN> restore controlfile from autobackup;
- RMAN> startup force mount
- RMAN> restore database;
- RMAN> recover database;
- RMAN-06054: media recovery requesting unknown archived log for thread 1
[oracle@vm501 ~]$ . oraenv ORACLE_SID = [orcl2] ? orcl2 The Oracle base remains unchanged with value /u01/app/oracle [oracle@vm501 ~]$ rman target / connected to target database (not started) RMAN> set DBID 843703910 RMAN> startup nomount RMAN> restore spfile from autobackup db_recovery_file_dest='/u03/fast_recovery_area' db_name='ORCL2'; RMAN> startup force nomount RMAN> restore controlfile from autobackup; RMAN> startup force mount RMAN> restore database; RMAN> recover database; RMAN-06054: media recovery requesting unknown archived log for thread 1
The RMAN-06054 error in this case is benign. It appears because the recovery procedure continues requesting the next archive log, however, the database has been already been recovered to a consistent state and there are no more archived redo logs to apply. The error could be avoided by using the UNTIL clause and specifying the last database SCN or archivelog sequence that needs to be applied, like it is done when performing a database point in time restore and recovery (PITR), but it is not necessary in this case.
- RMAN> alter database open resetlogs;
- database opened
RMAN> alter database open resetlogs; database opened
- including current control file in backup set
- including current SPFILE in backup set
- channel ORA_DISK_1: starting piece 1 at 10-MAY-15
- channel ORA_DISK_1: finished piece 1 at 10-MAY-15
- piece handle=/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp
including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 10-MAY-15 channel ORA_DISK_1: finished piece 1 at 10-MAY-15 piece handle=/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp
- RMAN> restore spfile from '/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp';
- RMAN> restore controlfile from '/u03/fast_recovery_area/ORCL2/backupset/2015_05_10/o1_mf_ncsnf_TAG20150510T183149_bnz20tdn_.bkp'