[Translated from mos] How To restore database and mosrestore when backup of control files is lost

Source: Internet
Author: User

[Translated from mos] How To restore database and mosrestore when backup of control files is lost

How can I restore the database when the backup of the control file is lost?

Source:
How to restore database when controlfile backup missing (Doc ID 1438776.1)

Applicable:

Oracle Database-Enterprise Edition-Version 9.2.0.1 to 11.2.0.3 [Release 9.2 to 11.2]
Information in this document applies to any platform.
* ** Checked for relevance on 23-Sep-2013 ***

Objectives:
This article is helpful in the following situations: Except for controlling that the file backup does not exist, all other backups exist. In this case, the database restore.

Solution:
An example is provided.
1. view the current database structure:

RMAN> report schema;using target database control file instead of recovery catalogReport of database schemaList of Permanent Datafiles===========================File Size(MB) Tablespace RB segs Datafile Name---- -------- -------------------- ------- ------------------------1 510 SYSTEM *** +DATA/ora102/datafile/system.257.7751266032 595 UNDOTBS1 *** +DATA/ora102/datafile/undotbs1.256.7751265613 250 SYSAUX *** +DATA/ora102/datafile/sysaux.258.7751266374 28 USERS *** +DATA/ora102/datafile/users.259.7751266535 50 USERS *** +DATA/ora102/datafile/users.262.776000421List of Temporary Files=======================File Size(MB) Tablespace Maxsize(MB) Tempfile Name---- -------- -------------------- ----------- --------------------1 29 TEMP 32767 /u01/app/oracle/oradata/ora102/ORA102/datafile/o1_mf_temp_7lqq1qko_.tmpRMAN> exitRecovery Manager complete

 

2. Create a dummy instance/can use existing database to extract datafile 1 from backup piece and restore datafile 1 from backup piece

SQL> DECLARE  devtype varchar2(256);  done boolean;  BEGIN  devtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');  dbms_backup_restore.RestoreSetDatafile;  dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/u03/datafile1.dbf');  dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/u03/backup/2cn5blrn_1_1', params => null);  dbms_backup_restore.DeviceDeallocate; END;/


 

3. Create a control file when datafile 1 is included:

SQL>!cat /u03/1.ctlCREATE CONTROLFILE REUSE DATABASE "ORA102" NORESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_1_7lqq1m62_.log' SIZE 50M,GROUP 2 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_2_7lqq1myr_.log' SIZE 50M,GROUP 3 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_3_7lqq1nr0_.log' SIZE 50MDATAFILE'/u03/datafile1.dbf'CHARACTER SET WE8ISO8859P1;SQL> @/u03/1.ctlControl file created.SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/u03/datafile1.dbfSQL> exitDisconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

 

4. All backuppiece of catalog

[oracle@oel57 ~]$ rman target /Recovery Manager: Release 10.2.0.5.0 - Production on Thu Mar 8 11:55:58 2012Copyright (c) 1982, 2007, Oracle. All rights reserved.connected to target database: ORA102 (DBID=396070408, not open)RMAN> catalog start with '/u03/backup/' noprompt;using target database control file instead of recovery catalogsearching for all files that match the pattern /u03/backup/List of Files Unknown to the Database=====================================File Name: /u03/backup/28n5bki6_1_1File Name: /u03/backup/ORA1122-backup-080312.logFile Name: /u03/backup/2dn5blsq_1_1File Name: /u03/backup/2cn5blrn_1_1File Name: /u03/backup/ora102-080312.logFile Name: /u03/backup/27n5bkd0_1_1cataloging files...cataloging doneList of Cataloged Files=======================File Name: /u03/backup/2dn5blsq_1_1File Name: /u03/backup/2cn5blrn_1_1List of Files Which Where Not Cataloged=======================================File Name: /u03/backup/28n5bki6_1_1RMAN-07518: Reason: Foreign database file DBID: 2353175563 Database Name: ORA1122File Name: /u03/backup/ORA1122-backup-080312.logRMAN-07517: Reason: The file header is corruptedFile Name: /u03/backup/ora102-080312.logRMAN-07517: Reason: The file header is corruptedFile Name: /u03/backup/27n5bkd0_1_1RMAN-07518: Reason: Foreign database file DBID: 2353175563 Database Name: ORA1122RMAN> list backup;using target database control file instead of recovery catalogList of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------1 Full 1.05M DISK 00:00:00 08-MAR-12BP Key: 1 Status: AVAILABLE Compressed: YES Tag: TAG20120308T101415Piece Name: /u03/backup/2dn5blsq_1_1Control File Included: Ckp SCN: 1320981 Ckp time: 08-MAR-12SPFILE Included: Modification time: 08-MAR-12BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------2 Full 107.40M DISK 00:00:00 08-MAR-12BP Key: 2 Status: AVAILABLE Compressed: YES Tag: TAG20120308T101415Piece Name: /u03/backup/2cn5blrn_1_1List of Datafiles in backup set 2File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Full 1320981 08-MAR-12 +DATA/ora102/datafile/system.257.7751266032 Full 1320981 08-MAR-123 Full 1320981 08-MAR-124 Full 1320981 08-MAR-125 Full 1320981 08-MAR-12RMAN>

5. Use dbms_backup_restore package to restore datafile. Note: The datafile name is not important, as long as it is a unique name for the datafile to be restored.

SQL>  -- use scriptDECLARE  devtype varchar2(256);  done boolean;BEGIN  devtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');  dbms_backup_restore.RestoreSetDatafile;  dbms_backup_restore.RestoreDatafileTo(dfnumber => 4,toname => '/u03/datafile4.dbf');  dbms_backup_restore.RestoreDatafileTo(dfnumber => 2,toname => '/u03/datafile2.dbf');  dbms_backup_restore.RestoreDatafileTo(dfnumber => 3,toname => '/u03/datafile3.dbf');  dbms_backup_restore.RestoreDatafileTo(dfnumber => 5,toname => '/u03/datafile5.dbf');  dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/u03/datafile1.dbf');  dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/u03/backup/2cn5blrn_1_1', params => null);  dbms_backup_restore.DeviceDeallocate;END;/PL/SQL procedure successfully completed.


 

Metadata display only datafile 1. Do I need to re-create the control file to carry all the datafiles to be restored?

SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------+DATA/ora102/datafile/system.257.775126603SQL> shutdown immediate; <ORA-01109: database not openDatabase dismounted.ORACLE instance shut down.SQL> startup nomount;ORACLE instance started.Total System Global Area 209715200 bytesFixed Size 1272864 bytesVariable Size 142607328 bytesDatabase Buffers 58720256 bytesRedo Buffers 7114752 bytesSQL>!cat /u03/1.ctlCREATE CONTROLFILE REUSE DATABASE "ORA102" NORESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_1_7lqq1m62_.log' SIZE 50M,GROUP 2 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_2_7lqq1myr_.log' SIZE 50M,GROUP 3 '/u01/app/oracle/oradata/ora102/ORA102/onlinelog/o1_mf_3_7lqq1nr0_.log' SIZE 50MDATAFILE'/u03/datafile1.dbf','/u03/datafile4.dbf','/u03/datafile2.dbf','/u03/datafile3.dbf','/u03/datafile5.dbf'CHARACTER SET WE8ISO8859P1;SQL> @/u03/1.ctlControl file created.SQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/u03/datafile1.dbf/u03/datafile2.dbf/u03/datafile3.dbf/u03/datafile4.dbf/u03/datafile5.dbf

6. If this backup is not a cold backup, we need to recover the database. We need catalog including archivelog's backuppiece, restore archivelog, and then

SQL> recover database until cancel;Media recovery complete.SQL> alter database open resetlogs;Database altered.SQL>

7. Once the database is in a consistent state, we can use resetlogs to open the database.

SQL>alter database open resetlogs;Database altered.SQL>


Note:
In the case of multisection backup, we need to consider all backuppiece (that is, all sections) and use the initmsr function to restore datafile.

DECLAREdevtype varchar2(256);done boolean;BEGINdevtype := dbms_backup_restore.DeviceAllocate(type=>null, ident=>'d1');   dbms_backup_restore.RestoreSetDatafile;dbms_backup_restore.initmsr(1,'/ud1001/PROD/oradata/system01-test.dbf');dbms_backup_restore.RestoreDatafileTo(dfnumber => 1,toname => '/ud1001/PROD/oradata/system01-test.dbf');dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/backup/Oracle-DB-8-7-2014/db_L0_PROD_e6pf7too_1_1.rman', params => null);dbms_backup_restore.RestoreBackupPiece(done => done,handle =>'/backup/Oracle-DB-8-7-2014/db_L0_PROD_e6pf7too_2_1.rman', params => null);END;/ 



 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.