原文地址:通过 trace文件 备份控制文件controlfile 作者:laigq
备份控制文件及恢复
通过 trace 文件备份 控制文件
SQL> alter database backup controlfile to trace;
在 $ORACLE_BASE/admin/$ORACLE_SID/udump 目录下,生成的新的 trace 文件里有 生成控制文件的脚本
$su - oracle
$cd $ORACLE_BASE/admin/$ORACLE_SID/udump
$ls -l //查看最新的trc文件,可以发现控制文件的备份新在里面
-----------------------------------
-- Set #2. RESETLOGS 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.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- 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 "STUDY" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oracle/oradata/study/redo01.log' SIZE 50M,
GROUP 2 '/oracle/oradata/study/redo02.log' SIZE 50M,
GROUP 3 '/oracle/oradata/study/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/oracle/oradata/study/system01.dbf',
'/oracle/oradata/study/undotbs01.dbf',
'/oracle/oradata/study/sysaux01.dbf',
'/oracle/oradata/study/users01.dbf',
'/oracle/oradata/study/studydata1.bdf',
'/oracle/oradata/study/studydata2.bdf'
CHARACTER SET AL32UTF8
;
-- 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 '/oracle/flash_recovery_area/STUDY/archivelog/2009_12_16/o1_mf_1_1_%u_.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/oradata/study/temp01.dbf'
SIZE 28311552 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
注意: 里面已经包含 重建控制文件的脚本文件及相关步骤。在丢失控制文件时,可以通过该脚本进行恢复