ORALCE重要後台進程

來源:互聯網
上載者:User

何時觸發lgwr,dbwr,chpk等進程     
Log Writer (LGWR)   
LGWR performs sequential writes from the Redo Log Buffer to the online redo log file under the followingsituations:   
     1.When a transaction commits   
     2.When the Redo Log Buffer is

 one-third full  
     3.When there is more than 1 MB of changes recorded in the Redo Log Buffer   
     4.Before DBWn writes modified blocks in the Database Buffer Cache to the
data files   
     5.Every three seconds   
   
.Because the redo is needed for recovery, LGWR confirms the commit operation only after the redo is written todisk.   
LGWR can also call on DBWn to write to the data files.   
  
  
Database Writer (DBWn)   
The server process records changes to undo and data blocks
in the Database Buffer Cache. DBWn writes thedirty buffers from the Database Buffer Cache to the data files. It ensures that a sufficient number of free buffers(buffers that can be overwritten when server processes need to read in blocks from the data files)
are availablein the Database Buffer Cache. Database performance is improved because server processes make changes onlyin the Database Buffer Cache.   
DBWn defers writing to the data files until one of the following events occurs:   
     Incremental or normal checkpoint  
     The number of dirty buffers reaches a threshold value   
     A process scans a specified number of blocks when scanning for free buffers and cannot find any  
     Timeout occurs   
     A ping request in Real Application Clusters (RAC) environment   
     Placing a normal or temporary tablespace offline   
     Placing a tablespace in read-only mode   
     Dropping or truncating a table  
     ALTER TABLESPACEtablespace nameBEGIN BACKUP   
  
1. 當Buffer Cache中的Dirty List長度達到閥值:   
DBWR將Dirty List中的Dirty Buffer寫入磁碟(user Server Process在LRU List中尋找free buffer時將碰到的dirty blocks移入Dirty List)   
  
2. 當user Server Process在Buffer Cache的LRU List中搜尋了過長的時間而仍然沒有找到free buffer:   
DBWR直接從LRU List中將Dirty Buffer寫入磁碟   
  
3. 每過3秒鐘:   
DBWR把dirty buffers從LRU List移到Dirty List,一旦Dirty List長度達到閥值,DBWR便將資料寫入磁碟   
  
4. Checkpoint發生時:   
DBWR把所有的dirty buffers從LRU List移到Dirty List,並且開始寫資料   
  
5. 當Tablespace開始Hot backup時:   
DBWR把所有屬於該資料表空間的dirty buffers從LRU List移到Dirty List,並且開始寫資料   
  
6. 當Tablespace offline時:   
DBWR把所有屬於該資料表空間的dirty buffers從LRU List移到Dirty List,並且開始寫資料   
  
7. 執行Drop時:   
drop table或者index將促使DBWR先將屬於該segment的dirty
blocks寫入磁碟   
  
  
checkpoint

checkpoint是一個資料庫事件,它將已修改的資料從快取重新整理到磁碟,並更新控制檔案和資料檔案。   
我們知道了checkpoint會重新整理髒資料,但什麼時候會發生checkpoint呢?以下幾種情況會觸發checkpoint。   
  
1.當發生日誌組切換的時候   
2.當符合LOG_CHECKPOINT_TIMEOUT,LOG_CHECKPOINT_INTERVAL,fast_start_io_target,fast_start_mttr_target參數設定的時候   
3.當運行ALTER SYSTEM SWITCH LOGFILE的時候   
4.當運行ALTER SYSTEM CHECKPOINT的時候   
5.當運行alter tablespace XXX begin backup,end backup的時候   
6.當運行alter tablespace ,datafile offline的時候;  
何時觸發lgwr,dbwr,chpk等進程  
Log Writer (LGWR)
LGWR performs sequential writes from the Redo Log Buffer to the online redo log file under the followingsituations:
     1.When a transaction commits
     2.When the Redo Log Buffer is one-third full
     3.When there is more than 1 MB of changes recorded in the Redo Log Buffer
     4.Before DBWn writes modified blocks in the Database Buffer Cache to the data files
     5.Every three seconds

.Because the redo is needed for recovery, LGWR confirms the commit operation only after the redo is written todisk.
LGWR can also call on DBWn to write to the data files.

Database Writer (DBWn)
The server process records changes to undo and data blocks in the Database Buffer Cache. DBWn writes thedirty buffers from the Database Buffer Cache to the data files. It ensures that a sufficient number of free buffers(buffers that can be overwritten
when server processes need to read in blocks from the data files) are availablein the Database Buffer Cache. Database performance is improved because server processes make changes onlyin the Database Buffer Cache.
DBWn defers writing to the data files until one of the following events occurs:
     Incremental or normal checkpoint
     The number of dirty buffers reaches a threshold value
     A process scans a specified number of blocks when scanning for free buffers and cannot find any
     Timeout occurs
     A ping request in Real Application Clusters (RAC) environment
     Placing a normal or temporary tablespace offline
     Placing a tablespace in read-only mode
     Dropping or truncating a table
     ALTER TABLESPACEtablespace nameBEGIN BACKUP
1. 當Buffer Cache中的Dirty List長度達到閥值:
DBWR將Dirty List中的Dirty Buffer寫入磁碟(user Server Process在LRU List中尋找free buffer時將碰到的dirty blocks移入Dirty List)
2. 當user Server Process在Buffer Cache的LRU List中搜尋了過長的時間而仍然沒有找到free buffer:
DBWR直接從LRU List中將Dirty Buffer寫入磁碟
3. 每過3秒鐘:
DBWR把dirty buffers從LRU List移到Dirty List,一旦Dirty List長度達到閥值,DBWR便將資料寫入磁碟
4. Checkpoint發生時:
DBWR把所有的dirty buffers從LRU List移到Dirty List,並且開始寫資料
5. 當Tablespace開始Hot backup時:
DBWR把所有屬於該資料表空間的dirty buffers從LRU List移到Dirty List,並且開始寫資料
6. 當Tablespace offline時:
DBWR把所有屬於該資料表空間的dirty buffers從LRU List移到Dirty List,並且開始寫資料
7. 執行Drop時:
drop table或者index將促使DBWR先將屬於該segment的dirty blocks寫入磁碟

checkpoint是一個資料庫事件,它將已修改的資料從快取重新整理到磁碟,並更新控制檔案和資料檔案。
我們知道了checkpoint會重新整理髒資料,但什麼時候會發生checkpoint呢?以下幾種情況會觸發checkpoint。
1.當發生日誌組切換的時候
2.當符合LOG_CHECKPOINT_TIMEOUT,LOG_CHECKPOINT_INTERVAL,fast_start_io_target,fast_start_mttr_target參數設定的時候
3.當運行ALTER SYSTEM SWITCH LOGFILE的時候
4.當運行ALTER SYSTEM CHECKPOINT的時候
5.當運行alter tablespace XXX begin backup,end backup的時候
6.當運行alter tablespace ,datafile offline的時候;

PMON進程:
       該進程在使用者進程出現故障時執行進程恢複,負責清理記憶體儲區和釋放該進程所使用的資源。例:它要重設活動事務表的狀態,釋放封鎖,將該故障的進程的ID從活動進程表中移去。PMON還周期地檢查調度進程(DISPATCHER)和伺服器進程的狀態,如果已死,則重新啟動(不包括有意刪除的進程)。
PMON有規律地被呼醒,檢查是否需要,或者其它進程發現需要時可以被調用。

SMON進程:
        該進程執行個體啟動時執行執行個體恢複,還負責清理不再使用的臨時段。在具有並行伺服器選項的環境下,SMON對有故障CPU或執行個體進行執行個體恢複。SMON進程有規律地被呼醒,檢查是否需要,或者其它進程發現需要時可以被調用。

DBWR進程:
        該進程執行將緩衝區寫入資料檔案,是負責緩衝儲存區管理的一個ORACLE後台進程。當緩衝區中的一緩衝區被修改,它被標誌為“弄髒”,DBWR的主要任務是將“弄髒”的緩衝區寫入磁碟,使緩衝區保持“乾淨”。由於緩衝儲存區的緩衝區填入資料庫或被使用者進程弄髒,未用的緩衝區的數目減少。當未用的緩衝區下降到很少,以致使用者進程要從磁碟讀入塊到記憶體儲存區時無法找到未用的緩衝區時,DBWR將管理緩衝儲存區,使使用者進程總可得到未用的緩衝區。
ORACLE採用LRU(LEAST RECENTLY USED)演算法(最近最少使用演算法)保持記憶體中的資料區塊是最近使用的,使I/O最小。在下列情況預示DBWR 要將弄髒的緩衝區寫入磁碟:
1、當一個伺服器處理序將一緩衝區移入“弄髒”表,該弄髒表達到臨界長度時,該服務進程將通知DBWR進行寫。該臨界長度是為參數DB-BLOCK-WRITE-BATCH的值的一半。
2、 當一個伺服器處理序在LRU表中尋找DB-BLOCK-MAX-SCAN-CNT緩衝區時,沒有查到未用的緩衝區,它停止尋找並通知DBWR進行寫。
3、出現逾時(每次3秒),DBWR 將通知本身。
4、 當出現檢查點時,LGWR將通知DBWR 在前兩種情況下,DBWR將弄髒表中的塊寫入磁碟,每次可寫的塊數由初始化參數DB-BLOCK-WRITE-BATCH所指定。如果弄髒表中沒有該參數指定塊數的緩衝區,DBWR從LUR表中尋找另外一個弄髒緩衝區。 如果DBWR在三秒內未活動,則出現逾時。在這種情況下DBWR對LRU表尋找指定數目的緩衝區,將所找到任何弄髒緩衝區寫入磁碟。每當出現逾時,DBWR尋找一個新的緩衝區組。每次由DBWR尋找的緩衝區的數目是為寢化參數DB-BLOCK-WRITE-BATCH的值的二倍。如果資料庫空運轉,DBWR最終將全部緩衝區儲存區寫入磁碟。
在出現檢查點時,LGWR指定一修改緩衝區表必須寫入到磁碟。DBWR將指定的緩衝區寫入磁碟。 在有些平台上,一個執行個體可有多個DBWR。在這樣的執行個體中,一些塊可寫入一磁碟,另一些塊可寫入其它磁碟。參數DB-WRITERS控制DBWR進程個數。

LGWR進程:
           該進程將日誌緩衝區寫入磁碟上的一個記錄檔,它是負責管理日誌緩衝區的一個ORACLE後台進程。LGWR進程將自上次寫入磁碟以來的全部日誌項輸出,LGWR輸出:
1、 當使用者進程提交一事務時寫入一個提交記錄。
2、每三秒將日誌緩衝區輸出。
3、 當日誌緩衝區的1/3已滿時將日誌緩衝區輸出。
4、當DBWR將修改緩衝區寫入磁碟時則將日誌緩衝區輸出。
LGWR進程同步地寫入到活動的鏡象線上記錄檔組。如果組中一個檔案被刪除或不可用,LGWR 可繼續地寫入該組的其它檔案。 日誌緩衝區是一個迴圈緩衝區。當LGWR將日誌緩衝區的日誌項寫入記錄檔後,
伺服器處理序可將新的日誌項寫入到該日誌緩衝區。LGWR 通常寫得很快,可確保日誌緩衝區總有空間可寫入新的日誌項。
注意:有時候當需要更多的日誌緩衝區時,LWGR在一個事務提交前就將日誌項寫出,而這些日誌項僅當在以後事務提交後才永久化。 ORACLE使用快速提交機制,當使用者發出COMMIT語句時,一個COMMIT記錄立即放入日誌緩衝區,但相應的資料緩衝區改變是被延遲,直到在更有效時才將它們寫入資料檔案。當一事務提交時,被賦給一個系統修改號(SCN),它同交易記錄項一起記錄在日誌中。由於SCN記錄在日誌中,以致在並行伺服器選項配置情況下,恢複操作可以同步。

聯繫我們

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