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.

13 comments:

Anonymous said...

Thanks for the good writeup. It actually was a amusement
account it. Glance complicated to more added agreeable
from you! By the way, how could we be in contact?
Here is my site Diets that work

Anonymous said...

Does your blog have a contact page? I'm having trouble locating it but, I'd like to send you an e-mail.
I've got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it expand over time.

Also visit my web site bankruptcy Florida

Anonymous said...

I'm really enjoying the theme/design of your website. Do you ever run into any browser compatibility problems? A number of my blog readers have complained about my site not operating correctly in Explorer but looks great in Firefox. Do you have any recommendations to help fix this problem?

Have a look at my page - calories burned Walking

Anonymous said...

No matter if some one searches for his required thing, thus he/she wishes to be available
that in detail, therefore that thing is maintained over here.


Here is my blog post: http://www.teenpornpost.com

Anonymous said...

Excellent blog here! Additionally your web site lots
up fast! What host are you the use of? Can I get your associate link
for your host? I wish my website loaded up as quickly as yours
lol

Feel free to surf to my website ... teenpornpost.com

Anonymous said...

These are truly fantastic ideas in about blogging. You have touched some fastidious points here.
Any way keep up wrinting.

My blog www.farwest.org

Anonymous said...

Youг style is ѕo unique іn comparisоn to other peοple
Ι've read stuff from. Thanks for posting when you'νe got the opрortunity, Guess І wіll just bοok marκ thіs blog.


my webpagе; herbal incense bags

Anonymous said...

I enjoy whаt yοu guys are usually uρ tоo.
Suсh cleveг ωork and reporting! Keep uρ the fantastic woгkѕ guyѕ Ӏ've added you guys to my own blogroll.

Here is my blog post ... tyrosine kinase inhibitor ()

Anonymous said...

I alwауs spent my half аn hour to гead this ωebρagе's articles daily along with a mug of coffee.

Look at my blog - free legal highs

Anonymous said...

Thanks for your personal marvelous posting! I actually enjoyed reading it,
you could be a great author.I will be sure to bookmark your blog and will come back someday.
I want to encourage you to continue your great posts,
have a nice evening!

Visit my web blog: legal ecstasy **

Anonymous said...

I like reading through an article that will
make men and women think. Also, many thanks for allowing for me to
comment!

Also visit my website ... mouse click the next page

Anonymous said...

http://www.maotai1919.com/bbs/forum.php?mod=viewthread&tid=196542&extra=
http://www.dftzpx.net/bbs/forum.php?mod=viewthread&tid=86973&extra=
http://viihdeforuumi.foorumi.org/viewtopic.php?f=2&t=22944
http://www.in0798.com/viewthread.php?tid=30523&extra=
http://www.forum.fastcars.pl/viewtopic.php?pid=10757#p10757
http://forum.flashlady.ru/viewtopic.php?f=2&t=54818
http://www.xikecn.com/bbs/forum.php?mod=viewthread&tid=225033&extra=
http://www.mdc168.com/bbs/forum.php?mod=viewthread&tid=71023&extra=
http://forum.kiel.ru/viewtopic.php?f=4&t=133173
http://lshnba.com/viewthread.php?tid=603169&extra=

Anonymous said...

http://7seas.su/forum/viewtopic.php?f=2&t=513547
http://horolezci.cz/forum/viewtopic.php?TopicID=112156
http://mtvtrunk.com/malay/forum.php?mod=viewthread&tid=1371840&extra=
http://forum.banmeel.com/viewtopic.php?f=44&t=10302
http://www.xinyashu.com/forum.php?mod=viewthread&tid=202872&extra=
http://www.eternallifechurchthailand.org/elcboard/viewthread.php?tid=454113&extra=
ires%20involving%20forethought%20and%20scheduling%20so%20that%20one%20not%20regret%20newer.%20And%20the%20money%20you%20spend%20doesn%5C%27t%20even%20guarantee%20that%20you%5C%27ll%20be%20satisfied%20with%20the%20results.%20Truthfully%2C%20no%20one%20can%20make%20your%20website%20the%20way%20you%20want%20it.%0D%0A%20%0D%0Ahttp%3A%2F%2Fcheapmkoutletuk.webeden.co.uk%0D%0A%20Permit%20me%20introduce%20to%20you%20a%20pair%20of%20stylish%20shoes%20to%20make%20you%20far%20more%20fashional.%20Complex%20hand%20embroidery%20and%20brilliant%20hues%20increase%20an%20exotic%20touch%20to%20the%20woman%20system%2C%20one%20particular%20of%20our%20most%20beloved%20styles.%20If%20you%20have%20any%20concerns%20about%20your%20own%20health%20or%20the%20health%20of%20your%20child%2C%20you%20should%20always%20consult%20with%20a%20physician%20or%20other%20healthcare%20professional.%0D%0A%20%0D%0A%5Burl%3Dhttp%3A%2F%2Fshopairmaxuk.webeden.co.uk%5DNike%20Air%20Max%20Sale%5B%2Furl%5D%0D%0A%20For%20adolescent%20girls%2C%20but%20to%20cha
http://web0122064.web48.badudns.cc/forum.php?mod=viewthread&tid=114561&extra=
http://www.narkozfan.com/showthread.php?1709-Swift-Methods-Of-cheap-shoes-outlet-Where-To-Go&p=15427#post15427
http://tver-pravda.ru/forum/viewtopic.php?pid=8115#p8115