误删Oracle dbf 文件后的补救措施

  • scenario

oracle主机上磁盘空间为0了,我查了一下,发现oracle的文件夹占用了 10g以上的空间,又发现有3个我以前创建的早就不用的.dbf文件占据了将近2G的空间,以前好像曾经做过删除,怎么现在还在?二话不说,删!系统报告 说这三个文件还在使用中。这还了得?不容置疑停止oracle服务,删除了这三个文件,然后重启oracle服务。。。。天塌了!!!oraclelistener虽然还能起来,但是别人远程连接,都是ORA-01033: ORACLE initialization or shutdown in progress的错误。

糟了糟了,这下死翘翘了,QA们打电话说他们的service manager连不上了,因为这个oracleSM7DB所在。我的心跳频率一下子升高为平常的两倍(据同事后来说,我当时连给他们的office communicator发的消息都是胡言乱语了…)。匆匆忙忙找了资料,就开始动手了。

  • solution

lsnrctl stop
sqlplus internal
SQL> shutdown abort
SQL> startup
mount
SQL
> alter database datafile 'ovsd45.dbf' offline drop;
SQL> alter database open;
SQL> drop tablespace ovsd45.dbf;
lsnrctl start

(以上忽略屏幕输出的内容)

 

  • action

lsnrctl stop
sqlplus internal
SQL> shutdown abort
SQL> startup
mount

这几个steps都挺正常的,但是我删除的datafile name是什么呢?我想不起来了L,近乎绝望的时候,突然想起来该去找log文件,说不定能找到呢。抱着一丝----真的是一丝的希望,天不绝人啊,果然让我找到\admin\ora10g(数据库名)\bdump\alert.ora10g.log,里面就有这么一段错误:

Thu Feb 12 15:45:56 2009

Errors in file c:\oracle\product\10.1.0\admin\ora10g\bdump\ora10g_dbw0_2784.trc:

ORA-01157: cannot identify/lock data file 5 - see DBWR trace file

ORA-01110: data file 5: 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\TEAM\ORA10G\OVSDOVSD45_DATA.DBF'

ORA-27041: unable to open file

OSD-04002: unable to open file

O/S-Error: (OS 2) The system cannot find the file specified.

 

Thu Feb 12 15:45:56 2009

Errors in file c:\oracle\product\10.1.0\admin\ora10g\bdump\ora10g_dbw0_2784.trc:

ORA-01157: cannot identify/lock data file 6 - see DBWR trace file

ORA-01110: data file 6: 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\TEAM\ORA10G\OVSDOVSD45_INDEX.DBF'

ORA-27041: unable to open file

OSD-04002: unable to open file

O/S-Error: (OS 2) The system cannot find the file specified.

 

Thu Feb 12 15:45:56 2009

Errors in file c:\oracle\product\10.1.0\admin\ora10g\bdump\ora10g_dbw0_2784.trc:

ORA-01157: cannot identify/lock data file 202 - see DBWR trace file

ORA-01110: data file 202: 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\TEAM\ORA10G\OVSDOVSD45_TEMP.DBF'

ORA-27041: unable to open file

OSD-04002: unable to open file

O/S-Error: (OS 2) The system cannot find the file specified.

C:\ORACLE\PRODUCT\10.1.0\ORADATA\TEAM\ORA10G下分别创建3个空文件,名字分别为“OVSDOVSD45_DATA.DBF”、“OVSDOVSD45_INDEX.DBF”、“OVSDOVSD45_TEMP.DBF”,接下来的就是执行:

SQL> alter database datafile ' OVSDOVSD45_DATA.DBF ' offline drop;

SQL> alter database datafile ' OVSDOVSD45_INDEX.DBF ' offline drop;

SQL> alter database datafile ' OVSDOVSD45_TEMP.DBF ' offline drop;

SQL> alter database open;

tablespace?我的tablespace叫啥名字了。。。不管了,跳过这一步

SQL> drop tablespace ovsd45.dbf;

直接执行

lsnrctl start

然后,从PL/SQL再登陆,咦,可以了!赶紧以sys身份登陆以后,赶紧drop掉刚才找回来的那些dbf文件的tablespace,然后check其他连接,心跳总算又恢复正常了。

你可能感兴趣的:(oracle,sql,C++,c,OS)