Oracle maintains control file Controlfile related scripts (backup and recovery of control files)
-- 1- Two backup methods of control files
-- 1.1 System command ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak'; backup control file
-- the backup control file is the control file data at the historical point, and will not follow the server Update the control file, so you cannot use the control file to restore the database, otherwise the data will be lost
SQL> ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak'; Database altered.
-- Backup information recorded in the Alert alert file
alert_ora11g.log
Fri Apr 08 01:03:41 2016 ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak' Completed: ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak' Fri Apr 08 01:04:37 2016 ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak201604080104' Completed: ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak201604080104' Fri Apr 08 01:09:53 2016
-- 1.2 Back up the control file to the TRACE file directory, first enable the SQL_TRACE parameter at the session level, and then view the TRACE file information
SQL> ALTER SESSION SET SQL_TRACE = TRUE; Session altered.
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE; Database altered.
SQL> SHOW PARAMETER USER_DUMP_DEST; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ user_dump_dest string /home/oracle/product/diag/rdbm s/ora11g/ora11g/trace SQL>
-- Backup information recorded in the Alert alert file
ALTER DATABASE BACKUP CONTROLFILE TO TRACE Backup controlfile written to trace file /home/oracle/product/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_3791.trc Completed: ALTER DATABASE BACKUP CONTROLFILE TO TRACE
-- Track the backup information in the file ora11g_ora_3791.trc
-- 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 "ORA11G" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/home/oracle/product/oradata/ora11g/redo01.log' SIZE 50M BLOCKSIZE 512, GROUP 2 '/home/oracle/product/oradata/ora11g/redo02.log' SIZE 50M BLOCKSIZE 512, GROUP 3 '/home/oracle/product/oradata/ora11g/redo03.log' SIZE 50M BLOCKSIZE 512 -- STANDBY LOGFILE DATAFILE '/home/oracle/product/oradata/ora11g/system01.dbf', '/home/oracle/product/oradata/ora11g/sysaux01.dbf', '/home/oracle/product/oradata/ora11g/undotbs01.dbf', '/home/oracle/product/oradata/ora11g/users01.dbf', '/home/oracle/product/oradata/ora11g/TRADE.dbf' CHARACTER SET ZHS16GBK ;
-- 2- Recovery of the control file (cold backup method)
-- 2.1 Copy the control file backed up by the ALTER DATABASE BACKUP CONTROLFILE TO '/home/oracle/backup/controlfile/control.ctl.bak'; command to the target path And rename it to the lost or damaged control file
-- 2.2 Start the database to the mount state
SQL> STARTUP MOUNT
-- 2.3 Use the backup control file to open the database
SQL> ALTER DATABASE OPEN USING BACKUP CONTROLFILE;
-- 3- Recovery of the control file (TRACE Backup method)
-- 3.1 Write a script to rebuild the control file according to the corresponding TRACE file, the content of the script is as follows:
STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "ORA11G" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/home/oracle/product/oradata/ora11g/redo01.log' SIZE 50M BLOCKSIZE 512, GROUP 2 '/home/oracle/product/oradata/ora11g/redo02.log' SIZE 50M BLOCKSIZE 512, GROUP 3 '/home/oracle/product/oradata/ora11g/redo03.log' SIZE 50M BLOCKSIZE 512 -- STANDBY LOGFILE DATAFILE '/home/oracle/product/oradata/ora11g/system01.dbf', '/home/oracle/product/oradata/ora11g/sysaux01.dbf', '/home/oracle/product/oradata/ora11g/undotbs01.dbf', '/home/oracle/product/oradata/ora11g/users01.dbf', '/home/oracle/product/oradata/ora11g/TRADE.dbf' CHARACTER SET ZHS16GBK ; RECOVER DATABASE ALTER SYSTEM ARCHIVE LOG ALL; ALTER DATABASE OPEN; ALTER TABLESPACE TEMP ADD TEMPFILE '/home/oracle/product/oradata/ora11g/temp02.dbf' SIZE 411043040 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;