今天群里有个哥们问我一个关于oracle控制文件的错误,具体见下:
ORA-00205: error in identifying control file, check alert log for more info 遇见过没?
细问得知,其在复用控制文件时出现此错误。
故整理下控制文件的复用方法。
以下是按照该网友描述恢复错误场景:
--查看数据库版本(一时半会没找到什么新的环境,就先凑合用10g了)
SQL> select * from v$version where rownum<5;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
--查看参数文件
SQL> show parameter spfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/10.2.0
/db_1/dbs/spfilenode1.ora
--擦看控制文件参数
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/app/oracle/oradata/node1/
control01.ctl, /u01/app/oracle
/oradata/node1/control02.ctl,
/u01/app/oracle/oradata/node1/
control03.ctl
--创建静态参数文件(以备后用)
SQL> create pfile from spfile;
File created.
SQL> shutdown immediate;--注意,此处可是一致性关闭库的哟。若不是,那就麻烦大了,搞不好就需要用隐含参数将数据库不一致打开,将数据导出来,再重建新库,再导数据进去。
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> !
[oracle@xlong01 ~]$ cp /u01/app/oracle/oradata/node1/control01.ctl /u01/app/oracle/controlfile04.ctl
[oracle@xlong01 ~]$ exit
exit
--启动数据库就发生该网友反映的错误
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 100664912 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
进一步查看日志文件:
[oracle@xlong01 bdump]$ tail alert_node1.log
starting up 1 shared server(s) ...
Sun Apr 8 22:14:39 2012
ALTER DATABASE MOUNT
Sun Apr 8 22:14:42 2012
ORA-00202: control file: '/u01/app/oracle/oradata/node1/control01.ctl, /u01/app/oracle/oradata/node1/control02.ctl,/u01/app/oracle/oradata/node1/control03.ctl,/u01/app/oracle/controlfile04.ctl'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Sun Apr 8 22:14:42 2012
ORA-205 signalled during: ALTER DATABASE MOUNT...
问题就在于当把控制文件复用后,在关闭数据库时,需要把相关信息写回至控制文件。而此时控制文件发生了变化,获取不到控制文件(此处指的是新建的那个controlfile04.ctl)的状态,而控制文件不同于联机日志文件,其是且的关系,而非或的关系。此刻便已经损坏了控制文件。
下面就开始复原数据库并进行正确的控制文件复用。
当然,首先尝试把控制文件修改回以前的个数:
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 100664912 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
SQL> alter system set control_files='/u01/app/oracle/oradata/node1/control01.ctl, /u01/app/oracle/oradata/node1/control02.ctl,/u01/app/oracle/oradata/node1/control03.ctl' scope=spfile;
System altered.
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 100664912 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info
[oracle@xlong01 bdump]$ tail alert_node1.log
starting up 1 shared server(s) ...
Sun Apr 8 22:21:55 2012
ALTER DATABASE MOUNT
Sun Apr 8 22:21:57 2012
ORA-00202: control file: '/u01/app/oracle/oradata/node1/control01.ctl, /u01/app/oracle/oradata/node1/control02.ctl,/u01/app/oracle/oradata/node1/control03.ctl'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
Sun Apr 8 22:21:57 2012
ORA-205 signalled during: ALTER DATABASE MOUNT...
此时显然是行不通的,因为控制文件已经出现了问题了。
那怎么恢复呢,其实办法有以下:
1、可以从备份恢复控制文件。
2、可以从控制文件的trace文件重建控制文件。
3、就是读所有的alert.log文件进行人工创建,当然这个alert.log需要从建库开始以来的所有日志文件。
由于我的这个是测试环境,也没有什么备份文件,所以只能悲剧的进行第三种方案了。狂汗~以后不管怎么样,也要备控制文件和参数文件!
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 100664912 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
--把以前旧的控制文件挪个地
[oracle@xlong01 node1]$ mv control0* ..
--查看alert.log文件手工重建控制文件,如果此时你的库运行了很久的话,那就惨了。还好,我的库基本变化不大,咔咔~~算是幸运的吧..
--此处重建控制文件,是因为前边是一致性关闭库的,数据文件都一致,只是控制文件出了问题而已。
SQL> CREATE CONTROLFILE set DATABASE "node1" RESETLOGS NOARCHIVELOG
2 LOGFILE
3 GROUP 1 ('/u01/app/oracle/oradata/node1/redo01.log') SIZE 50M,
4 GROUP 2 ('/u01/app/oracle/oradata/node1/redo02.log') SIZE 50M,
5 GROUP 3 ('/u01/app/oracle/oradata/node1/redo03.log') SIZE 50M,
6 DATAFILE
7 '/u01/app/oracle/oradata/node1/users01.dbf',
8 '/u01/app/oracle/oradata/node1/sysaux01.dbf',
9 '/u01/app/oracle/oradata/node1/undotbs01.dbf',
10 '/u01/app/oracle/oradata/node1/system01.dbf',
11 '/u01/app/oracle/oradata/node1/example01.dbf'
12 ;
Control file created.
--此时就不写那么多日志文件鸟,也说明了日志文件是或的关系,而控制文件是且的关系了。
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
对于以resetlogs打开的数据库建议立即进行备份,虽然10g以后的可以不用及时备份,不过还是建议立即进行备份。貌似10g以后可以绕过resetlogs后进行重新恢复,我记得我好像这样恢复过,具体忘了..嘻嘻~改天再测下..
此刻也需要创建临时数据文件。
由于是测试环境,以上暂且放一边了。
此刻赶紧备份下控制文件再说,以免重蹈覆辙。
--备trace文件
SQL> alter database backup controlfile to trace as '/u01/app/oracle/controlfile_bak.trc';
Database altered.
--备二进制文件
SQL> alter database backup controlfile to '/u01/app/oracle/controlfile_bak.ctl';
Database altered.
ok了,下面来进行正确的控制文件复用
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/app/oracle/oradata/node1/
control01.ctl, /u01/app/oracle
/oradata/node1/control02.ctl,
/u01/app/oracle/oradata/node1/
control03.ctl
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/10.2.0
/db_1/dbs/spfilenode1.ora
--创建pfile文件
SQL> create pfile='/u01/app/oracle/pfile_20120408' from memory;
create pfile='/u01/app/oracle/pfile_20120408' from memory
*
ERROR at line 1:
ORA-00922: missing or invalid option
--由于不是11g所以以上命令会出错
SQL> create pfile='/u01/app/oracle/pfile_20120408' from spfile;
File created.
--拷贝控制文件的副本到新地
[oracle@xlong01 node1]$ cp control01.ctl ../control04.ctl
--修改pfile文件准备复用控制文件
[oracle@xlong01 node1]$ vi /u01/app/oracle/pfile_20120408
--修改后如下:
*.control_files='/u01/app/oracle/oradata/node1/control01.ctl','/u01/app/oracle/oradata/node1/control02.ctl','/u01/app/oracle/oradata/node1/control03.ctl','/u01/app/oracle/oradata/control04.ctl'
--以pfile启动数据库
SQL> startup pfile=/u01/app/oracle/pfile_20120408;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 104859216 bytes
Database Buffers 176160768 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
--创建spfile
SQL> create spfile from pfile;
File created.
--重启数据库即可
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 100664912 bytes
Database Buffers 180355072 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
后来想了想还是补上临时文件吧,咔咔~
--的确没有临时文件
SQL> select CREATION_TIME,STATUS,NAME from v$tempfile;
no rows selected
--查看临时表空间名
SQL> select NAME from v$tablespace;
NAME
------------------------------
USERS
SYSAUX
UNDOTBS1
SYSTEM
EXAMPLE
TEMP
6 rows selected.
--增加临时文件
SQL> alter tablespace temp add tempfile '/u01/app/oracle/oradata/node1/temp01.dbf' size 5m reuse;
Tablespace altered.
SQL> select CREATION_TIME,STATUS,NAME,CREATION_TIME from v$tempfile;
CREATION_ STATUS
--------- -------
NAME
--------------------------------------------------------------------------------
CREATION_
---------
08-APR-12 ONLINE
/u01/app/oracle/oradata/node1/temp01.dbf
08-APR-12
至此,已经ok了..咔咔~~碎觉去鸟,希望能帮到那位网友解决他的问题。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26143577/viewspace-720679/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26143577/viewspace-720679/