使用BBED修改檔案頭解決資料庫Open驗證問題(上)
筆者在《一次資料檔案映象丟失引起的故障解決》(http://blog.itpub.net/17203031/viewspace-2126579/)中,使用了強制關閉資料庫Open過程中完整性驗證來開啟資料庫。除此之外,還可以使用資料檔案頭修改的方法,“騙過”Oracle啟動機制。
本篇就透過BBED來模擬錯誤和進行修復。注意:BBED是Oracle研究的利器,但是同樣也可能是“塌天大禍”的起始。所以,如果沒有100%把握,絕對不要輕易在投產環境上應用。作為技術人員,創新精神是可貴的,但是謹慎認真是更需要的一種職業素養。
1、環境說明
筆者使用Oracle 11gR2進行測試,具體版本為11.2.0.4。
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 – Production
當前資料檔案列表如下:
SQL> select file#, checkpoint_change#, checkpoint_time, name from v$datafile;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME NAME
---------- ------------------ --------------- --------------------------------------------------------------------------------
1 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_system_bw773xok_.dbf
2 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_sysaux_bw773xpr_.dbf
3 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_undotbs1_bw773xqo_.dbf
4 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_users_bw773xrv_.dbf
5 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_TESTdev_bw8xbqrz_.dbf
6 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_inttestt_bw8xdnkt_.dbf
7 1713752 2016/10/18 22:0 /u01/app/oracle/oradata/TESTDB/datafile/o1_mf_epssite_by19vtnh_.dbf
7 rows selected
2、故障模擬
筆者的思路是:在資料庫正常執行過程中,抽取資料檔案7。Datafile 7對應的是一個過去時間的SCN編號和檔案頭。之後,透過一系列的Online Redo Log切換、手工檢查點操作,最後直接shutdown immediate關閉伺服器動作,推動資料庫所有資料檔案SCN編號前進。
關閉之後,使用過去版本的資料檔案7來替換檔案。啟動資料庫進入open狀態之後,如果當前online redo log已經乜有接續的檔案(被覆蓋+非歸檔),系統報錯。
當前檔案目錄,複製留存一箇舊版本的datafile 7。
[oracle@TESTlife datafile]$ ls -l
total 6482252
-rw-r----- 1 oracle oinstall 2017468416 Oct 18 22:05 o1_mf_epssite_by19vtnh_.dbf
-rw-r----- 1 oracle oinstall 1702895616 Oct 18 22:05 o1_mf_inttestt_bw8xdnkt_.dbf
-rw-r-----. 1 oracle oinstall 5251072 Oct 18 22:05 o1_mf_users_bw773xrv_.dbf
(篇幅原因,有省略……)
[oracle@TESTlife datafile]$ cp o1_mf_epssite_by19vtnh_.dbf o1_mf_epssite_by19vtnh_.dbf_bk
[oracle@TESTlife datafile]$ ls -l
total 8452440
-rw-r----- 1 oracle oinstall 2017468416 Oct 18 22:05 o1_mf_epssite_by19vtnh_.dbf
-rw-r----- 1 oracle oinstall 2017468416 Oct 18 22:12 o1_mf_epssite_by19vtnh_.dbf_bk
-rw-r----- 1 oracle oinstall 1702895616 Oct 18 22:05 o1_mf_inttestt_bw8xdnkt_.dbf
-rw-r----- 1 oracle oinstall 1283465216 Oct 18 22:05 o1_mf_TESTdev_bw8xbqrz_.dbf
-rw-r-----. 1 oracle oinstall 597696512 Oct 18 22:10 o1_mf_sysaux_bw773xpr_.dbf
多次切換日誌,進行檢查點操作。
SQL> alter system switch logfile;
System altered
(篇幅原因,有省略……)
SQL> alter system checkpoint;
System altered
SQL> alter system switch logfile;
System altered
SQL> select group#, status, FIRST_CHANGE# from v$log;
GROUP# STATUS FIRST_CHANGE#
---------- ---------------- -------------
1 CURRENT 1714475
2 INACTIVE 1714464
3 INACTIVE 1714467
關閉資料庫,強行使用舊版本檔案替換。
[oracle@TESTlife datafile]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 18 22:14:53 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@TESTlife datafile]$ cp o1_mf_epssite_by19vtnh_.dbf o1_mf_epssite_by19vtnh_.dbf_bk_f
[oracle@TESTlife datafile]$ ls -l
total 10422628
-rw-r----- 1 oracle oinstall 2017468416 Oct 18 22:15 o1_mf_epssite_by19vtnh_.dbf
-rw-r----- 1 oracle oinstall 2017468416 Oct 18 22:12 o1_mf_epssite_by19vtnh_.dbf_bk
-rw-r----- 1 oracle oinstall 2017468416 Oct 18 22:20 o1_mf_epssite_by19vtnh_.dbf_bk_f
-rw-r----- 1 oracle oinstall 1702895616 Oct 18 22:15 o1_mf_inttestt_bw8xdnkt_.dbf
-rw-r----- 1 oracle oinstall 1283465216 Oct 18 22:15
[oracle@TESTlife datafile]$ cp o1_mf_epssite_by19vtnh_.dbf_bk o1_mf_epssite_by19vtnh_.dbf
啟動資料庫,在open過程中報錯。
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 3540881408 bytes
Fixed Size 2258320 bytes
Variable Size 855640688 bytes
Database Buffers 2667577344 bytes
Redo Buffers 15405056 bytes
Database mounted.
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7:
'/u01/app/oracle/oradata/TESTDB/datafile/o1_mf_epssite_by19vtnh_.dbf'
使用redo log進行修復,失敗。
SQL> recover datafile 7
ORA-00279: change 1713752 generated at 10/18/2016 22:00:25 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/fast_recovery_area/TESTDB/archivelog/2016_10_18/o1_mf_1_60_%u_.a
rc
ORA-00280: change 1713752 for thread 1 is in sequence #60
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00308: cannot open archived log
'/u01/app/oracle/fast_recovery_area/TESTDB/archivelog/2016_10_18/o1_mf_1_60_%u_.
arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
故障出現,嘗試進行修復。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17203031/viewspace-2126665/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 使用BBED修改檔案頭解決資料庫Open驗證問題(下)資料庫
- BBED 修改檔案頭 解決 ORA-01190
- 【kingsql分享】使用BBED修改Oracle資料檔案頭推進SCNSQLOracle
- [20150527]bbed解決資料檔案大小問題.txt
- 資料檔案拷貝檔案頭驗證錯誤
- [20160405]bbed修改檔案頭.txt
- 解決requests庫中SSL驗證問題
- 【BBED】使用bbed修改數字型別資料型別
- 【BBED】使用bbed修改字元型別資料字元型別
- 【BBED】使用BBED修改資料檔案SCN,使該檔案從offline轉變為online
- 資料庫突然當機無法open的問題及解決資料庫
- 解決Oracle資料庫日誌檔案丟失恢復問題Oracle資料庫
- excel檔案內容匯入資料庫的問題及解決Excel資料庫
- 【BBED】使用bbed 修改日期型別的資料型別
- BBED 修改oracle 資料檔案的 SCN 號來做資料庫不完全恢復。Oracle資料庫
- oracle_bbed.Datafile.Header_System.資料檔案頭資訊OracleHeader
- 資料庫檔案複製問題和解決辦法資料庫
- bbed 與檔案頭恢復
- [20160407]bbed修改檔案頭2(補充).txt
- linux上“rman can't open target”問題解決Linux
- oracle資料檔案驗證工具Oracle
- 安裝資料庫和資料庫解決問題資料庫
- Tomcat中訪問資料庫使用屬性檔案問題Tomcat資料庫
- 資料庫問題求證資料庫
- 檔案系統異常引起的資料庫open失敗的解決過程資料庫
- PHP檔案頭BOM頭問題PHP
- 資料庫層面問題解決思路資料庫
- Oracle資料庫頻繁歸檔問題的解決辦法Oracle資料庫
- 資料庫系列:大廠使用資料庫中介軟體解決什麼問題?資料庫
- 不修改任何檔案,完美解決QQ與360共存問題
- element-ui使用from表單驗證資料問題UI
- elment UI 表格 item 驗證問題解決方案UI
- 解決mac上Navicat新建資料庫3680錯誤問題跽勒Mac資料庫
- 使用BBED檢視SYSTEM檔案頭的root dba及bootstrap$boot
- 使用bulkCollect解決資料遷移問題
- 解決WAMP環境修改apache配置檔案不生效問題(Laravel public)ApacheLaravel
- SqlServer資料庫中文亂碼問題解決SQLServer資料庫
- 解決被掛起的資料庫問題資料庫