Linux下如何恢複意外刪除的檔案

來源:互聯網
上載者:User

今天有客戶的資料庫意外被刪除了整個目錄中的資料檔案,作業系統層級的刪除,然而幸運的是這個資料庫沒有崩潰,仍然處於open狀態的時候,客戶就發現了問題,求助到我們,最終完整地恢複了所有資料檔案。

在Linux下大致重新示範一下恢複的過程,恢複的步驟與資料庫版本沒有太大關係,與作業系統的不同會有所不同。

1. 在資料庫open的時候,直接刪除users資料表空間中的資料檔案。

SQL> select name from v$datafile;

NAME

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

/app/oracle/oradata/ORCL/datafile/o1_mf_system_555wqbnk_.dbf

/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_555wqxgl_.dbf

/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_555wr5p6_.dbf

/app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf

SQL> host rm /app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf

2. 嘗試在users資料表空間中建立表,開始報錯。

SQL> create table t tablespace users as select * from dual;

create table t tablespace users as select * from dual

*

ERROR at line 1:

ORA-01116: error in opening database file 4

ORA-01110: data file 4:

'/app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf'

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3

在警示日誌中,同樣也可以看到類似資訊。

Mon Dec 19 21:48:17 CST 2011

Errors in file /app/oracle/admin/orcl/bdump/orcl_m000_3897.trc:

ORA-01116: error in opening database file 4

ORA-01110: data file 4: '/app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf'

ORA-27041: unable to open file

Linux Error: 2: No such file or directory

Additional information: 3

3. 檢查dbwr的進程PID

$ ps -ef|grep dbw0|grep -v grep

oracle    2879     1  0 21:38 ?        00:00:00 ora_dbw0_orcl

本文URL:http://www.bianceng.cn/OS/Linux/201410/45614.htm

4. dbwr會開啟所有資料檔案的控制代碼。在proc目錄中可以查到,目錄名是進程PID,fd表示檔案描述符。

$ cd /proc/2879/fd

$ ls -l

total 0

lr-x------ 1 oracle dba 64 Dec 19 21:50 0 -> /dev/null

lr-x------ 1 oracle dba 64 Dec 19 21:50 1 -> /dev/null

lr-x------ 1 oracle dba 64 Dec 19 21:50 10 -> /dev/zero

lr-x------ 1 oracle dba 64 Dec 19 21:50 11 -> /dev/zero

lr-x------ 1 oracle dba 64 Dec 19 21:50 12 -> /app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

lrwx------ 1 oracle dba 64 Dec 19 21:50 13 -> /app/oracle/product/10.2.0/db_1/dbs/hc_orcl.dat

lrwx------ 1 oracle dba 64 Dec 19 21:50 14 -> /app/oracle/product/10.2.0/db_1/dbs/lkORCL

lrwx------ 1 oracle dba 64 Dec 19 21:50 15 -> /app/oracle/oradata/ORCL/controlfile/o1_mf_555wq3ng_.ctl

lrwx------ 1 oracle dba 64 Dec 19 21:50 16 -> /app/oracle/oradata/ORCL/datafile/o1_mf_system_555wqbnk_.dbf

lrwx------ 1 oracle dba 64 Dec 19 21:50 17 -> /app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_555wqxgl_.dbf

lrwx------ 1 oracle dba 64 Dec 19 21:50 18 -> /app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_555wr5p6_.dbf

lrwx------ 1 oracle dba 64 Dec 19 21:50 19 -> /app/oracle/oradata/ORCL/datafile/o1_mf_users_555wrj4o_.dbf (deleted)

lr-x------ 1 oracle dba 64 Dec 19 21:50 2 -> /dev/null

lrwx------ 1 oracle dba 64 Dec 19 21:50 20 -> /app/oracle/oradata/ORCL/datafile/o1_mf_temp_555wrbnz_.tmp

lr-x------ 1 oracle dba 64 Dec 19 21:50 21 -> /app/oracle/product/10.2.0/db_1/rdbms/mesg/oraus.msb

lr-x------ 1 oracle dba 64 Dec 19 21:50 3 -> /dev/null

lr-x------ 1 oracle dba 64 Dec 19 21:50 4 -> /dev/null

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.