在數據庫服務器異常斷電重啟后,數據庫會進行實例恢復,那么實例恢復的過程中Oracle做了什么操作呢?參考官網在這里做一下解釋,菜鳥水平有限,歡迎勘正。
首先說下實例恢復的定義:
Instance recovery is the process of applying records in the online redo log to data files to reconstruct changes made after the most recent checkpoint. Instance recovery occurs automatically when an administrator attempts to open a database that was previously shut down inconsistently.
Oracle Database performs instance recovery automatically in the following situations:
-
The database opens for the first time after the failure of a single-instance database or all instances of an Oracle RAC database. This form of instance recovery is also called crash recovery. Oracle Database recovers the online redo threads of the terminated instances together.
-
Some but not all instances of an Oracle RAC database fail. Instance recovery is performed automatically by a surviving instance in the configuration.
The SMON background process performs instance recovery, applying online redo automatically. No user intervention is required.
因此我們知道非一致性關閉會引發實例恢復(一致性關閉不會,參考shutdown immediate的官方定義)同時RAC節點宕機也會在一個存活節點進行實例恢復,其過程就是重構內存中的臟塊并提交,同時對未提交的做出回滾,這個過程由smon后臺進程負責。
這里上一幅官網的圖:
圖:Basic Instance Recovery Steps: Rolling Forward and Rolling Back
Instance Recovery Phases
The first phase of instance recovery is called cache recovery or rolling forward, and involves reapplying all of the changes recorded in the online redo log to the data files. Because rollback data is recorded in the online redo log, rolling forward also regenerates the corresponding undo segments.
Rolling forward proceeds through as many online redo log files as necessary to bring the database forward in time. After rolling forward, the data blocks contain all committed changes recorded in the online redo log files. These files could also contain uncommitted changes that were either saved to the data files before the failure, or were recorded in the online redo log and introduced during cache recovery.
After the roll forward, any changes that were not committed must be undone. Oracle Database uses the checkpoint position, which guarantees that every committed change with an SCN lower than the checkpoint SCN is saved on disk. Oracle Database applies undo blocks to roll back uncommitted changes in data blocks that were written before the failure or introduced during cache recovery. This phase is called rolling back or transaction recovery.
文章列表