Use a Linux File handle to restore accidentally deleted Oracle data files

Source: Internet
Author: User
Test environment: OEL + Oracle11.2.0.1 first, check the status of the current data file and data file: SQLgt; selectfile_id, tablespace_name, file_name

Test environment: OEL + Oracle 11.2.0.1 first check the current data file and Data File status: 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

Prepare to delete the data file/oradata/orcl2/SG01.dbf from rm and use the Linux handle for restoration. After deletion, remember that the instance cannot be shut down (It Doesn't Matter after shutdown, but it will make recovery more troublesome );

Delete data files/oradata/orcl2/SG01.dbf

[Oracle @ DBA2 orcl2] $ rm SG01.dbf

[Oracle @ DBA2 orcl2] $

View the file handle and find that the/oradata/orcl2/SG01.dbf status is (delete), as shown in red:

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

3140

PS: 3140 is the pid of the DBWn process. The DBWn process references this handle to operate data files. In fact, it can also use other Oracle processes such as LGWR. It is not necessary to use the pid of the DBWn process;

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

[Oracle @ DBA2 fd] $ ls-al

Total 0

Dr-x ------ 2 oracle oinstall 0 Sep 4.

Dr-xr-x 7 oracle oinstall 0 Sep 4 ..

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

L-wx ------ 1 oracle oinstall 64 Sep 4 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->/u/oracle/product/11.2/rdbms/mesg/oraus. msb

Lr-x ------ 1 oracle oinstall 64 Sep 4->/dev/zero

Lr-x ------ 1 oracle oinstall 64 Sep 4 14->/proc/3140/fd

Lr-x ------ 1 oracle oinstall 64 Sep 4 15->/dev/zero

Lrwx ------ 1 oracle oinstall 64 Sep 4 16->/u/oracle/product/11.2/dbs/hc_orcl2.dat

Lrwx ------ 1 oracle oinstall 64 Sep 4 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 2->/dev/null

Lrwx ------ 1 oracle oinstall 64 Sep 4 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->/oradata/orcl2/SG01.dbf (deleted)

Lrwx ------ 1 oracle oinstall 64 Sep 4 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 29->/u/oracle/product/11.2/rdbms/mesg/oraus. msb

L-wx ------ 1 oracle oinstall 64 Sep 4 3->/u/oracle/product/11.2/rdbms/log/orcl2_ora_3056.trc

Lr-x ------ 1 oracle oinstall 64 Sep 4 4->/dev/null

Lr-x ------ 1 oracle oinstall 64 Sep 4 5->/dev/null

Lr-x ------ 1 oracle oinstall 64 Sep 4 6->/dev/null

Lrwx ------ 1 oracle oinstall 64 Sep 4 7->/u/oracle/product/11.2/dbs/hc_orcl2.dat

Lrwx ------ 1 oracle oinstall 64 Sep 4 8->/u/oracle/product/11.2/dbs/lkinstorcl2 (deleted)

Lr-x ------ 1 oracle oinstall 64 Sep 4 9->/proc/3140/fd

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.