千家信息网

Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办

发表于:2025-01-21 作者:千家信息网编辑
千家信息网最后更新 2025年01月21日,这篇文章主要讲解了"Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一
千家信息网最后更新 2025年01月21日Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办

这篇文章主要讲解了"Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办"吧!

今天遇到一个比较神奇的问题,客户某套测试数据库断电重启了,重启时发现数据库提示ORA-01157: cannot identify/lock data file和ORA-01110的错误,经过检查发现是系统启动后未挂载存储,表空间都放在存储盘上,手工挂载存储后所有问题迎刃而解。当时没有记录问题,这里通过测试环境模拟重现问题。

制造实验数据

[oracle@XLJ181 ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 10 19:27:14 2018Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@cams> create tablespace test datafile '/home/oracle/test.dbf' size 100M;Tablespace created.SYS@cams> create user test identified by 123456 default tablespace test;User created.SYS@cams> grant connect,resource to test;Grant succeeded.TEST@cams> create table test(id number primary key,name varchar2(20));Table created.TEST@cams> insert into test values(1,'bob');1 row created.TEST@cams> insert into test values(2,'joe');1 row created.TEST@cams> select count(*) from test;  COUNT(*)----------         2TEST@cams> conn / as sysdbaConnected.SYS@cams> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SYS@cams> exitDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

模拟文件误删除

[oracle@XLJ181 ~]$ mv /home/oracle/test.dbf /home/oracle/test.dbf.bak

故障出现

启动数据库,发现数据文件不存在:

[oracle@XLJ181 ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 10 19:38:26 2018Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to an idle instance.SYS@cams> startup;ORACLE instance started.Total System Global Area 5344731136 bytesFixed Size             2262656 bytesVariable Size               1040189824 bytesDatabase Buffers    4294967296 bytesRedo Buffers                   7311360 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01110: data file 63: '/home/oracle/test.dbf'

查看trace文件:

Mon Dec 10 19:38:35 2018ALTER DATABASE OPENErrors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_dbw0_21153.trc:ORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01110: data file 63: '/home/oracle/test.dbf'ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_ora_21175.trc:ORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01110: data file 63: '/home/oracle/test.dbf'ORA-1157 signalled during: ALTER DATABASE OPEN...

查看cams_ora_21175.trc文件,报错信息如下:

DDE: Problem Key 'ORA 1110' was flood controlled (0x1) (no incident)ORA-01110: data file 63: '/home/oracle/test.dbf'ORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01110: data file 63: '/home/oracle/test.dbf'

查看cams_dbw0_21153.trc文件,报错信息如下:

ORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01110: data file 63: '/home/oracle/test.dbf'ORA-27037: unable to obtain file statusLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3

问题已经很明显了,就是找不到data file 63: '/home/oracle/test.dbf'。

针对该问题,我们应该怎么去处理呢?特别是测试环境,一般为了节约资源,不会开启归档,更不会有RMAN备份,那怎么让数据库跑起来,让数据损失降到最低呢?

常用解决方案:offline drop+recreate

SQL> shutdown immediate;SQL> startup mount;SQL> alter database datafile '/home/oracle/test.dbf' offline drop;SQL> alter database open;SQL> drop tablespace test including contents;               --注意:执行之前检查是否还有其他文件属于该表空间SQL> create tablespace test datafile '/home/oracle/test.dbf' size 100M;

因为是测试环境,想办法重建数据或者利用最近的逻辑备份或其他测试导入数据,这样能把数据损失降到最低。

如果删除的是核心系统的表空间,那么还不如重建表空间之后把相关数据清理之后重新导入一份。

感谢各位的阅读,以上就是"Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办"的内容了,经过本文的学习后,相信大家对Oracle表空间误删除导致startup启动时提示ORA-01110和ORA-01157错误怎么办这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!

0