1. 程式人生 > 其它 >[2020-12-22] oracle 什麼情況下需要重建控制檔案,重建控制檔案方法

[2020-12-22] oracle 什麼情況下需要重建控制檔案,重建控制檔案方法

技術標籤:oraclerecreatecontrolfileoracle

Recreating Database using Current Controlfile (Doc ID 1039149.6)
Problem Description: 
==================== 
 
You want to rebuild an instance with the same configuration as before 
and need to know how you would do it using your current controlfile and 
full_database_export.

Solution Description: 
===================== 
 
This procedure is very useful for someone who wants to recreate  
the database with the same configuration as used previously. 
 
Mandatory elements for the following procedure: 
 
  a.) full_database_export 
  b.) current control file 
  c.) instance can be "MOUNTED" or "OPENED" 
 
 
*** WARNING: Before following this procedure, do full_Database_Export of  
*** the database you want to create.  Before following this bulletin,  
*** cleanly shutdown the databases and take full operating system (OS) level 
*** cold backup. 
 
 
Steps to recreate database using current controlfile: 
 
 
 1. Do full_Database_Export of the database you want to recreate. 
 
    Note: If your database is not using the default character set 
          you may want to add the character set clause to the 
          create database command in step-7. 
 
 2. Shutdown all instances and take full os level system backup. 
 
 3. Startup MOUNT or STARTUP. 
 
 4. Backup controlfile to trace with the following command: 
 
   "alter database backup controlfile to trace;" 
 
   - This will create a trace file (*.trc) in the 
     user_dump_dest location and it will contain all the  
     commands needed to recreate your controlfile. 
 
 5. Copy the trace file (*.trc) from the user_dump_dest to  
   /tmp and call it user.sql 
 
    For Example: cp ../udump/ora_7179.trc /tmp/user.sql 
 
   - This will make it easier to find the script when needed. 
 
 
 6. Delete datafiles, controlfiles, redologs, archive logs for the old 
   database at the os level manually. 
 
 7. Modify user.sql to create database instead of create controlfile.  
 
   The final script to be executed should look like the following example:  
 
   SET ECHO ON 
   CREATE DATABASE "Test" NORESETLOGS NOARCHIVELOG 
       MAXLOGFILES 16 
       MAXLOGMEMBERS 3 
       MAXDATAFILES 30 
       MAXINSTANCES 1 
       MAXLOGHISTORY 100 
   LOGFILE 
     GROUP 1 '/../../../redolog/redolog1.dbf'  SIZE 2M, 
     GROUP 2 '/../../../redolog/redolog2.dbf'  SIZE 2M, 
     GROUP 3 '/../../../redolog/redolog3.dbf'  SIZE 2M 
   DATAFILE 
            '/../../../datafile/system01.dbf' size 50M; 
  
 
   Note: Remember, to only add the system datafile and to remove all other 
         datafiles, because they will be added during the 
         full_database_import. 
 
   Note: Remember to also turn ARCHIVING ON after creating the database 
         and doing full_database_import if the original database was in 
         archivelog mode.  (For Performance it is better to run import  
         in NOARCHIVE LOG Mode). 
  
 8. Startup NOMOUNT 
 
 9. Run /tmp/user.sql  
 
    (i.e., SVRMGRL > @tmp/user.sql) 
 
10. Run $ORACLE_HOME/rdbms/admin/catalog and catproc scripts. 
 
    i.e., 1. (SVRMGRL> @$ORACLE_HOME/rdbms/admin/catalog) 
          2. (SVRMGRL> @$ORACLE_HOME/rdbms/admin/catproc) 
 
11. Create second rollback segment in the system tablespace. 
 
12. Run full_database_import.
After Upgrading Database Error ORA-16433 including RMAN DUPLICATE / RESTORE (Doc ID 1074855.1)To BottomTo Bottom

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.1.0.7 and later
Information in this document applies to any platform.
***Checked for relevance on 27-NOV-2015 ***

SYMPTOMS

NOTE: In the images and/or the document content below, the user information and environment data used represents fictitious data from the
Oracle sample schema(s),
Public Documentation delivered with an Oracle database product or other training material. Any similarity to actual
environments, actual persons, living or dead, is

purely coincidental and not intended in any manner.

For the purposes of this document, the following fictitious environment is used as an example to describe the procedure:

Database Name: PROD,V11P
Disk Group Names: +BACKUP
Directory Names: C:\ORA11G,C:\APP and all sub-directories
Catalog Schema: RMAN


**********

Possible Symptoms:

o Database was upgraded to 11.1.0.7.2

The database shows its in read write mode. ( open )
RMAN Resync catalog failing with errors:


o This problem can be caused by a recreate of the controlfile with resetlogs,
and subsequent failure during the open resetlogs.
That is, if recreating a controlfile with resetlogs option, but if there are any issues
during the open resetlogs, leaving the database in this state reporting
.
ORA-16433: The database has not been opened in read-write mode
.

$ rman catalog rman/<password>@<catalog service> target sys/<password>@<target service>

Recovery Manager: Release 11.1.0.7.0 - Production on Mon Mar 15 10:58:49 2010

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

connected to target database: PROD (DBID=1078444404)
connected to recovery catalog database

RMAN> resync catalog;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of resync command on default channel at 03/15/2010 10:58:56
ORA-16433: The database has not been opened in read-write mode



-Tried to open the database in read only then change it to read write. Same error

-Tried sql> 'alter database backup controlfile to trace' from sqlplus failed with the same error

SQL> alter database backup controlfile to trace;
alter database backup controlfile to trace
*
ERROR at line 1:
ORA-16433: The database has not been opened in read-write mode

CAUSE


Bug 8422605 BACKUP CONTROLFILE TO TRACE GENERATES ORA-16433 AFTER 11.1.0.7
UPGRADE V1110:
Status: 31,Could Not Reproduce.

SOLUTION



1) Recreate the controlfile with NORESETLOGS option.

2) Recover database using this command:

SQL> recover database;

3) Open the database as follows:

SQL> alter database open;

# This will get you out of the read/write problem and allow the database to open

Note:
Since the 'alter database backup controlfile to trace' fail, then the controlfile need to be created from start if you don't have one already.

The following queries can be used to collect the information needed to recreate the controlfile while database is mounted:

SQL> select name from v$datafile order by file#;
SQL> select group#, member from v$logfile;
SQL> select name, bytes from v$tempfile order by file#;


Example of modified controlfile script:

--
-- Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "V11P" NORESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE

*** 2010-03-15 13:12:56.641
GROUP 1 'C:\APP\ORADATA\V11P\REDO01.LOG' SIZE 50M,
GROUP 2 'C:\APP\ORADATA\V11P\REDO02.LOG' SIZE 50M,
GROUP 3 'C:\APP\ORADATA\V11P\REDO03.LOG' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'C:\APP\ORADATA\V11P\SYSTEM01.DBF',
'C:\APP\ORADATA\V11P\SYSAUX01.DBF',
'C:\APP\ORADATA\V11P\UNDOTBS01.DBF',
'C:\APP\ORADATA\V11P\USERS01.DBF'
CHARACTER SET WE8MSWIN1252
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE 'C:\ORA11G\ARCHIVE\V11P\1_1_708426060.ARC';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
-- All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
ALTER DATABASE OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 'C:\APP\ORADATA\V11P\TEMP01.DBF' REUSE;
-- End of tempfile additions.