何时触发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 onlyafter 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 offree buffers(buffers that can be overwritten when server processes need toreadin 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 forfree buffers and cannot find any
Timeout occurs
A ping request inReal Application Clusters (RAC) environment
Placing a normal ortemporary tablespace offline
Placing a tablespace inread-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时:
droptable或者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的时候;
ITPUB相关帖子讨论 http://www.itpub.net/forum.php?mod=viewthread&tid=1775404