1.首先測試rm 誤刪除數據庫文件
[oracle@primary dbwdn]$ ll
total 2153164
-rw-r----- 1 oracle dba 8536064 Nov 27 21:50 control01.ctl
-rw-r----- 1 oracle dba 8536064 Nov 27 21:50 control02.ctl
-rw-r----- 1 oracle dba 8536064 Nov 27 21:50 control03.ctl
-rw-r----- 1 oracle dba 104865792 Nov 27 21:32 ggs01.dbf
-rw-r----- 1 oracle dba 525344768 Nov 27 21:32 perfstat.dbf
-rw-r----- 1 oracle dba 52429312 Nov 27 21:10 redo01.log
-rw-r----- 1 oracle dba 52429312 Nov 27 21:49 redo02.log
-rw-r----- 1 oracle dba 52429312 Nov 27 21:10 redo03.log
-rw-r----- 1 oracle dba 10493952 Nov 27 21:32 shkz_data_01.dbf
-rw-r----- 1 oracle dba 524296192 Nov 27 21:49 sysaux01.dbf
-rw-r----- 1 oracle dba 524296192 Nov 27 21:49 system01.dbf
-rw-r----- 1 oracle dba 209723392 Nov 18 10:54 temp01.dbf
-rw-r----- 1 oracle dba 52436992 Nov 27 21:32 test01.dbf
-rw-r----- 1 oracle dba 251666432 Nov 27 21:49 undotbs01.dbf
-rw-r----- 1 oracle dba 26222592 Nov 27 21:32 users01.dbf
[oracle@primary dbwdn]$ rm test01.dbf
2.找到數據庫後台進程dbw0
oracle 3493 1 0 21:10 ? 00:00:00 ora_dbw0_dbwdn
進程號3493
3.找到被誤刪除的數據庫文件
[oracle@primary dbwdn]$ ll /proc/3493/fd
total 0
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 0 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 1 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 10 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 11 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 12 -> /u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkDBWDN
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 15 -> /u01/app/oracle/oradata/dbwdn/control01.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 16 -> /u01/app/oracle/oradata/dbwdn/control02.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 17 -> /u01/app/oracle/oradata/dbwdn/control03.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 18 -> /u01/app/oracle/oradata/dbwdn/system01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 19 -> /u01/app/oracle/oradata/dbwdn/undotbs01.dbf
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 2 -> /dev/null
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 20 -> /u01/app/oracle/oradata/dbwdn/sysaux01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 21 -> /u01/app/oracle/oradata/dbwdn/users01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 22 -> /u01/app/oracle/oradata/dbwdn/test01.dbf (deleted)
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 23 -> /u01/app/oracle/oradata/dbwdn/ggs01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 24 -> /u01/app/oracle/oradata/dbwdn/perfstat.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 25 -> /u01/app/oracle/oradata/dbwdn/shkz_data_01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 26 -> /u01/app/oracle/oradata/dbwdn/temp01.dbf
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 27 -> /u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 21:52 4 -> /dev/null
l-wx------ 1 oracle oinstall 64 Nov 27 21:52 5 -> /u01/app/oracle/admin/dbwdn/udump/dbwdn_ora_3485.trc
l-wx------ 1 oracle oinstall 64 Nov 27 21:52 6 -> /u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log
lrwx------ 1 oracle oinstall 64 Nov 27 21:52 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat
l-wx------ 1 oracle oinstall 64 Nov 27 21:52 8 -> /u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log
誤刪除之後,數據庫沒有重啟,系統也沒用重啟
4.拷貝數據庫文件
[oracle@primary ~]$ cp /proc/3493/fd/22 /u01/app/oracle/oradata/dbwdn/test01.dbf
[oracle@primary ~]$ cd /u01/app/oracle/oradata/dbwdn
[oracle@primary dbwdn]$ ls
control01.ctl control03.ctl perfstat.dbf redo02.log shkz_data_01.dbf system01.dbf test01.dbf users01.dbf
control02.ctl ggs01.dbf redo01.log redo03.log sysaux01.dbf temp01.dbf undotbs01.dbf
數據庫文件找回來了。
5.恢復數據庫文件
[oracle@primary dbwdn]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Nov 27 21:55:15 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database datafile 5 offline;
Database altered.
SQL> recover datafile 5;
Media recovery complete.
SQL> alter database datafile 5 online;
Database altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1273276 bytes
Variable Size 130024004 bytes
Database Buffers 150994944 bytes
Redo Buffers 2920448 bytes
Database mounted.
Database opened.
SQL>
成功恢復數據庫
注:如果數據庫重啟之後,還能恢復嗎,測試一下:
[oracle@primary dbwdn]$ rm users01.dbf[oracle@primary dbwdn]$ ps -ef |grep dbw0
oracle 3798 1 0 21:56 ? 00:00:00 ora_dbw0_dbwdn
oracle 4147 3439 0 22:07 pts/1 00:00:00 grep dbw0
[oracle@primary dbwdn]$ ll /proc/3798/fd
total 0
lr-x------ 1 oracle oinstall 64 Nov 27 22:07 0 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 22:07 1 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 22:07 10 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Nov 27 22:07 11 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Nov 27 22:07 12 -> /u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkDBWDN
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 15 -> /u01/app/oracle/oradata/dbwdn/control01.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 16 -> /u01/app/oracle/oradata/dbwdn/control02.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 17 -> /u01/app/oracle/oradata/dbwdn/control03.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 18 -> /u01/app/oracle/oradata/dbwdn/system01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 19 -> /u01/app/oracle/oradata/dbwdn/undotbs01.dbf
lr-x------ 1 oracle oinstall 64 Nov 27 22:07 2 -> /dev/null
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 20 -> /u01/app/oracle/oradata/dbwdn/sysaux01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 21 -> /u01/app/oracle/oradata/dbwdn/users01.dbf (deleted)lrwx------ 1 oracle oinstall 64 Nov 27 22:07 22 -> /u01/app/oracle/oradata/dbwdn/test01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 23 -> /u01/app/oracle/oradata/dbwdn/ggs01.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 24 -> /u01/app/oracle/oradata/dbwdn/perfstat.dbf
lrwx------ 1 oracle oinstall 64 Nov 27 22:07 25 -> /u01/app/oracle/oradata/dbwdn/shkz_data_01.d