控制檔案版本不一致下恢復資料庫
控制檔案跟重做日誌檔案一般都形成多路徑冗餘,區別在於日誌檔案只在日誌檔案組內
形成相互映像,而控制檔案是所有控制檔案相互形成映像。再者,控制檔案需要保持高度的
一致性,例如控制檔案的內容等,總的來說就是版本保持一致性。以下是測試控制檔案版本
不一致對資料庫的影響,進而恢復的過程:
----控制檔案的恢復:
---檢視控制檔案的資訊:
sys@PROD>col name for a50
sys@PROD>select name,status from v$controlfile;
NAME STATUS
-------------------------------------------------- -------
/u01/app/oracle/oradata/PROD/control01.ctl
/u01/app/oracle/fast_recovery_area/PROD/control02.ctl
---系統上做一個備份用於切換:
[oracle@enmo ~]$ cd /u01/app/oracle/fast_recovery_area/PROD/
[oracle@enmo PROD]$ ls
archivelog autobackup control02.ctl onlinelog
[oracle@enmo PROD]$ cp control02.ctl control02.ctl.bak
[oracle@enmo PROD]$ ls
archivelog autobackup control02.ctl control02.ctl.bak onlinelog
[oracle@enmo PROD]$
---觸發一個檢測點:
sys@PROD>alter system checkpoint;
System altered.
#從這裡已經開始導致控制檔案的版本不一致。
---刪除原來的2號控制檔案並把備份切換過來作為2號控制檔案:
[oracle@enmo PROD]$ rm control02.ctl
[oracle@enmo PROD]$ mv control02.ctl.bak control02.ctl
[oracle@enmo PROD]$
---再觸發一次檢測點:
sys@PROD>alter system checkpoint;
System altered.
---嘗試建立一個測試表:
sys@PROD>create table tests(id number(2),name varchar2(10));
create table tests(id number(2),name varchar2(10))
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 17656
Session ID: 1 Serial number: 7
#此時報錯,無法連線資料庫。
---嘗試關閉資料庫:
sys@PROD>shutdown immediate;
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
sys@PROD>
---退出sqlplus重新登入並嘗試登入資料庫:
[oracle@enmo ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 22 23:01:14 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
PROD>startup
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 507513936 bytes
Database Buffers 322961408 bytes
Redo Buffers 2371584 bytes
ORA-00214: control file '/u01/app/oracle/oradata/PROD/control01.ctl' version
4951 inconsistent with file
'/u01/app/oracle/fast_recovery_area/PROD/control02.ctl' version 4946
#此時報錯,兩個控制檔案的版本不一致。
---檢視此時例項的狀態:
PROD>select status from v$instance;
STATUS
------------
STARTED
---到作業系統層刪除2號控制檔案,並從1號控制檔案複製一份保持版本一致:
[oracle@enmo PROD]$ pwd
/u01/app/oracle/fast_recovery_area/PROD
[oracle@enmo PROD]$ rm control02.ctl
[oracle@enmo PROD]$ ls
archivelog autobackup onlinelog
[oracle@enmo PROD]$ pwd
/u01/app/oracle/oradata/PROD
[oracle@enmo PROD]$
[oracle@enmo PROD]$ cp control01.ctl /u01/app/oracle/fast_recovery_area/PROD/control02.ctl
[oracle@enmo PROD]$ pwd
/u01/app/oracle/fast_recovery_area/PROD
[oracle@enmo PROD]$ ls
archivelog autobackup control02.ctl onlinelog
#已經完成複製保持著兩個控制檔案的版本一致。
---嘗試把例項調至mount狀態:
PROD>alter database mount;
Database altered.
--alter日誌的記錄:
Tue Nov 22 23:11:34 2016
alter database mount
Tue Nov 22 23:11:38 2016
Successful mount of redo thread 1, with mount id 340427558
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: alter database mount
--檢視當前例項的狀態:
PROD>select status from v$instance;
STATUS
------------
MOUNTED
#例項mount狀態。
---嘗試開啟資料庫到open狀態:
PROD>alter database open;
Database altered.
PROD>select status from v$instance;
STATUS
------------
OPEN
#資料庫已經開啟成功。
--控制檔案版本不一致的恢復也相對簡單一些,與丟失一個的恢復過程與難度相似,只是前者比後者
稍微多了一些刪除步驟,後面同樣的從一個最新版本複製一個副本到舊版本的路徑目錄下,然後在開啟資料庫。
當然,還有當全部的控制檔案丟失或者損壞的情況下,可以透過最近最新的rman控制檔案自動備份檔案恢復,
或者把控制檔案轉儲備份到trace檔案,透過trace檔案的記錄,手動重新建立控制檔案來恢復資料庫。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2128912/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 備份與恢復--重新控制檔案資料字典和控制檔案不一致的恢復
- 【備份恢復】 控制檔案之版本不一致 之恢復操作
- 使用備份的控制檔案恢復資料庫資料庫
- 使用NORESETLOGS重建控制檔案恢復資料庫資料庫
- 使用RESETLOGS重建控制檔案恢復資料庫資料庫
- 【資料庫資料恢復】EXT3檔案系統下MYSQL資料庫恢復案例資料庫資料恢復MySql
- 丟失一個控制檔案並恢復資料庫資料庫
- 使用RESETLOGS重建控制檔案恢復資料庫(二)資料庫
- rman恢復資料庫--用備份的控制檔案資料庫
- 控制檔案被破壞的資料庫恢復方法資料庫
- Linux下誤刪資料檔案從檔案控制程式碼恢復資料檔案Linux
- 【資料庫資料恢復】透過恢復NDF檔案修復資料庫的資料恢復過程資料庫資料恢復
- RMAN恢復案例:無恢復目錄,丟失全部資料檔案、控制檔案、日誌檔案恢復
- 【備份恢復】利用 備份控制檔案到指定目錄下的控制檔案 恢復控制檔案
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- Bak檔案恢復到資料庫資料庫
- 跨版本資料庫恢復資料庫
- 備份與恢復--重建控制檔案後資料檔案損壞的恢復
- 丟失已歸檔日誌檔案下恢復資料庫資料庫
- Oracle資料庫控制檔案在備份恢復中的作用Oracle資料庫
- 【原創】模擬控制檔案丟失的資料庫恢復資料庫
- 控制檔案恢復—從trace檔案中恢復
- 通過控制程式碼恢復Linux下誤刪除的資料庫資料檔案Linux資料庫
- windows重灌/資料庫物理檔案完好的情況下恢復資料庫Windows資料庫
- 伺服器資料恢復-ext3檔案系統下oracle資料庫資料恢復案例伺服器資料恢復Oracle資料庫
- 當oracle丟失所有控制檔案後可以重新建立控制檔案來恢復資料庫Oracle資料庫
- 【資料庫資料恢復】Sql Server資料庫檔案丟失的資料恢復過程資料庫資料恢復SQLServer
- 引數檔案控制檔案和資料檔案丟失的恢復
- 同時丟失控制檔案與資料檔案的恢復
- Linux救援模式下拷貝Oracle資料檔案,恢復資料庫Linux模式Oracle資料庫
- 恢復案例:歸檔模式下丟失全部資料檔案的恢復模式
- RMAN恢復控制檔案
- 手工恢復控制檔案
- 在歸檔下恢復系統資料檔案
- 資料庫資料恢復-SQL SERVER資料庫檔案大小變為“0”的資料恢復方案資料庫資料恢復SQLServer
- 【恢復】使用控制檔案的trace備份恢復因異常斷電導致所有控制檔案損壞的資料庫故障資料庫
- 控制檔案恢復—從快照中恢復
- 只有.dbf資料檔案進行資料庫恢復資料庫