错误现象:在mount数据库时,会跑出如下错误:ORA-00214: controlfile '/home/oracle/oradata/item/control01.ctl' version 10232896 inconsistent with file
'/home/oracle/oradata/item/control02.ctl' version 9190433
下面总结一下处理过程: 尝试1:三个控制文件中若有一个控制文件的SCN是与数据文件的SCN保持一致,即可以正常将数据库启动,此时,只需要将其他两个文件从Oracle的初始化参数文件中的设定中移除即可。
[oracle@spreader oracle]$ sqlplus /nolog
[uniread] Loaded history (2158 lines)
SQL*Plus: Release 10.1.0.2.0 - Production on Mon Feb 27 11:37:09 2006
Copyright (c) 1982, 2004, Oracle. All rights reserved. SQL> connect / as sysdba
SQL> startup mount
ORACLE instance started.
Total System Global Area 188743680 bytes
Fixed Size 778036 bytes
Variable Size 162275532 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
ORA-00214: controlfile '/home/oracle/oradata/item/control01.ctl' version 10232896 inconsistent with file
'/home/oracle/oradata/item/control02.ctl' version 9190433
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning and Data Mining options
[uniread] Saved history (2163 lines)
SQL> create pfile='/home/oracle/init.ora' from spfile;
File created.
编辑init.ora,把'/home/oracle/oradata/item/control02.ctl'去掉,然后再重启数据库
[oracle@spreader oracle]$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance.
SQL> create spfile from pfile='/home/oracle/init.ora';
SQL> startup nomount
ORACLE instance started.
Total System Global Area 188743680 bytes
Fixed Size 778036 bytes
Variable Size 162275532 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00214: controlfile '/home/oracle/oradata/item/control01.ctl' version 10232896 inconsistent with file
'/home/oracle/oradata/item/control03.ctl' version 9190433
再编辑init.ora,把'/home/oracle/oradata/item/control03.ctl'去掉,然后再按照上面步骤重启数据库
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 188743680 bytes
Fixed Size 778036 bytes
Variable Size 162275532 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00227: corrupt block detected in controlfile: (block 175, # blocks 1)
ORA-00202: controlfile: '/home/oracle/oradata/item/control01.ctl'
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01507: database not mounted
唯一的控制文件都有问题了,重新编辑init.ora文件,去掉控制文件一,而留下控制文件二和三,然后再重启数据库 尝试二:如果三个控制文件的SCN都与数据文件不一致了,在上面的尝试中,选择一个可以正常mount的控制文件,然后尝试打开数据库,结果抛出如下错误(此时,可选择其他其他两个文件尝试):
ORA-01207: file is more recent than control file - old control file
尝试recover database using backup controlfile;也会抛出上述错误;
出现这个错误的意思是控制文件比数据文件的版本旧,也即数据文件中的SCN比控制文件中的SCN高;(原因请参考文章开头)。
尝试三:出现上述错误时,可以尝试通过recover database;命令来恢复数据库,使得控制文件和数据文件的SCN恢复到一致。但是oracle抛出如下错误:
SQL> RECOVER DATABASE;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done
再尝试用recover database using backup controlfile to cancel;命令来恢复,可尝试指定在线日志文件的方式,具体方法参考下面。;
一旦恢复成功,则可以通过open resetlogs的方式打开数据库。
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
SQL> alter database open resetlogs;
数据库已更改。 到这里,由停电导致的数据库突然中断,从而引起的控制文件不一致的问题,已经全部解决了。 由于重新用resetlogs打开了数据库,所以必须在第一时间对数据库做一次完全备份。