ORA-01157报错"cannot identify/lock data file"解决

时间:2023-03-08 17:36:59
ORA-01157报错"cannot identify/lock data file"解决
sqlplus以管理员方式接入数据库,启动时出现报错,如下:
> sqlplus "/as sysdba"
SQL> startup
......
ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
ORA-01110: data file 8: '/tmp/test.dbf'
查看数据库日志文件alert_$ORACLE_SID.log,存在对应报错信息:
Errors in file ....../aix85_psp0_454886.trc:
查看此trc文件中记录信息:
*** SERVICE NAME:() 2011-07-18 10:05:00.769
*** SESSION ID:(332.1) 2011-07-18 10:05:00.769
ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
ORA-01110: data file 8: '/tmp/test.dbf'
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3
ORA-01157: cannot identify/lock data file 9 - see DBWR trace file
ORA-01110: data file 9: '/tmp/test1.dbf'
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3
ORA-01157: cannot identify/lock data file 10 - see DBWR trace file
ORA-01110: data file 10: '/tmp/indx1.dbf'
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3
ORA-01157: cannot identify/lock data file 11 - see DBWR trace file
ORA-01110: data file 11: '/tmp/test2.dbf'
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3
ORA-01157: cannot identify/lock data file 12 - see DBWR trace file
查询分析:
查看/tmp目录中已经没有任何dbf文件存在,查询确认/tmp目录中的几个dbf是在之前数据库运行过程中添加的测试空间文件,测试完毕已经删除,而且后续没有任何人访问到这几个文件,因此也没有任何数据库报错,直到数据库实例宕掉并重启时出现启动失败。
解决办法:
既然出现报错的几个dbf文件已经不用,则解决办法相对简单,只要将对应的数据文件删除,并继续删除对应新增的表空间即可。操作过程如下:
SQL> shutdown immediate;
SQL> startup mount;
SQL> select file#,name,status from v$datafile;
SQL> alter database datafile '/tmp/test.dbf' offline drop;      //此处若不加drop会报错
再次查看v$datafile表会发现对应的几个dbf文件状态由ONLINE变为RECOVER
SQL> select * from v$tablespace;
SQL> drop tablespace test including contents cascade constraints;
......
删除完毕,再次执行startup成功。