Pages

Friday, November 30, 2012

How to recover a never backed up tablespace after losing its datafile and even the current controlfile but before the autobackup feature completes its job

During our daily dba job it sometimes happens to add a new tablespace: perhaps a new application deployment requires a dedicated schema where to save tables and information, and you want to localize those tables into a specific tablespace.

You are confident your backup script will still be able to guarantee a valid backup including the new tablespace: indeed in the next few hours your cron job will execute those RMAN backup scripts and take a full backup of your database.

The question is:
what does it happen if you lose your new tablespace before your nigthly backup script is successfully executed ?
Think 5 minutes: you already should know the answer. We saw a similar scenario in a post of this blog ("How to recover from a loss of a read-only tablespace" located at web page http://dbaworkshop.blogspot.it/2012/09/how-to-recover-from-loss-of-read-only.html).

All the required information is still available and written in your archived or online redo log. So the solution of the first question is as simple as write the following lines code:
RMAN> restore tablespace my_new_tablespace;
RMAN> recover tablespace my_new_tablespace

A more difficult question could be instead:
what does it happen when you lose your new tablespace with all your new transactions already committed five minutes before your full RMAN backup script is executed (same situation described above) AND, at the same time, your control file where information of your datafile was recorded ?
And no, the answer is not: "Today is a bad day".
Would be RMAN able to restore your tablespace using a controlfile coming from a backup older than your "CREATE TABLESPACE" command ?
Does your archived or online redo log have instead all the necessary information to restore and recover your tablespace ?
The restore and recovery process depends on the information contained in the available controlfile: there could be two or three different scenarios and I'm going to show them in this post and in the next one.

This post will take into consideration a Recovery Manager setting using the CONTROLFILE AUTOBACKUP feature, a tablespace created after the only available full backup (so this backup doesn't have information on this tablespace), some rows committed on the new tablespace, a crash happened few seconds before the autobackup feature completes its job to create a backup of the controlfile because of a structural change of the database.
Starting with Oracle 11gR2, RMAN creates the autobackup controlfile encompassing all of the structural changes that have occurred in the database within a few minutes.
"Within few minutes..." in my virtualized environment and several production installations means from 5 to even 10 minutes must pass before the autobackup controlfile is created.

So let's start with an example remembering that in this crash scenario you are going to lose the "never backed up" tablespace and the current controlfile at the same time.

Our instance is up and running.
[oracle@localhost orcl]$ ps -ef|grep smon
oracle    9488     1  0 02:47 ?        00:00:05 ora_smon_orcl
oracle   13341 13309  0 05:51 pts/5    00:00:00 grep smon
Connect with RMAN client to see my persistent settings.
[oracle@localhost orcl]$ rman target /

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'HIGH' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home/oracle/app/oracle/product/11.2.0/dbhome_2/dbs/snapcf_orcl.f'; # default
Connect with sqlplus client and (try to) drop the tablespace XXX including its contents and datafiles.
[oracle@localhost orcl]$ sqlplus / as sysdba

SQL> drop tablespace XXX including contents and datafiles;
drop tablespace XXX including contents and datafiles
*
ERROR at line 1:
ORA-00959: tablespace 'XXX' does not exist
Now delete all backups and copies. I want to be sure I don't have a valid backup of XXX tablespace.
[oracle@localhost orcl]$ rman target /

RMAN> delete backup;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=56 device type=DISK

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
129     128     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_annnn_TAG20121126T220655_8c8p3zwk_.bkp
130     129     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_26/o1_mf_s_800403200_8c8pj2dv_.bkp
131     130     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_nnndf_TAG20121126T220657_8c8p42b4_.bkp
132     131     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_annnn_TAG20121126T221815_8c8ps84p_.bkp
133     132     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_26/o1_mf_s_800403497_8c8ps9rv_.bkp
134     133     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_ncnnf_TAG20121126T223003_8c8qhdq3_.bkp
135     134     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_26/o1_mf_s_800404205_8c8qhg3l_.bkp
136     135     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800419680_8c96m0y8_.bkp
137     136     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800422100_8c98yngz_.bkp
138     137     1   1   AVAILABLE   DISK        /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800425124_8c9cx4h2_.bkp

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_annnn_TAG20121126T220655_8c8p3zwk_.bkp RECID=129 STAMP=800402815
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_26/o1_mf_s_800403200_8c8pj2dv_.bkp RECID=130 STAMP=800403202
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_nnndf_TAG20121126T220657_8c8p42b4_.bkp RECID=131 STAMP=800402818
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_annnn_TAG20121126T221815_8c8ps84p_.bkp RECID=132 STAMP=800403496
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_26/o1_mf_s_800403497_8c8ps9rv_.bkp RECID=133 STAMP=800403497
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_26/o1_mf_ncnnf_TAG20121126T223003_8c8qhdq3_.bkp RECID=134 STAMP=800404204
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_26/o1_mf_s_800404205_8c8qhg3l_.bkp RECID=135 STAMP=800404206
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800419680_8c96m0y8_.bkp RECID=136 STAMP=800419680
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800422100_8c98yngz_.bkp RECID=137 STAMP=800422100
deleted backup piece
backup piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800425124_8c9cx4h2_.bkp RECID=138 STAMP=800425124
Deleted 10 objects

RMAN> delete noprompt copy;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=56 device type=DISK
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================

Key     Thrd Seq     S Low Time           
------- ---- ------- - -------------------
156     1    3       A 26-11-2012 22:04:49
        Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_26/o1_mf_1_3_8c8p3zbb_.arc

157     1    4       A 26-11-2012 22:06:55
        Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_26/o1_mf_1_4_8c8ps77f_.arc

158     1    5       A 26-11-2012 22:18:15
        Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_5_8c9chdq1_.arc

deleted archived log
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_26/o1_mf_1_3_8c8p3zbb_.arc RECID=156 STAMP=800402815
deleted archived log
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_26/o1_mf_1_4_8c8ps77f_.arc RECID=157 STAMP=800403495
deleted archived log
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_5_8c9chdq1_.arc RECID=158 STAMP=800424685
Deleted 3 objects
Now it's time to take a full database backup including the archived redo log. This backup doesn't contain a tablespace named XXX.
RMAN> backup database plus archivelog;

Starting backup at 27-11-2012 05:54:05
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=6 RECID=159 STAMP=800430845
channel ORA_DISK_1: starting piece 1 at 27-11-2012 05:54:06
channel ORA_DISK_1: finished piece 1 at 27-11-2012 05:54:07
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_annnn_TAG20121127T055405_8c9khy7t_.bkp tag=TAG20121127T055405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 27-11-2012 05:54:07

Starting backup at 27-11-2012 05:54:07
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf
input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/oradata/orcl/read_only01.dbf
input datafile file number=00009 name=/home/oracle/app/oracle/oradata/orcl/example02.dbf
channel ORA_DISK_1: starting piece 1 at 27-11-2012 05:54:08
channel ORA_DISK_1: finished piece 1 at 27-11-2012 06:05:45
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_nnndf_TAG20121127T055407_8c9kj0ty_.bkp tag=TAG20121127T055407 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:11:37
Finished backup at 27-11-2012 06:05:45

Starting backup at 27-11-2012 06:05:45
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=160 STAMP=800431546
channel ORA_DISK_1: starting piece 1 at 27-11-2012 06:05:47
channel ORA_DISK_1: finished piece 1 at 27-11-2012 06:05:48
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_annnn_TAG20121127T060546_8c9l5vgg_.bkp tag=TAG20121127T060546 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 27-11-2012 06:05:48

Starting Control File and SPFILE Autobackup at 27-11-2012 06:05:48
piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800431548_8c9l5xbv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 27-11-2012 06:05:51
My only current backup is formed by the following backup sets:
RMAN> list backup;

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
138     1.27M      DISK        00:00:00     27-11-2012 05:54:06
        BP Key: 139   Status: AVAILABLE  Compressed: YES  Tag: TAG20121127T055405
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_annnn_TAG20121127T055405_8c9khy7t_.bkp

  List of Archived Logs in backup set 138
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    6       14557799   27-11-2012 04:11:24 14559404   27-11-2012 05:54:05

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
139     Full    9.45M      DISK        00:00:02     27-11-2012 05:59:12
        BP Key: 140   Status: AVAILABLE  Compressed: NO  Tag: TAG20121127T055910
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800431150_8c9kshfg_.bkp
  SPFILE Included: Modification time: 26-11-2012 22:07:49
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 14559567     Ckp time: 27-11-2012 05:59:10

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
140     Full    680.28M    DISK        00:11:35     27-11-2012 06:05:42
        BP Key: 141   Status: AVAILABLE  Compressed: YES  Tag: TAG20121127T055407
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_nnndf_TAG20121127T055407_8c9kj0ty_.bkp
  List of Datafiles in backup set 140
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/system01.dbf
  2       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
  3       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
  4       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/users01.dbf
  5       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/example01.dbf
  6       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.dbf
  7       Full 13915815   02-09-2012 22:03:34 /home/oracle/app/oracle/oradata/orcl/read_only01.dbf
  9       Full 14559410   27-11-2012 05:54:08 /home/oracle/app/oracle/oradata/orcl/example02.dbf

BS Key  Size       Device Type Elapsed Time Completion Time    
------- ---------- ----------- ------------ -------------------
141     315.50K    DISK        00:00:00     27-11-2012 06:05:47
        BP Key: 142   Status: AVAILABLE  Compressed: YES  Tag: TAG20121127T060546
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_annnn_TAG20121127T060546_8c9l5vgg_.bkp

  List of Archived Logs in backup set 141
  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time
  ---- ------- ---------- ------------------- ---------- ---------
  1    7       14559404   27-11-2012 05:54:05 14559867   27-11-2012 06:05:46

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
142     Full    9.45M      DISK        00:00:01     27-11-2012 06:05:49
        BP Key: 143   Status: AVAILABLE  Compressed: NO  Tag: TAG20121127T060548
        Piece Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800431548_8c9l5xbv_.bkp
  SPFILE Included: Modification time: 26-11-2012 22:07:49
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 14559876     Ckp time: 27-11-2012 06:05:48

RMAN> list copy;

specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================

Key     Thrd Seq     S Low Time           
------- ---- ------- - -------------------
159     1    6       A 27-11-2012 04:11:24
        Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_6_8c9khxlq_.arc

160     1    7       A 27-11-2012 05:54:05
        Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_7_8c9l5tb5_.arc
I'm going to create the new XXX tablespace and a new table (IMPORTANT_XXX_TRANSACTION) containing some commited rows.
[oracle@localhost orcl]$ sqlplus / as sysdba

SQL> create tablespace XXX DATAFILE '/home/oracle/app/oracle/oradata/orcl/XXX01.dbf' size 1M autoextend on next 1M maxsize 10M;

Tablespace created.

SQL> create table IMPORTANT_XXX_TRANSACTION (a number, b number) tablespace XXX;

Table created.

SQL> begin
  2  for indx IN 1 .. 1000
  3  loop
  4  execute immediate 'insert into IMPORTANT_XXX_TRANSACTION(a,b) values (:1, :2)' using indx, indx*2;
  5  end loop;
  6  commit;
  7  end;
  8  /

PL/SQL procedure successfully completed.

SQL> alter system switch logfile;

System altered.
As anticipated at the beginning of this post in Oracle Database 11gR2 the autobackup feature starts within a delay trying to encompass all of the structural changes made to the database rather than creating a new backup of the controlfile on each structural change. This delay could be critical for you and for your transactions and simply implies different ways to restore and recover them.
Let's simulate a loss of our current controlfile and of our "never backed up" new tablespace (XXX), before our instance remembers to create the "delayed" autobackup controlfile.
[oracle@localhost orcl]$ cd /home/oracle/app/oracle/oradata/orcl/
[oracle@localhost orcl]$ ls
APEX_1930613455248703.dbf  example01.dbf        XXX201.dbf.bck  redo01b.log  redo02.log   sysaux01.dbf  temp02.dbf
control01.ctl              example02.dbf        non_default_location      redo01.log   redo03b.log  system01.dbf  undotbs01.dbf
control01.ctl.bck          XXX01.dbf  read_only01.dbf           redo02b.log  redo03.log   temp01.dbf    users01.dbf
[oracle@localhost orcl]$ mv control01.ctl control01.ctl.bck
[oracle@localhost orcl]$ mv /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl.bck
[oracle@localhost orcl]$ mv XXX01.dbf XXX01.dbf.bck
The instance is still up and running
[oracle@localhost orcl]$ ps -ef|grep smon
oracle    9488     1  0 02:47 ?        00:00:05 ora_smon_orcl
oracle   13499 13309  0 06:09 pts/5    00:00:00 grep smon
The rows are still available
[oracle@localhost orcl]$ sqlplus / as sysdba

SQL> select count(*) from IMPORTANT_XXX_TRANSACTION;

  COUNT(*)
----------
      1000
The alert log discovered a current controlfile is missing.
[oracle@localhost orcl]$ vi /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log
...
Tue Nov 27 06:09:52 2012
Errors in file /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_m000_13503.trc:
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/home/oracle/app/oracle/oradata/orcl/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
...
The instance is not working anymore.
[oracle@localhost orcl]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 27 06:10:22 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL>  select count(*) from IMPORTANT_XXX_TRANSACTION;
 select count(*) from IMPORTANT_XXX_TRANSACTION
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
I force the instance to abort.
SQL> shutdown abort;
ORACLE instance shut down.
Inside the "lost" controlfile some references to the new tablespace are present.
[oracle@localhost orcl]$ strings control01.ctl.bck |grep -i XXX
XXX
XXX
Let's try to recover our database. Connecting the RMAN client, the output log shows a not started instance.
[oracle@localhost orcl]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Tue Nov 27 06:11:05 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

Start the instance in NOMOUNT mode
RMAN> startup nomount;

Oracle instance started

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                394267320 bytes
Database Buffers              54525952 bytes
Redo Buffers                   6008832 bytes
We have lost our current controlfile and want to restore it using the autobackup feature. RMAN is able to search from the available backup set and find the right one.
RMAN> restore controlfile from autobackup;

Starting restore at 27-11-2012 06:11:28
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

recovery area destination: /home/oracle/app/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800431548_8c9l5xbv_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800431548_8c9l5xbv_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/home/oracle/app/oracle/oradata/orcl/control01.ctl
output file name=/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
Finished restore at 27-11-2012 06:11:32
The restored controlfile doesn't have any references about the XXX tablespace: that autobackup of the control file was created indeed before the creation of the lost tablespace.
[oracle@localhost orcl]$ strings control01.ctl |grep -i XXX
Connect again with RMAN client to the "not mounted" instance.
[oracle@localhost orcl]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Tue Nov 27 06:12:41 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (not mounted)
A controlfile is now available to mount the instance.
RMAN> alter database mount;

using target database control file instead of recovery catalog
database mounted
The report schema command in "List of Permanent Datafiles" section does not have any information about XXX tablespace and its datafile.
RMAN> report schema;

Starting implicit crosscheck backup at 27-11-2012 06:12:57
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 27-11-2012 06:12:59

Starting implicit crosscheck copy at 27-11-2012 06:12:59
using channel ORA_DISK_1
Finished implicit crosscheck copy at 27-11-2012 06:12:59

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_8_8c9lcht5_.arc
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789203952_80ogm1c3_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789209074_80omm3d0_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_27/o1_mf_s_800431548_8c9l5xbv_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_10_05/o1_mf_s_795852591_86xq10nr_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_10_05/o1_mf_s_795834324_86x564xb_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_09_26/o1_mf_s_795045371_867q3d12_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_17/o1_mf_s_788864449_80c39jlo_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_23/o1_mf_s_800101490_8bzkk05s_.bkp

RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name ORCL

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    911      SYSTEM               ***     /home/oracle/app/oracle/oradata/orcl/system01.dbf
2    1105     SYSAUX               ***     /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
3    65       UNDOTBS1             ***     /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
4    225      USERS                ***     /home/oracle/app/oracle/oradata/orcl/users01.dbf
5    82       EXAMPLE              ***     /home/oracle/app/oracle/oradata/orcl/example01.dbf
6    7        APEX_1930613455248703 ***     /home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.dbf
7    1        READ_ONLY            ***     /home/oracle/app/oracle/oradata/orcl/read_only01.dbf
9    1        EXAMPLE2             ***     /home/oracle/app/oracle/oradata/orcl/example02.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /home/oracle/app/oracle/oradata/orcl/temp01.dbf
2    20       TEMP                 50          /home/oracle/app/oracle/oradata/orcl/temp02.dbf
The "RMAN-20202: Tablespace not found in the recovery catalog" and "RMAN-06019: could not translate tablespace name "XXX"" errors are thrown, because the controlfile used has no information about that tablespace as you can see in the following output:
RMAN> restore tablespace XXX;

Starting restore at 27-11-2012 06:13:47
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 11/27/2012 06:13:47
RMAN-20202: Tablespace not found in the recovery catalog
RMAN-06019: could not translate tablespace name "XXX"
To recover the missing and "never backed up" tablespace you must restore and recover the entire database.
RMAN> restore database;

Starting restore at 27-11-2012 06:14:31
using channel ORA_DISK_1

skipping datafile 7; already restored to file /home/oracle/app/oracle/oradata/orcl/read_only01.dbf
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /home/oracle/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /home/oracle/app/oracle/oradata/orcl/APEX_1930613455248703.dbf
channel ORA_DISK_1: restoring datafile 00009 to /home/oracle/app/oracle/oradata/orcl/example02.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_nnndf_TAG20121127T055407_8c9kj0ty_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_27/o1_mf_nnndf_TAG20121127T055407_8c9kj0ty_.bkp tag=TAG20121127T055407
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:05:18
Finished restore at 27-11-2012 06:19:49

RMAN> recover database;

Starting recover at 27-11-2012 06:21:02
using channel ORA_DISK_1
datafile 7 not processed because file is read-only

starting media recovery

archived log for thread 1 with sequence 7 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_7_8c9l5tb5_.arc
archived log for thread 1 with sequence 8 is already on disk as file /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_8_8c9lcht5_.arc
archived log for thread 1 with sequence 9 is already on disk as file /home/oracle/app/oracle/oradata/orcl/redo03.log
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_7_8c9l5tb5_.arc thread=1 sequence=7
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_8_8c9lcht5_.arc thread=1 sequence=8
creating datafile file number=8 name=/home/oracle/app/oracle/oradata/orcl/XXX01.dbf
archived log file name=/home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_8_8c9lcht5_.arc thread=1 sequence=8
archived log file name=/home/oracle/app/oracle/oradata/orcl/redo03.log thread=1 sequence=9
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-11-2012 06:21:12
In the above log of the recover database command you can see the creation of datafile number 8 ...
...
creating datafile file number=8 name=/home/oracle/app/oracle/oradata/orcl/XXX01.dbf
...
... and in the alert log you can find also the following lines:
...
Media Recovery Log /home/oracle/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_27/o1_mf_1_8_8c9lcht5_.arc
File #8 added to control file as 'UNNAMED00008'. Originally created as:
'/home/oracle/app/oracle/oradata/orcl/XXX01.dbf'
...
Since I restored a controlfile from a backup, it is required to open the database using the resetlogs option:
RMAN> alter database open resetlogs;

database opened
The new current controlfile has records about the XXX tablespace and its datafile.
[oracle@localhost orcl]$ strings control01.ctl |grep -i XXX
/home/oracle/app/oracle/oradata/orcl/XXX01.dbf
/home/oracle/app/oracle/oradata/orcl/XXX01.dbf
XXX
XXX
All previous data inserted and committed into IMPORTANT_XXX_TRANSACTION table are available again.
[oracle@localhost orcl]$ sqlplus / as sysdba

SQL> select count(*) from IMPORTANT_XXX_TRANSACTION;

  COUNT(*)
----------
      1000
That's all.

Wednesday, November 14, 2012

How to restore from a loss of all current control files to a non default location using a backup piece

Here again with a scenario simulating a loss of all the control files and restoring them to a non-default location: differently from previous posts (here and here) you don't have an autobackup control file available, but just a backup piece.

First of all just create a location outside the flash recovery area where to save the backup piece containing the current control file:
[oracle@localhost oracle]$ pwd
/home/oracle/app/oracle/
[oracle@localhost oracle]$ mkdir controlfile_copy
[oracle@localhost oracle]$ cd controlfile_copy/
[oracle@localhost controlfile_copy]$ ll
total 0
Now it's time to create the backup piece with the current control file.
RMAN> backup current controlfile to destination '/home/oracle/app/oracle/controlfile_copy';

Starting backup at 09-11-2012 06:29:08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 09-11-2012 06:29:10
channel ORA_DISK_1: finished piece 1 at 09-11-2012 06:29:11
piece handle=/home/oracle/app/oracle/controlfile_copy/ORCL/backupset/2012_11_09/o1_mf_ncnnf_TAG20121109T062908_89t4sp41_.bkp tag=TAG20121109T062908 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-11-2012 06:29:11
In your local directory RMAN was able to create your backup piece as written in the above log and as you can verify moving through those directories:
[oracle@localhost controlfile_copy]$ ll
total 4
drwxrwx--- 3 oracle oracle 4096 Nov  9 06:29 ORCL
[oracle@localhost controlfile_copy]$ cd ORCL/backupset/2012_11_09/
[oracle@localhost 2012_11_09]$ ll
total 9680
-rw-rw---- 1 oracle oracle 9895936 Nov  9 06:29 o1_mf_ncnnf_TAG20121109T062908_89t4sp41_.bkp
Let's simulate the loss of all current control files.
[oracle@localhost ~]$ rm /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl /home/oracle/app/oracle/oradata/orcl/control01.ctl
Instance is still running, so I have to kill it.
[oracle@localhost ~]$ ps -ef|grep smon
oracle    2384     1  0 03:58 ?        00:00:03 ora_smon_orcl
oracle    6758  3039  0 06:35 pts/1    00:00:00 grep smon
[oracle@localhost ~]$ kill -9 2384
[oracle@localhost ~]$ ps -ef|grep smon
oracle    6762  3039  0 06:35 pts/1    00:00:00 grep smon
Under my non_default_location directory I will restore the control file: currently it's empty.
[oracle@localhost non_default_location]$ pwd
/home/oracle/app/oracle/oradata/orcl/non_default_location
[oracle@localhost non_default_location]$ ll
total 0
Use RMN to connect to your target instance.
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Fri Nov 9 07:46:58 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)
Start the database in NOMOUNT mode.
RMAN> startup nomount;

Oracle instance started

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                364907192 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6008832 bytes
Use the following RESTORE CONTROLFILE command to get the control file backup from your backup piece and restore it to your non default location:
RMAN> restore controlfile to '/home/oracle/app/oracle/oradata/orcl/non_default_location/control01.ctl' from '/home/oracle/app/oracle/controlfile_copy/ORCL/backupset/2012_11_09/o1_mf_ncnnf_TAG20121109T062908_89t4sp41_.bkp';

Starting restore at 09-11-2012 07:51:43
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 09-11-2012 07:51:46
After the restore process finishes you can find the control file under non_default_location directory
[oracle@localhost non_default_location]$ ll
total 9632
-rw-rw---- 1 oracle oracle 9846784 Nov  9 07:51 control01.ctl
Instance is still not able to go to the next mode because it doesn't know where restored control file is located.
RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/09/2012 07:54:04
ORA-00205: error in identifying control file, check alert log for more info
Use sqlplus to connect the instance ...
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Fri Nov 9 07:54:50 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
... have a look at the control_files initialization parameter written in spfile ...
SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /home/oracle/app/oracle/oradata/orcl/control01.ctl, 
                                                 /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
... and modify it according to your new control file location.
SQL> alter system set control_files='/home/oracle/app/oracle/oradata/orcl/non_default_location/control01.ctl' scope=spfile;

System altered.
Close the instance ...
SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
.. and start it again in MOUNT mode using RMAN.
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Fri Nov 9 07:56:56 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup mount;

Oracle instance started
database mounted

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                364907192 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6008832 bytes
You have to perform a recovery of the database after the restore of the control file, even if any datafile was restored.
RMAN> recover database;

Starting recover at 09-11-2012 07:57:34
Starting implicit crosscheck backup at 09-11-2012 07:57:34
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
Crosschecked 5 objects
Finished implicit crosscheck backup at 09-11-2012 07:57:36

Starting implicit crosscheck copy at 09-11-2012 07:57:36
using channel ORA_DISK_1
Finished implicit crosscheck copy at 09-11-2012 07:57:36

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/backupset/2012_11_07/o1_mf_ncnnf_TAG20121107T223343_89pnl8z3_.bkp.old
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789203952_80ogm1c3_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789209074_80omm3d0_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_10_05/o1_mf_s_795852591_86xq10nr_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_10_05/o1_mf_s_795834324_86x564xb_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_09_26/o1_mf_s_795045371_867q3d12_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_17/o1_mf_s_788864449_80c39jlo_.bkp

using channel ORA_DISK_1
datafile 7 not processed because file is read-only

starting media recovery

archived log for thread 1 with sequence 9 is already on disk as file /home/oracle/app/oracle/oradata/orcl/redo03.log
archived log file name=/home/oracle/app/oracle/oradata/orcl/redo03.log thread=1 sequence=9
media recovery complete, elapsed time: 00:00:13
Finished recover at 09-11-2012 07:57:52
After the restore of the control file you have to open the database with RESETLOGS option.
RMAN> alter database open resetlogs;

database opened
If you want to come back to the original settings because the original location is available again, you have to modify again the control_files initialization parameter value.
SQL> show parameter control_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /home/oracle/app/oracle/oradata/orcl/non_default_location/control01.ctl
Set the control_files parameter to the original configuration:
SQL> alter system set control_files='/home/oracle/app/oracle/oradata/orcl/control01.ctl','/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl' scope=spfile;

System altered.
Close your instance
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Copy your current control file to the original locations:
[oracle@localhost non_default_location]$ pwd
/home/oracle/app/oracle/oradata/orcl/non_default_location
[oracle@localhost non_default_location]$ ll
total 9632
-rw-rw---- 1 oracle oracle 9846784 Nov  9 08:01 control01.ctl
[oracle@localhost non_default_location]$ cp control01.ctl /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
[oracle@localhost non_default_location]$ cp control01.ctl /home/oracle/app/oracle/oradata/orcl/control01.ctl
Connect to the instance...
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Fri Nov 9 08:07:28 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.
... and start it
SQL> startup
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             369101496 bytes
Database Buffers           79691776 bytes
Redo Buffers                6008832 bytes
Database mounted.
Database opened.

SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /home/oracle/app/oracle/oradata/orcl/control01.ctl,                                                
                                                 /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
That's all.

Saturday, November 10, 2012

How to restore from a loss of all current control files to a non default location using autobackup

Like the previous scenario the following one simulates again a database losing all the control files, but they will be restored using the autobackup to a non-default location.
As already stated in the mentioned previous post when losing all current control files you are only able to open your database in NOMOUNT mode.

Also remember that "when you lose all (or one) control files and restore them (or one of them) from a backup control file, you have to perform a recovery of your database and open it with the RESETLOGS option, even if any datafile is restored (like in this scenario).
Anyway a control file restored from a backup has an SCN taken at that "remote" time, different compared with those currently available in the datafiles and redo logs and so they have to be resynchronized.
Generally speaking, having the instance in NOMOUNT mode means your control files are still not accessed (if available), so RMAN is not able to know how to find information about an unidentified database: DBID indeed is contained into the control file.
If you are using a flash recovery area or a recovery catalog (best practice's solution) then you don't have to set the DBID before executing the RESTORE command of your NOMOUNTED instance, saving time and avoiding extra manual steps always prone to error."

Let's start.

The instance is not running.
[oracle@localhost ORCL]$ ps -ef|grep smon
oracle   12901  2820  0 07:24 pts/1    00:00:00 grep smon
Let's simulate the loss of all current control files.
[oracle@localhost orcl]$ rm /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl /home/oracle/app/oracle/oradata/orcl/control01.ctl
In my future non default location there still isn't any file.
[oracle@localhost non_default_location]$ pwd
/home/oracle/app/oracle/oradata/orcl/non_default_location
[oracle@localhost non_default_location]$ ll
total 0
Connect through RMAN and...
[oracle@localhost orcl]$ rman target /

Recovery Manager: Release 11.2.0.2.0 - Production on Mon Jul 23 07:27:53 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)
... start the instance in nomount mode
RMAN> startup nomount;

Oracle instance started

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                364907192 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6008832 bytes
Execute the following command to restore the autoback control file copy to a different location compared to the originals.
RMAN> restore controlfile to '/home/oracle/app/oracle/oradata/orcl/non_default_location/control01.ctl' from autobackup;

Starting restore at 23-07-2012 07:30:26
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

recovery area destination: /home/oracle/app/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: AUTOBACKUP /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789209074_80omm3d0_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789209074_80omm3d0_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
Finished restore at 23-07-2012 07:30:29
After the execution of restore command you can find a control file under the specified location
[oracle@localhost non_default_location]$ ll
total 9536
-rw-rw---- 1 oracle oracle 9748480 Jul 23 07:30 control01.ctl
Is it possible to mount the database ? No, of course.
RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 07/23/2012 07:34:00
ORA-00205: error in identifying control file, check alert log for more info
You have to modify at least the control_files parameter and set the location of the new available control file.
[oracle@localhost non_default_location]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Mon Jul 23 07:35:29 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter system set control_files='/home/oracle/app/oracle/oradata/orcl/non_default_location/control01.ctl' scope=spfile;

System altered.

Shutdown the instance.
SQL> shutdown immediate;
ORA-01507: database not mounted

ORACLE instance shut down.
Connect the instance with RMAN and start it in mount mode
[oracle@localhost orcl]$ rman target /

RMAN> startup mount;

Oracle instance started
database mounted

Total System Global Area     456146944 bytes

Fixed Size                     1344840 bytes
Variable Size                364907192 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6008832 bytes
Issue the recover command for the whole database...
RMAN> recover database;

Starting recover at 23-07-2012 07:38:49
Starting implicit crosscheck backup at 23-07-2012 07:38:49
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 23-07-2012 07:38:51

Starting implicit crosscheck copy at 23-07-2012 07:38:51
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 23-07-2012 07:38:52

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789203952_80ogm1c3_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_21/o1_mf_s_789209074_80omm3d0_.bkp
File Name: /home/oracle/app/oracle/flash_recovery_area/ORCL/autobackup/2012_07_17/o1_mf_s_788864449_80c39jlo_.bkp

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /home/oracle/app/oracle/oradata/orcl/redo01.log
archived log file name=/home/oracle/app/oracle/oradata/orcl/redo01.log thread=1 sequence=1
media recovery complete, elapsed time: 00:00:01
Finished recover at 23-07-2012 07:38:54
...and, as already stated, open it with the RESETLOGS option.
RMAN> alter database open resetlogs;

database opened
Now if your original location become available again, you may want to configure the control_files parameter to the original value.
SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /home/oracle/app/oracle/oradata/orcl/non_default_location/control01.ctl
SQL> alter system set control_files='/home/oracle/app/oracle/oradata/orcl/control01.ctl','/home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl' scope=spfile;

System altered.
Close the instance...
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
...and copy the only available control file to the original locations.
[oracle@localhost non_default_location]$ pwd
/home/oracle/app/oracle/oradata/orcl/non_default_location
[oracle@localhost non_default_location]$ ll
total 9536
-rw-rw---- 1 oracle oracle 9748480 Jul 23 07:30 control01.ctl
[oracle@localhost non_default_location]$ cp control01.ctl /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
[oracle@localhost non_default_location]$ cp control01.ctl /home/oracle/app/oracle/oradata/orcl/control01.ctl
Connect to the instance and start it once again.
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Mon Jul 23 07:40:13 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  456146944 bytes
Fixed Size                  1344840 bytes
Variable Size             369101496 bytes
Database Buffers           79691776 bytes
Redo Buffers                6008832 bytes
Database mounted.
Database opened.
The instance is available, the database is in OPEN mode and ready to be used with control_files parameter modified.
SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /home/oracle/app/oracle/oradata/orcl/control01.ctl, /home/oracle/app/oracle/flash_recovery_area/orcl/control02.ctl
That's all.