Use the trace file to rebuild the control file
1. Generate a trace file:
SQL>alter database backup controlfile to trace;
2. Find the generated trace file:
SQL>show parameter user_dump_dest
The path corresponding to the user_dump_dest file is the path of the trace file
3. Close the database
SQL>shutdown immediate
4. View the trace file (my trace file path is: /u01/app/oracle/diag/rdbms/test/test/trace)
ls -lt /u01/app/oracle/diag/rdbms/test/test/trace |more
View: Instance name_ora number_.trc file
5. Copy the contents of the trace file:
tail -100 /u01/app/oracle/diag/rdbms/test/test/trace/test_ora_7900.trc
The copied content is as follows (starting from STARTUP NOMOUNT in the file to
the content between – Commands to re-create incarnation table):
6. Create a sql script:
create a script in any directory, and paste the copied content in 5 to the script:
$ vi createtcl.sql
$ cat createtcl.sql
CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 20
MAXLOGMEMBERS 3
MAXDATAFILES 200
MAXINSTANCES 8
MAXLOGHISTORY 747
LOGFILE
GROUP 1 '/oracle/oradata/test/redo01.log' SIZE 1024M BLOCKSIZE 512,
GROUP 2 '/oracle/oradata/test/redo02.log' SIZE 1024M BLOCKSIZE 512,
GROUP 3 '/oracle/oradata/test/redo03.log' SIZE 1024M BLOCKSIZE 512,
-- STANDBY LOGFILE
DATAFILE
'/oracle/oradata/test/system01.dbf',
'/oracle/oradata/test/sysaux01.dbf',
'/oracle/oradata/test/undotbs01.dbf',
'/oracle/oradata/test/users01.dbf'
CHARACTER SET AL32UTF8
;
7. Run the created script in nomount state:
$ sqlplus / as sysdba
SQL>startup nomount
SQL> @createtcl.sql
Control file created.
The above script is executed when all archived logs and online logs exist. The control file can get the exact scn and time point from the current log file. The exact scn can also be obtained from the data file as well.
8. Start the database and complete the redo of the control file:
alter database open
Note: If "ORA-01589: must use RESETLOGS or NORESETLOGS option for database open" appears in 8, the
solution: the database is running in the mount state: alter database open resetlogs;
Common errors and handling methods
1. ORA-12720
When using createtcl.sql to create a control file in step 7, the following error may occur:
ORA-01503: CREATE CONTROLFILE failed
ORA-12720: operation requires database is in EXCLUSIVE mode
This may be due to other instances not shutting down in a clustered environment.
The processing method is as follows:
shut down the instances in the remaining nodes in the cluster, and then perform the following operations on the current node instance:
SQL>alter system set cluster_database=FALSE scope=spfile;
SQL>shutdown immediate
SQL>startup nomount;
Execute createtcl.sql again, and the error will not appear.
Reference link:
https://www.cnblogs.com/NextAction/p/7366715.html
https://www.cnblogs.com/51linux/archive/2013/12/31/3499028.html