ITPub博客

首页 > 数据库 > Oracle > oracle 控制文件的修复小结

oracle 控制文件的修复小结

原创 Oracle 作者:贺子_DBA时代 时间:2014-08-12 23:29:15 0 删除 编辑

1控制文件版本不一致
SYS@ENMOEDU> show parameter control 

NAME TYPE VALUE 
------------------------------------ ----------- ------------------------------ 
control_file_record_keep_time integer 7 
control_files string /u01/app/oracle/oradata/ENMOED 
U/control01.ctl, /u01/app/orac 
le/fast_recovery_area/ENMOEDU/ 
control02.ctl, /u01/app/oracle 
/fast_recovery_area/ENMOEDU/co 
ntrol04.ctl
[oracle@ENMOEDU trace]$ cd /u01/app/oracle/oradata/ENMOEDU/ 
[oracle@ENMOEDU ENMOEDU]$ ls 
control01.ctl example01.dbf redo01.log redo03.log redo05.log sysaux01.dbf temp01.dbf ts_lob01.dbf users01.dbf 
control04.ctl LL redo02.log redo04.log redo06.log system01.dbf ts_idx01.dbf undotbs01.dbf
[oracle@ENMOEDU ENMOEDU]$ cp  control01.ctl   control01.ctlbk                       #复制一份
[oracle@ENMOEDU ENMOEDU]$  sqlplus  /  as sysdba 

SQL*Plus: Release 11.2.0.3.0 Production on Tue Aug 12 22:46:41 2014 

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


Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

SYS@ENMOEDU> alter system checkpoint;                          #CKPT进程会更新控制文件的scn

System altered. 
[oracle@ENMOEDU ENMOEDU]$ rm control01.ctl 
[oracle@ENMOEDU ENMOEDU]$ mv control01.ctlbk control01.ctl
再次执行检查点,执行正常(虽然是完全检查点,但Oracle实际上是并未真正同步scn,还在排队中)但是你创建表空间也会也会改变控制文件,这是就会报错,此时   sqlplus已经断开连接,数据库down 了下来,
SYS@ENMOEDU> create tablespace th_control datafile 'u01/app/oracle/oradata/ENMOEDU/th_control.dbf' size 10m; 
create tablespace th_control datafile 'u01/app/oracle/oradata/ENMOEDU/th_control.dbf' size 10m 
* 
ERROR at line 1: 
ORA-03135: connection lost contact 
Process ID: 8722 
Session ID: 16 Serial number: 65 
SYS@ENMOEDU> startup                                                #控制文件不一致,导致不能起数据库
ORACLE instance started. 

Total System Global Area 422670336 bytes 
Fixed Size 1345380 bytes 
Variable Size 343935132 bytes 
Database Buffers 71303168 bytes 
Redo Buffers 6086656 bytes 
ORA-00214: control file 
'/u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl' version 1674 
inconsistent with file '/u01/app/oracle/oradata/ENMOEDU/control01.ctl' version 
1672
将那个不一致的旧版本控制文件删掉,从新的那拷一份
[oracle@ENMOEDU ENMOEDU]$ rm control01.ctl
[oracle@ENMOEDU ENMOEDU]$ cp control02.ctl       /u01/app/oracle/oradata/ENMOEDU/control01.ctl
这时候就可以起来了
  SYS@ENMOEDU> alter database mount; 
Database altered.
SYS@ENMOEDU> alter database open;
Database altered.
2.控制文件丢失;我们知道控制文件存储着数据库的结构信息,所以当数据库新建表空间时,就会更新控制文件,如果丢失就会报错;
[oracle@ENMOEDU ENMOEDU]$ ls 
archivelog autobackup backupset control02.ctl control04.ctl 
[oracle@ENMOEDU ENMOEDU]$ rm control02.ctl 
[oracle@ENMOEDU ENMOEDU]$ ls 
archivelog autobackup backupset control04.ctl
SYS@ENMOEDU> create tablespace ts_control datafile '/u01/app/oracle/ts_control.dbf' size 10m; 
create tablespace ts_control datafile '/u01/app/oracle/ts_control.dbf' size 10m 
* 
ERROR at line 1: 
ORA-00210: cannot open the specified control file 
ORA-00202: control file: 
'/u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl' 
ORA-27041: unable to open file 
Linux Error: 2: No such file or directory 
Additional information: 3 
  SYS@ENMOEDU> shutdown immediate;                            #提示控制文件不存在,无法一致性关闭
ORA-00210: cannot open the specified control file

ORA-00202: control file: '/u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl'

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3
拷贝一份好的就可以了      
SYS@ENMOEDU> shut abort 
ORACLE instance shut down. 
SYS@ENMOEDU> host 
[oracle@ENMOEDU ENMOEDU]$ ls 
archivelog autobackup backupset control04.ctl 
[oracle@ENMOEDU ENMOEDU]$ cp control04.ctl control02.ctl 
[oracle@ENMOEDU ENMOEDU]$ sqlplus / as sysdba 

SQL*Plus: Release 11.2.0.3.0 Production on Tue Aug 12 23:21:04 2014 

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

Connected to an idle instance. 

SYS@ENMOEDU> startup 
ORACLE instance started. 

Total System Global Area 422670336 bytes 
Fixed Size 1345380 bytes 
Variable Size 343935132 bytes 
Database Buffers 71303168 bytes 
Redo Buffers 6086656 bytes 
Database mounted. 
Database opened.
总结:控制文件是一个非常容易解决的问题,只要我们知道了,控制文件是多路复用的,就很好解决这个问题了,通过实验我们还知道了,控制文件的重要性,存储着Oracle数据库的结构信息,号称数据库的大脑,一定要有多个控制文件,一起使用。


















来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29654823/viewspace-1250180/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
10年数据库管理员从业经历,熟悉Oracle、mysql、tidb、oceanbase、redis、 mongodb 、python等技术栈,持有11g ocm 、mysql 5.7 ocp 、tidb 5.0 ptcp、tidb 6.0 ptca、oceanbase obcp等

注册时间:2014-05-12

  • 博文量
    327
  • 访问量
    2148986