Home  >  Article  >  Database  >  使用Linux文件句柄恢复误删除的Oracle数据文件

使用Linux文件句柄恢复误删除的Oracle数据文件

WBOY
WBOYOriginal
2016-06-07 17:31:59966browse

测试环境:OEL+Oracle 11.2.0.1 首先查看当前的数据文件及数据文件状态: SQLgt; select file_id,tablespace_name,file_name

SQL> select file#,status,name from v$datafile;

 

FILE# STATUS NAME

---------- ------- ----------------------------------------

1 SYSTEM /oradata/orcl2/system01.dbf

2 ONLINE /oradata/orcl2/sysaux01.dbf

3 ONLINE /oradata/orcl2/undotbs01.dbf

4 ONLINE /oradata/orcl2/users01.dbf

5 ONLINE /oradata/orcl2/SG01.dbf

6 ONLINE /oradata/orcl2/book.dbf

 

准备对数据文件/oradata/orcl2/SG01.dbf进行rm删除并使用Linux句柄进行恢复,,删除后切记不可将实例shutdown(其实shutdown后也没关系,只是会使恢复更麻烦);

删除数据文件/oradata/orcl2/SG01.dbf

[oracle@DBA2 orcl2]$ rm SG01.dbf

[oracle@DBA2 orcl2]$

查看文件句柄,发现/oradata/orcl2/SG01.dbf状态为(delete)如红显处:

[oracle@DBA2 orcl2]$ ps -ef|grep dbw|grep -v grep|awk '{print $2}'

3140

PS:3140 为DBWn进程的pid,DBWn进程引用此句柄对数据文件操作,其实也可以用LGWR等其他Oracle进程,不一定非得用DBWn这个进程的pid;

[oracle@DBA2 orcl2]$ cd /proc/3140/fd

[oracle@DBA2 fd]$ ls -al

total 0

dr-x------ 2 oracle oinstall 0 Sep 4 09:28 .

dr-xr-xr-x 7 oracle oinstall 0 Sep 4 09:28 ..

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 0 -> /dev/null

l-wx------ 1 oracle oinstall 64 Sep 4 09:41 1 -> /dev/null

l-wx------ 1 oracle oinstall 64 Sep 4 09:41 10 -> /u/oracle/diag/rdbms/orcl2/orcl2/trace/orcl2_ora_3056.trc

l-wx------ 1 oracle oinstall 64 Sep 4 09:41 11 -> /u/oracle/diag/rdbms/orcl2/orcl2/trace/orcl2_ora_3056.trm

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 12 -> /u/oracle/product/11.2/rdbms/mesg/oraus.msb

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 13 -> /dev/zero

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 14 -> /proc/3140/fd

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 15 -> /dev/zero

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 16 -> /u/oracle/product/11.2/dbs/hc_orcl2.dat

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 17 -> /u/oracle/product/11.2/dbs/lkORCL2

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 18 -> /oradata/orcl2/control01.ctl

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 19 -> /u/oracle/flash_recovery_area/orcl2/control02.ctl

l-wx------ 1 oracle oinstall 64 Sep 4 09:41 2 -> /dev/null

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 20 -> /oradata/orcl2/system01.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 21 -> /oradata/orcl2/sysaux01.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 22 -> /oradata/orcl2/undotbs01.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 23 -> /oradata/orcl2/users01.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 24 -> /oradata/orcl2/SG01.dbf (deleted)

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 25 -> /oradata/orcl2/book.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 26 -> /oradata/orcl2/temp01.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 27 -> /oradata/orcl2/temp02.dbf

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 28 -> /oradata/orcl2/temo01.dbf

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 29 -> /u/oracle/product/11.2/rdbms/mesg/oraus.msb

l-wx------ 1 oracle oinstall 64 Sep 4 09:41 3 -> /u/oracle/product/11.2/rdbms/log/orcl2_ora_3056.trc

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 4 -> /dev/null

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 5 -> /dev/null

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 6 -> /dev/null

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 7 -> /u/oracle/product/11.2/dbs/hc_orcl2.dat

lrwx------ 1 oracle oinstall 64 Sep 4 09:41 8 -> /u/oracle/product/11.2/dbs/lkinstorcl2 (deleted)

lr-x------ 1 oracle oinstall 64 Sep 4 09:41 9 -> /proc/3140/fd

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:MySQL体系结构Next article:MySQL架构分析与工作流程