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、要重启计算机。
只要机器没有运行过磁盘整理。系统完好.任何时候的文件都可以找回来。
linux rm误删除数据库文件的恢复方法
2019-12-01 16:50Linux教程网 Linux
在linux redhat 5.4版本,rm误删除数据库文件的恢复过程如下,网上找的,测试过OK
延伸 · 阅读
- 2024-11-03晨报:《龙腾4》Steam“多半好评” 《Apex》不再支
- 2022-03-11在Linux下通过命令行打包Android应用的方法
- 2022-03-10这个 Linux 图形计算器让数学很有趣
- 2022-03-10Mongodb数据库转换为表格文件的库
- 2022-03-10Linux下部署springboot项目的方法步骤
- 2022-03-10linux中把.c的文件编译成.so文件
- Linux
详解linux lcd驱动编写
这篇文章主要介绍了详解linux lcd驱动编写,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...
- Linux
Linux安装使用分布式版本控制系统GitHub的步骤
Git是一个分布式版本控制系统,为用户提供Git服务,下面小编就给大家介绍下Linux如何安装和使用GitHub,感兴趣的朋友可以看看 ...
- Linux
四款值得一试的 Linux 终端多路复用器
Linux 用户通常需要大量的虚拟视觉空间。一个终端窗口是永远不够的,所以终端有了标签。一个桌面太受限制了,所以有了虚拟桌面。...
- Linux
详解Linux patch命令参数及用法
本篇文章文章主要介绍了linux patch命令,此命令用于为特定软件包打补丁,他使用diff命令对源文件进行操作。有兴趣的可以了解一下。...
- Linux
Linux下Wireshark的网络抓包使用方法
这篇文章主要介绍了Linux下Wireshark的网络抓包使用方法,针对其的tshark命令给简单讲解,需要的朋友可以参考下...
- Linux
Linux中rz命令使用实例分享(批量上传文件、简单易用)
rz命令可以批量上传文件,当然也可上传单个文件啦。使用的协议是古老的ZMODEM协议,虽然协议古老,但毫不影响的简单易用的特性 ...
- Linux
容器的四大基础技术
在本文中,我研究了容器是如何在一些特殊的 Linux 技术基础上实现的,这其中包括命名空间和控制组。...
- Linux
linux系统中的批量删除文件与空文件删除的命令介绍
本章为大家详细的整理了,在linux系统中批量删除文件和空文件删除的命令,请大家“对症下药” ...