共計 3934 個字符,預計需要花費 10 分鐘才能閱讀完成。
行業資訊
數據庫
關系型數據庫
Oracle 表空間誤刪除導致 startup 啟動時提示 ORA-01110 和 ORA-01157 錯誤怎么辦
這篇文章主要講解了“Oracle 表空間誤刪除導致 startup 啟動時提示 ORA-01110 和 ORA-01157 錯誤怎么辦”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學習“Oracle 表空間誤刪除導致 startup 啟動時提示 ORA-01110 和 ORA-01157 錯誤怎么辦”吧!
今天遇到一個比較神奇的問題,客戶某套測試數據庫斷電重啟了,重啟時發現數據庫提示 ORA-01157: cannot identify/lock data file 和 ORA-01110 的錯誤,經過檢查發現是系統啟動后未掛載存儲,表空間都放在存儲盤上,手工掛載存儲后所有問題迎刃而解。當時沒有記錄問題,這里通過測試環境模擬重現問題。
制造實驗數據
[oracle@XLJ181 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 10 19:27:14 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@cams create tablespace test datafile /home/oracle/test.dbf size 100M;
Tablespace created.
SYS@cams create user test identified by 123456 default tablespace test;
User created.
SYS@cams grant connect,resource to test;
Grant succeeded.
TEST@cams create table test(id number primary key,name varchar2(20));
Table created.
TEST@cams insert into test values(1, bob
1 row created.
TEST@cams insert into test values(2, joe
1 row created.
TEST@cams select count(*) from test;
COUNT(*)
----------
2
TEST@cams conn / as sysdba
Connected.
SYS@cams shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@cams exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
模擬文件誤刪除
[oracle@XLJ181 ~]$ mv /home/oracle/test.dbf /home/oracle/test.dbf.bak
故障出現
啟動數據庫,發現數據文件不存在:
[oracle@XLJ181 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 10 19:38:26 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SYS@cams startup;
ORACLE instance started.
Total System Global Area 5344731136 bytes
Fixed Size 2262656 bytes
Variable Size 1040189824 bytes
Database Buffers 4294967296 bytes
Redo Buffers 7311360 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 63 - see DBWR trace file
ORA-01110: data file 63: /home/oracle/test.dbf
查看 trace 文件:
Mon Dec 10 19:38:35 2018
ALTER DATABASE OPEN
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_dbw0_21153.trc:
ORA-01157: cannot identify/lock data file 63 - see DBWR trace file
ORA-01110: data file 63: /home/oracle/test.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_ora_21175.trc:
ORA-01157: cannot identify/lock data file 63 - see DBWR trace file
ORA-01110: data file 63: /home/oracle/test.dbf
ORA-1157 signalled during: ALTER DATABASE OPEN...
查看 cams_ora_21175.trc 文件,報錯信息如下:
DDE: Problem Key ORA 1110 was flood controlled (0x1) (no incident)
ORA-01110: data file 63: /home/oracle/test.dbf
ORA-01157: cannot identify/lock data file 63 - see DBWR trace file
ORA-01110: data file 63: /home/oracle/test.dbf
查看 cams_dbw0_21153.trc 文件,報錯信息如下:
ORA-01157: cannot identify/lock data file 63 - see DBWR trace file
ORA-01110: data file 63: /home/oracle/test.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
問題已經很明顯了,就是找不到 data file 63: /home/oracle/test.dbf。
針對該問題,我們應該怎么去處理呢?特別是測試環境,一般為了節約資源,不會開啟歸檔,更不會有 RMAN 備份,那怎么讓數據庫跑起來,讓數據損失降到最低呢?
常用解決方案:offline drop+recreate
SQL shutdown immediate;
SQL startup mount;
SQL alter database datafile /home/oracle/test.dbf offline drop;
SQL alter database open;
SQL drop tablespace test including contents; -- 注意:執行之前檢查是否還有其他文件屬于該表空間
SQL create tablespace test datafile /home/oracle/test.dbf size 100M;
因為是測試環境,想辦法重建數據或者利用最近的邏輯備份或其他測試導入數據,這樣能把數據損失降到最低。
如果刪除的是核心系統的表空間,那么還不如重建表空間之后把相關數據清理之后重新導入一份。
感謝各位的閱讀,以上就是“Oracle 表空間誤刪除導致 startup 啟動時提示 ORA-01110 和 ORA-01157 錯誤怎么辦”的內容了,經過本文的學習后,相信大家對 Oracle 表空間誤刪除導致 startup 啟動時提示 ORA-01110 和 ORA-01157 錯誤怎么辦這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關知識點的文章,歡迎關注!