2009年6月8日星期一

ZT: ORA-01157 - Mount状态下的文件存在性校验


&copy作者:eygle 发布在 eygle.com

在我的新书里,曾经有一小段描述到在Mount状态下,Oracle对于文件存在性的校验,也就是你可能在Mount状态下看到如下提示信息:

Fri Jun 5 17:34:38 2009
Errors in file /opt/oracle/admin/eygle/bdump/eygle_dbw0_2424.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/opt/oracle/eygle01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
那么在什么状态下可以得到这样的信息输出呢?
在以下测试中,展示了这一过程,测试来自Oracle9i 9.2.0.4环境:
SQL> ! mv /opt/oracle/eygle01.dbf /opt/oracle/eygle01.dbf.b

SQL> startup mount;
ORACLE instance started.

Total System Global Area 420549952 bytes
Fixed Size 451904 bytes
Variable Size 268435456 bytes
Database Buffers 150994944 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> set linesize 120
SQL> col error for a20
SQL> select * from v$recover_file;

FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
---------- ------- ------- -------------------- ---------- ---------
3 ONLINE ONLINE FILE NOT FOUND 0

在查询v$recover_file视图时,查询进程触发了后台检查,在告警日志中将看到如下信息:
Fri Jun 5 17:34:25 2009
Database mounted in Exclusive Mode.
Completed: ALTER DATABASE MOUNT
Fri Jun 5 17:34:38 2009
Errors in file /opt/oracle/admin/eygle/bdump/eygle_dbw0_2424.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/opt/oracle/eygle01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
也就是说,虽然在Mount状态,数据库并不会主动校验文件的存在性,但是会被前台进程触发,去判断文件的存在性,从而报出出错信息。DBWR进程的日志与以上输出相类似
*** 2009-06-05 17:34:38.048
*** SESSION ID:(2.1) 2009-06-05 17:34:38.047
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: '/opt/oracle/eygle01.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
如果没有查询触发,在Open状态数据库才会一一校验文件的存在性、一致性,并根据不同情况给出不同的提示信息。
在Oracle Database 10g中,情况有所不同,对于以上情况,Oracle10g并不好触发后台DBWR进程的判断及错误信息,而是由前台进程去检查文件存在性,并给出v$recover_file的视图信息,并不会记录错误日志。

然而何时判断,如何判断,如何记录,心中了了即可。

-The End-

本文网址:http://www.eygle.com/archives/2009/06/ora_01157_mount_database.html

没有评论:

发表评论