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中DNS服务器地址查询命令nslookup使用教程
这篇文章主要介绍了Linux中DNS服务器地址查询命令nslookup使用教程,是Linux服务器运维的必备知识,需要的朋友可以参考下...
- Linux
Linux中服务器软件为什么需要编译安装
这篇文章主要介绍了Linux中服务器软件为什么需要编译安装,在什么情况下需要编译安装,需要的朋友可以参考下...
- Linux
使用uptimed命令监视Linux系统正常运行时间
今天这篇文章就为大家分享一个用于记录和跟踪系统的运行时间的实用命令行工具,它的名字叫做 uptimed。...
- Linux
这 10条 Linux 命令锦囊,防你牢底坐穿
每一年,都会有删库跑路的新闻。现实中,删库容易,跑路难,从业者充满了泪水。本文为大家分享这10条Linux 命令锦囊,防你牢底坐穿....
- Linux
Linux下rsync远程数据同步命令的详细介绍
rsync是一款开源的、快速的、多功能的、可实现全量及增量的本地或远程数据同步备份的优秀工具。rsync软件适用于unix/linux/windows等多种操作系统平台。下面...
- Linux
linux ln 命令使用参数详解(ln -s 软链接)
这是linux中一个非常重要命令,请大家一定要熟悉。它的功能是为某一个文件在另外一个位置建立一个同不的链接,这个命令最常用的参数是-s,具体用法是...
- Linux
Linux 逻辑卷管理(LVM)使用方法总结
这篇文章主要介绍了Linux 逻辑卷管理(LVM)的使用方法,文中命令十分详细,帮助大家更好的学习,感兴趣的小伙伴快来参考下 ...
- Linux
Linux中进程在后台可靠运行的方法总结
本篇文章主要给大家介绍了Linux中进程在后台可靠运行的方法以及示例代码分析,一起学习参考下吧。...