操作系统: Linux RH6
数据库: Oracle 11gR2
案例分析:
Oracle数据库中所有的控制文件被意外破坏,非归档的库,在有trace备份的情况下,重建控制文件。
1、控制文件trace脚本
[oracle@rh6 ~]$ cat crctr.sql
CREATE CONTROLFILE REUSE DATABASE "TEST3" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 10
MAXLOGMEMBERS 5
MAXDATAFILES 300
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/test3/redo01a.log' SIZE 100M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/test3/redo02a.log' SIZE 100M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/test3/system01.dbf',
'/u01/app/oracle/oradata/test3/sysaux01.dbf',
'/u01/app/oracle/oradata/test3/undotbs01.dbf',
'/u01/app/oracle/oradata/test3/users01.dbf'
CHARACTER SET ZHS16GBK;
2、启动Instance到nomount,重建controlfile
10:59:05 SYS@ test3 >startup nomount;
ORACLE instance started.
Total System Global Area 313860096 bytes
Fixed Size 1336232 bytes
Variable Size 213912664 bytes
Database Buffers 92274688 bytes
Redo Buffers 6336512 bytes
10:59:41 SYS@ test3 >@/home/oracle/crctr.sql
Control file created.
3、告警日志
......
CREATE CONTROLFILE REUSE DATABASE "TEST3" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 10
MAXLOGMEMBERS 5
MAXDATAFILES 300
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/test3/redo01a.log' SIZE 100M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/test3/redo02a.log' SIZE 100M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/test3/system01.dbf',
'/u01/app/oracle/oradata/test3/sysaux01.dbf',
'/u01/app/oracle/oradata/test3/undotbs01.dbf',
'/u01/app/oracle/oradata/test3/users01.dbf'
CHARACTER SET ZHS16GBK
WARNING: Default Temporary Tablespace not specified in CREATE DATABASE command
Default Temporary Tablespace will be necessary for a locally managed database in future release
Wed Jan 07 11:00:02 2015
Successful mount of redo thread 1, with mount id 991126251
Completed: CREATE CONTROLFILE REUSE DATABASE "TEST3" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 10
MAXLOGMEMBERS 5
MAXDATAFILES 300
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/test3/redo01a.log' SIZE 100M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/test3/redo02a.log' SIZE 100M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/test3/system01.dbf',
'/u01/app/oracle/oradata/test3/sysaux01.dbf',
'/u01/app/oracle/oradata/test3/undotbs01.dbf',
'/u01/app/oracle/oradata/test3/users01.dbf'
CHARACTER SET ZHS16GBK
Wed Jan 07 11:00:59 2015
......
3、查看数据库状态
11:00:03 SYS@ test3 >select status from v$instance;
STATUS
------------
MOUNTED
11:00:27 SYS@ test3 >select file#,name ,checkpoint_change# from v$datafile;
FILE# NAME CHECKPOINT_CHANGE#
---------- -------------------------------------------------- ------------------
1 /u01/app/oracle/oradata/test3/system01.dbf 333365
2 /u01/app/oracle/oradata/test3/sysaux01.dbf 333365
3 /u01/app/oracle/oradata/test3/undotbs01.dbf 333365
4 /u01/app/oracle/oradata/test3/users01.dbf 333365
11:00:46 SYS@ test3 >select file#,name ,checkpoint_change# from v$datafile_header;
FILE# NAME CHECKPOINT_CHANGE#
---------- -------------------------------------------------- ------------------
1 /u01/app/oracle/oradata/test3/system01.dbf 333365
2 /u01/app/oracle/oradata/test3/sysaux01.dbf 333365
3 /u01/app/oracle/oradata/test3/undotbs01.dbf 333365
4 /u01/app/oracle/oradata/test3/users01.dbf 333365
4、打开数据库