linux rm误删除数据库文件的恢复方法

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.dbf

数据库没有重启,这个数据文件还能恢复,如果我重启数据库之后,还能看见这个数据文件吗?

[oracle@primary dbwdn]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Nov 27 22:08:01 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> shutdown immediate;
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/u01/app/oracle/oradata/dbwdn/users01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SQL> shutdown abort;ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@primary dbwdn]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Nov 27 22:08:19 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
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.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/dbwdn/users01.dbf'

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@primary dbwdn]$ ll /proc/3798/fd
ls: /proc/3798/fd: No such file or directory
[oracle@primary dbwdn]$ ps -ef |grep dbw0
oracle 4160 1 0 22:08 ? 00:00:00 ora_dbw0_dbwdn
oracle 4193 3439 0 22:09 pts/1 00:00:00 grep dbw0
[oracle@primary dbwdn]$ ll /proc/4160/fd
total 0
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 0 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 1 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 10 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 11 -> /dev/zero
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 12 -> /u01/app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 13 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 14 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkDBWDN
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 15 -> /u01/app/oracle/oradata/dbwdn/control01.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 16 -> /u01/app/oracle/oradata/dbwdn/control02.ctl
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 17 -> /u01/app/oracle/oradata/dbwdn/control03.ctl
l-wx------ 1 oracle oinstall 64 Nov 27 22:09 2 -> /u01/app/oracle/admin/dbwdn/bdump/dbwdn_dbw0_4160.trc
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 Nov 27 22:09 4 -> /dev/null
l-wx------ 1 oracle oinstall 64 Nov 27 22:09 5 -> /u01/app/oracle/admin/dbwdn/udump/dbwdn_ora_4152.trc
l-wx------ 1 oracle oinstall 64 Nov 27 22:09 6 -> /u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 7 -> /u01/app/oracle/product/10.2.0/db_1/dbs/hc_dbwdn.dat
l-wx------ 1 oracle oinstall 64 Nov 27 22:09 8 -> /u01/app/oracle/admin/dbwdn/bdump/alert_dbwdn.log
lrwx------ 1 oracle oinstall 64 Nov 27 22:09 9 -> /u01/app/oracle/product/10.2.0/db_1/dbs/lkinstdbwdn (deleted)
[oracle@primary dbwdn]$

已经没法恢复了。
说明需要注意的是,rm误删除文件之后,千万不要慌张,稳住神,不要重启数据库,不要重启动系统。
AIX系统,我没有测试过。
使用备份集恢复上面的数据库文件:

[oracle@primary dbwdn]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Nov 27 22:13:45 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
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
RMAN> alter database mount;
using target database control file instead of recovery catalog
database mounted
RMAN> run
2> {
3> allocate channel t1 type to disk;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "to": expecting one of: "double-quoted-string, disk, equal, identifier, single-quoted-string"
RMAN-01007: at line 3 column 26 file: standard input
RMAN> run
2> {
3> allocate channel t1 device type disk;
4> restore datafile 4;
5> recover datafile 4;
6> release channel t1;
7> }
allocated channel: t1
channel t1: sid=156 devtype=DISK
Starting restore at 27-NOV-2012 22:16:26
channel t1: starting datafile backupset restore
channel t1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/dbwdn/users01.dbf
channel t1: reading from backup piece /u01/bak/03nrctnp_1_1.bak
channel t1: restored backup piece 1
piece handle=/u01/bak/03nrctnp_1_1.bak tag=TAG20121127T213241
channel t1: restore complete, elapsed time: 00:00:04
Finished restore at 27-NOV-2012 22:16:30
Starting recover at 27-NOV-2012 22:16:30
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-NOV-2012 22:16:31
released channel: t1
RMAN> alter database open;
database opened
RMAN>

Windows下数据恢复(把回收站清空后的恢复方法):

步骤:
1、单击“开始——运行,然后输入regedit (打开注册表)
2、依次展开:HEKEY——LOCAL——MACHIME/SOFTWARE/microsoft/WINDOWS/ CURRENTVERSION/EXPLORER/DESKTOP/NAMESPACE 在左边空白外点击“新建”
,选择:“主键”,把它命名为“645FFO40——5081——101B——9F08——00AA002F954E”
再把右边的“默认”的主键的键值设为“回收站”,然后退出注册表。就OK啦。
3、要重启计算机。
只要机器没有运行过磁盘整理。系统完好.任何时候的文件都可以找回来。

(0)

相关推荐

  • Linux rm 命令误删文件的恢复方法

    网上好多文章都是介绍 ext3 或者2的,在 ext4 下大家可以试下extundelete 这个软件,本人在 Ubuntu 11.04 下亲测,数据完美恢复。 假设被删除的文件位于 /media/b ...

  • U盘及闪存卡误删文件的恢复方法

    平时在操作电脑时,不小心将某个文件误删除了,通常情况下,我们还可以在回收站里找回。但若是,我们不小心将闪存卡、U盘中的文件删除了,怎么办呢?下面我们就一起来看看这种情况的解决方法。 第一种方法:就是使 ...

  • 华硕灵耀3笔记本提速方法及文件删除恢复方法

    电脑反应慢老是卡怎么办?是什么原因造成的呢?这是由于长时间使用电脑产生的垃圾文件和缓存造成的,那么怎么彻底的清理这些文件呢?简单几步就可以解决,顺带在说说电脑误删文件比较好用的恢复方法. 操作方法 0 ...

  • word文档误删怎么办?word文件误删恢复方法

    使用word编辑文档时,一时之乱不小心把编辑中的word文档没保存就关掉了。这可怎么办? Word文档误删怎么办?word文件误删恢复方法。 1.先打开一个新建的 Word 文档。 2.然后点击文件, ...

  • win7系统中被覆盖文件如何恢复 win7系统中被覆盖文件的恢复方法

    我们都知道在将某一个文件移动到另一个文件夹中,如果有同名文件存在,一般会有文件覆盖提示,询问用户是否覆盖文件,这时候选择“覆盖文件”就会将另一个文件覆盖,可是有很多用户在文件被覆盖后又想要恢复这个文件 ...

  • 电脑中误删除的文件如何恢复

    我们在使用电脑的时候,总会不小心误删除一些文件,想要恢复,该怎么操作呢?今天就跟大家介绍一下电脑中误删除的文件如何恢复的具体操作步骤.1. 这里我们选择使用失易得数据恢复软件来进行恢复操作,没有该软件 ...

  • hosts文件修复问题_360误删误改hosts文件的恢复方法

    hosts文件的作用相信大家都比较清楚了,其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库”,当用户在浏览器中输入一个需要登录的网址时,系统会首先自动从Hosts文件中寻找对应的I ...

  • Windows7系统回收站文件的恢复方法

    您是否遇到过这种情况,一不小心删除了文件并清空了回收站,被误删的文件还能找回来吗?可以的,相信不少朋友都会觉得是可以找回的。如果难度太大了,只能找数据恢复公司了。接系统之家下来给大家分享下如何恢复回收 ...

  • 十大数据库备份和恢复方法

    一般的文件型数据库,实际上对整个就是一个或者多个文件,所谓的备份就是把这些文件考虑到其它介质上,可能有一个打包的过程,或者刻录到DVD的过程.这是对文件型数据库备份和恢复的最好方法,效率最好,操作最简 ...