oracle資料檔案被誤刪除後的災難處理方法____oracle

來源:互聯網
上載者:User

010-06-18 17:47
oracle資料檔案被誤刪除後的災難處理方法
key:oracle資料檔案(datafile)被誤刪除後沒有恢複的辦法,只能把該資料檔案offline後drop掉,並刪除整個資料表空間。
steps:
當Oracle資料檔案被誤刪除之後的處理辦法。。
1、關閉資料庫:
?? sqlplus "/as sysdba";
?? sqlplus>shutdown abort;
2、裝載資料庫
?? sqlplus>startup mount;
3、刪除無效的資料庫檔案
?? sqlplus>alter database datafile '/home/oracle/survey/survey.dbf' offline drop
?? sqlplus>alter database datafile '/home/oracle/survey/surveytemp.dbf' offline drop
4、開啟資料庫
  sqlplus>alter database open;
5、刪除無效的資料表空間
?? sqlplus> drop tablespace surevy including contents;
?? sqlplus> drop tablespace surevytemp including contents;
??

---dtl----

資料表空間 GTI40_DATA01 資料檔案GTI40_DATA01.dbf被我刪除了
我再運行drop tablespace qwer
會報錯


ORA-01116: 開啟資料庫檔案48時出錯
ORA-01110: 資料檔案 48: '/data/GTI40_DATA01.dbf'
ORA-27041: 無法開啟檔案
Linux Error: 2: No such file or directory
Additional information: 3

我怎麼才能刪除這個資料表空間
現在我無法在建立這個空間(線上等急!!!!!!!!)


簡單的問題搞這麼複雜。
按下面步驟做即可:
1.shutdown immediate
2.startup mount
3.alter database datafile 'xxx' offline drop;
4.alter database open
5.drop tablespace xxxx including contents and datafiles;

先說明一下alter database datafile ... offline drop:

在非歸檔模式下,可以使用... offline drop,在歸檔模式下,使用... offline. 這個命令的意思並不是從資料表空間將這個資料檔案徹底刪除,而是說將這個資料檔案“凍結”住:它的scn不在變化,不會再向它寫入任何資料;但是原有存在這個檔案中對象和資料還可以繼續使用。因此在使用這個命令後,通過修改控制檔案將它刪除,資料庫在啟動時就會報檔案丟失的錯誤,並且會在資料字典中產生一個MISGXXXXX的紀錄。因此,以一個資料檔案是無法被直接從資料庫中刪除掉的。

如果需要減少資料表空間的資料檔案,可以採用以下辦法:

export除資料表空間的內容:exp ... tablespaces=xxx;

使用include content子句刪除資料表空間:drop tablespace xxx include content;

重見資料表空間,使之不包括需要去除掉的資料檔案;

import資料表空間的所有資料對象。

re: 徹底將一個資料檔案從資料表空間中刪除 [回複]
呵呵,在10g R2的drop empty datafile之前,事實上是無法對單個資料檔案進行刪除的,除非你更改資料字典或者將資料表空間刪除。如果按你上面的步驟操作,你查dba_data_files裡面肯定會有那個資料檔案的記錄,只是標識為D:ORACLEORA92DATABASEMISSING00005這類的檔案,事實上是由於你將控制檔案中該資料檔案的資訊刪除掉了,而資料字典裡面還有該檔案的資訊,現在對應不上,因此標識為這種奇怪的檔案名稱,表示該資料檔案需要恢複的。


當Oracle資料檔案被誤刪除之後的處理辦法。。
1、關閉資料庫:
?? sqlplus "/as sysdba";
?? sqlplus>shutdown abort;
2、裝載資料庫
?? sqlplus>startup mount;
3、刪除無效的資料庫檔案
?? sqlplus>alter database datafile '/home/oracle/survey/survey.dbf' offline drop
?? sqlplus>alter database datafile '/home/oracle/survey/surveytemp.dbf' offline drop
4、開啟資料庫
  sqlplus>alter database open;
5、刪除無效的資料表空間
?? sqlplus> drop tablespace surevy including contents;
?? sqlplus> drop tablespace surevytemp including contents;
??
??
good:
oracle資料檔案被誤刪除後的災難處理方法- -
Tag: oracle??? datafile??? 資料檔案??? 誤刪除??? 災難??????????????????????????????????????????
環境:Red Hat Linux 7.2 SMP
資料庫:Oracle 8.1.7

起因,一同事建立了一個資料表空間並建立一張表後發現資料表空間未用到直接刪除了那個資料檔案.其操作如下:
create tablespace r_csh_20051001 datafile '/webdata/dbdata/ry/csh20051001.dat' size 50M autoextend on next 500M default storage (initial 10m NEXT 10m MINEXTENTS 1 PCTINCREASE 0);
create table r_csh(
????? UsedDate?? char(26) default '',
????? CardNumber char(26) default '',
????? UserNumber char(16) default '',
????? Credit???? number(5) default 0,
????? UserArea?? number(6) default 0,
????? CardArea?? number(6) default 0,
????? ValiDdate char(26) default ''
);

rm /webdata/dbdata/ry/csh20051001.dat
經過這一操作後,資料庫出現串連失敗,探索資料庫已經停止了.
查看oracle的log顯示:

Errors in file /oracle/admin/webdb/bdump/ckpt_31638.trc:
ORA-01110: data file 63: '/webdata/dbdata/ry/csh20051001.dat'
ORA-01115: IO error reading block from file 63 (block # 1)
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
ORA-01242: data file suffered media failure: database in NOARCHIVELOG mode
ORA-01116: error in opening database file 63
ORA-01110: data file 63: '/webdata/dbdata/ry/csh20051001.dat'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
Fri Oct 21 15:31:47 2005
CKPT: terminating instance due to error 1242
Instance terminated by CKPT, pid = 31638
Fri Oct 21 15:55:09 2005

想要把oracle重新啟動,發現也啟動不了:

SQL> shutdown immediate;
SQL> startup;
ORACLE instance started.

Total System Global Area?? 40104096 bytes
Fixed Size??????????????????? 73888 bytes
Variable Size????????????? 23080960 bytes
Database Buffers?????????? 16777216 bytes
Redo Buffers???????????????? 172032 bytes
Database mounted.
ORA-01122: database file 63 failed verification check
ORA-01110: data file 63: '/webdata/dbdata/ry/csh20051001.dat'
ORA-01251: Unknown File Header Version read for file number 63

分析問題:
因為資料檔案在沒有被offline的情況下實物理刪除了,導致oracle的資料不一致,因此啟動失敗.

解決方案:
lsnrctl stop
sqlplus internal
SQL> shutdown abort
SQL> startup mount
SQL> alter database datafile '/webdata/dbdata/ry/csh20051001.dat' offline drop;
SQL> alter database open;
SQL> drop tablespace r_csh_20051001;
lsnrctl start

其中省略了螢幕輸出內容.

小結:oracle資料檔案(datafile)被誤刪除後沒有恢複的辦法,只能把該資料檔案offline後drop掉

這是我們的實際操作記載!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.