PMON、SMON、DBWn、LGWR、CKPT、ARCH等後臺程式說明

lusklusklusk發表於2017-07-13
Process Monitor (PMON): 該程式在使用者程式出現故障時執行程式恢復,負責清理記憶體儲區和釋放該程式所使用的資源。例:它要重置活動事務表的狀態,釋放封鎖,將該故障的程式的ID從活動程式表中移去。動態註冊資訊至監聽器。
performs process recovery when a user process fials
--cleans up the database buffer cache
--frees resources that are used by the user process
monitors sessions for idle session timeout
dynamically registers database services with listeners
When an instance starts, PMON polls the listener to determine whether it is running. If the listener is running, then PMON passes it relevant parameters. If it is not running, then PMON periodically attempts to contact it.


System Monitor (SMON):該程式在例項啟動時執行例項恢復,還負責清理不再使用的臨時段。
performs recovery at instance startup
clear up unused temporary segments


Checkpoint Process(CKPT):
完全檢查點把checkpoint寫入控制檔案和資料檔案頭部
增量檢查點只把checkpoint寫入控制檔案

Records checkpoint information in 

--controlfile
--each data file header
The checkpoint process (CKPT) updates the control file and data file headers with checkpoint information and signals DBWn to write blocks to disk. Checkpoint information includes the checkpoint position, SCN, location in online redo log to begin recovery, and so on.CKPT does not write data blocks to data files or redo blocks to online redo log files.
When Oracle Database Initiates Checkpoints
--Consistent database shutdown(完全檢查點)
--ALTER SYSTEM CHECKPOINT statement(完全檢查點)
如果LGWR的下一個日誌是ACTIVE,那麼LWGR會掛起,警告日誌會報告"Checkpoint not complete",oracle會發起alter system checkpoint的操作

--Online redo log switch(增量檢查點)
--ALTER DATABASE BEGIN BACKUP statement(完全檢查點)
--Tablespace and data file checkpoints such as ALTER TABLESPACE BEGIN BACKUP(完全檢查點)
--Incremental checkpoints(增量檢查點)
完全檢查點:個人更願意理解只有V$DATABASE.CHECKPOINT_CHANGE#增加了才算發生了一次完全檢查點。雖然完全檢查點的定義是隻要同時寫入資料檔案頭部和控制檔案就認為是完全檢查點。按個人理解其實上面BEGIN BACKUP這樣的操作就不算完全檢查點了。
database checkpoint:The thread checkpoint that has the lowest SCN. All changes in all enabled redo threads with SCNs before the database checkpoint SCN are guaranteed to have been written to disk.
--
Online redo log switch時只有V$DATABASE.CONTROLFILE_CHANGE#變大
--ALTER DATABASE BEGIN BACKUP時V$DATABASE.CHECKPOINT_CHANGE#沒變,雖然V$DATABASE.CONTROLFILE_CHANGE#、V$DATAFILE.CHECKPOINT_CHANGE#、V$DATAFILE_HEADER.CHECKPOINT_CHANGE#都變大

--alter tablespace users begin backup時,V$DATABASE.CONTROLFILE_CHANGE#、對應的表空間檔案V$DATAFILE.CHECKPOINT_CHANGE#、對應的表空間檔案V$DATAFILE_HEADER.CHECKPOINT_CHANGE#變大,$DATABASE.CHECKPOINT_CHANGE#和其他表空間對應資料檔案CHECKPOINT_CHANGE#沒變



Database Writer Process (DBWn):雜湊寫即隨機IO,DBWn程式可以有多個
The database writer process (DBWn) writes the contents of database buffers to data files. DBWn processes write modified buffers in the database buffer cache to disk
Although one database writer process (DBW0) is adequate for most systems, you can configure additional processes—DBW1 through DBW9 and DBWa through DBWj—to improve write performance if your system modifies data heavily. These additional DBWn processes are not useful on uniprocessor(單處理器) systems.
In many cases the blocks that DBWn writes are scattered throughout the disk. Thus, the writes tend to be slower than the sequential writes performed by LGWR. DBWn performs multiblock writes when possible to improve efficiency. 
The DBWn process writes dirty buffers to disk under the following conditions:
--When a server process cannot find a clean reusable buffer after scanning a threshold number of buffers, it signals DBWn to write. DBWn writes dirty buffers to disk asynchronously if possible while performing other processing.
--DBWn periodically(定期) writes buffers to advance the checkpoint


Log Writer Process (LGWR):順序寫即順序IO,LGWR程式只能有一個,按漏斗原理,LGWR寫入的最佳化是ORACLE最終極的最佳化目標
The log writer process (LGWR) manages the redo log buffer. LGWR writes one contiguous portion(一個連續區域) of the buffer to the online redo log. By separating the tasks of modifying database buffers, performing scattered writes of dirty buffers to disk, and performing fast sequential writes of redo to disk, the database improves performance.
In the following circumstances, LGWR writes all redo entries that have been copied into the buffer since the last time it wrote:
--A user commits a transaction.
--An online redo log switch occurs.
--Three seconds have passed since LGWR last wrote.
--The redo log buffer is one-third full or contains 1 MB of buffered data.
--DBWn must write modified buffers to disk.



ARCH程式日誌歸檔觸發條件
 1. 如果設定了自動歸檔模式,則日誌切換時,由LGWR程式觸發ARCH程式進行歸檔。這是最常見的方式。
 2. 可以手工進行歸檔。使用命令:alter system archive log current表示啟動ARCH程式,從而對當前的日誌檔案進行歸檔。
 3. 如果ARCH程式在5分鐘以後還沒有接收到LGWR的通知,則發生超時,於是ARCH被喚醒以檢查是否存在需要歸檔的日誌檔案。ARCH透過讀取控制檔案中的資訊來決定是否需要歸檔以及應該歸檔哪些日誌檔案。但是在進行例項恢復或者介質恢復的過程中,ARCH程式不會啟動。


Manageability Monitor Processes (MMON and MMNL):主要用於AWR,ADDM,觸發SGA中的統計資訊寫到系統表,也觸發統計資訊收集
The manageability monitor process (MMON) performs many tasks related to the Automatic Workload Repository (AWR). For example, MMON writes when a metric violates its threshold value, taking snapshots, and capturing statistics value for recently modified SQL objects.capturing statistics value for SQL object that have been recently modified

The manageability monitor lite process (MMNL) writes statistics from the Active Session History (ASH) buffer in the SGA to disk. MMNL writes to disk when the ASH buffer is full.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2142022/,如需轉載,請註明出處,否則將追究法律責任。

相關文章