一.Background Processes
To maximize performance and accommodate many users, a multiprocess Oracle system uses some additional Oracle processes called background processes .
后台进程定义:为了最大的性能和容纳更多的用户,oracle使用额外的进程被叫做后台进程处理。
二、后台进程主要包括:
Database Writer Process(DBWn)
Log Writer Process(LGWR)
CheckPoint Process(CKPT)
System Monitor Process(SMON)
Process Monitor Process(PMON)
Recoverer Process(RECO)
Job Queue Processes
Archiver Processes(ARCn)
Queue Monitor Processes (QMNn)
Other Background Processes
三、DBWR
在什么触发dbwr进程的条件:
1.当脏缓冲区的数量超过了所设定的限额。
2.当所设定的时间间隔到了。
3.当有进程需要数据库高速缓冲区却找不到空闲的缓冲区时。
4.当校验点发生时。
5.当某个表被删除或被截断时。
6.当某个表空间被设置为只读状态时。
7.当使用类似于alter tablespace users begin backup的命令对某个表空间进行联机备份时。
8.当某个临时表空间被设置为只脱机状态或正常状态时。
可通过设置DB_WRITER_PROCESSES的参数来让多个DBWR来进行写操作
1.show parameter db_writer_processes
2.alter system set db_writer_processes=9 scope=spfile(网有说是最多10个dbwr同时进行写操作,但是官方的文档上说有20个 ,本人没有测试过 )
3.shutdown immediate
4.startup
官方文档关于dbwn的说明
Database Writer Process (DBW n )
The database writer process (DBWn) writes the contents of buffers to datafiles. The DBW n processes are responsible for writing modified (dirty) 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 DBW n processes are not useful on uniprocessor systems.
数据库的dbwn进程主要是把缓存的内容写到数据文件中。dbwn进程主要负责把数据库的高速缓存中的脏数据写到硬盘上。虽然一个dbwn进程能够满足大部分的系统,如果你的系统脏数据太多,你也可以配置(dbw1到dbw9或dbwa到dbwj)来改善写性能。在单进程的系统上增加dbwn进程没有用。
When a buffer in the database buffer cache is modified, it is marked dirty . A cold buffer is a buffer that has not been recently used according to the least recently used (LRU) algorithm. The DBW n process writes cold, dirty buffers to disk so that user processes are able to find cold, clean buffers that can be used to read new blocks into the cache. As buffers are dirtied by user processes, the number of free buffers diminishes. If the number of free buffers drops too low, user processes that must read blocks from disk into the cache are not able to find free buffers. DBW n manages the buffer cache so that user processes can always find free buffers.
在数据库高速缓存中当有一个缓存被修改,它就变成了脏数据了。一个冷缓存就是最近没有被访问的缓存块。dbwn进程写冷块,脏缓存到硬盘,所以用户进程能够找到冷块,清除缓,能把新的块读进缓存中去。缓存被用户进程变脏,空闲缓存的数量就变少了。如果空闲的缓存下降的太少了,如果缓存不能找到空闲的块用户进程就必须从硬盘中读块。dbwn管理着高速缓存是为了让用户进程总能找到空闲的缓存。
By writing cold, dirty buffers to disk, DBW n improves the performance of finding free buffers while keeping recently used buffers resident in memory. For example, blocks that are part of frequently accessed small tables or indexes are kept in the cache so that they do not need to be read in again from disk. The LRU algorithm keeps more frequently accessed blocks in the buffer cache so that when a buffer is written to disk, it is unlikely to contain data that will be useful soon.
写冷,脏块缓存到硬盘,当保存最近使用的缓存在内存中是为了让dbwn提高找到空闲的性能。比如,频繁的访问一个小表和索引放在缓存中,是为了他们不需要再次的从硬盘中读取数量。在高速缓存中用最近最少使用算法保存着频繁访问的块,为了当一个缓存被写到硬盘,不太可能和数据可能被很快就使用。
The initialization parameter
DB_WRITER_PROCESSES
specifies the number of DBW
n
processes. The maximum number of DBW
n
processes is 20. If it is not specified by the user during startup, Oracle determines how to set
DB_WRITER_PROCESSES
based on the number of CPUs and processor groups.
db_writer_processes初始化参数指定dbwn进程的数量。dbwn进程的数量最多是20。如果在运行期间用户没有指定,oracle会以cpu的数量和进程组来确定db_writer_processes的数量。
The DBW n process writes dirty buffers to disk under the following conditions:
dbwn进程写脏数据到硬盘在下面的几种情况:
-
When a server process cannot find a clean reusable buffer after scanning a threshold number of buffers, it signals DBW n to write. DBW n writes dirty buffers to disk asynchronously while performing other processing.
-
-
DBW n periodically writes buffers to advance the checkpoint , which is the position in the redo thread (log) from which instance recovery begins. This log position is determined by the oldest dirty buffer in the buffer cache.
-
dbwn定期的写缓存数据,为了使检查点向前。在高速缓存中重做位置是由最后脏缓存决定的。
四、LGWR
LGWR(日志写入程序)进程负责把联机重做日志缓冲区的内容写入联机重做日志文件。
触发LGWR的条件:
A commit record when a user process commits a transaction
当用户进程提交一个事务Redo log buffers
Every three seconds超过三分钟
When the redo log buffer is one-third full
当重写缓存达到三分之一时.
When a DBW n process writes modified buffers to disk, if necessary
当dbwn进程写脏缓存到硬盘.
The log writer process (LGWR) is responsible for redo log buffer management—writing the redo log buffer to a redo log file on disk. LGWR writes all redo entries that have been copied into the buffer since the last time it wrote.
LGWR对重做日志缓存负责-------写重做日志缓存到重做日志文件中.LGWR写所有的重做记录,是为了在最后把缓存里的东西复制出来.
The redo log buffer is a circular buffer. When LGWR writes redo entries from the redo log buffer to a redo log file, server processes can then copy new entries over the entries in the redo log buffer that have been written to disk. LGWR normally writes fast enough to ensure that space is always available in the buffer for new entries, even when access to the redo log is heavy.
重做日志缓存区是一循环的缓存区.当LGWR把重做记录从重做日志缓存区写到重做日志文件中.在重做日志缓存服务进程能把新的记录复制到这个记录上,旧的记录被写到硬盘上.
LGWR一般都快速的写以确保在缓存中对于新存的记录能有空闲的空间可以使用,即使当redo log很忙.
LGWR writes synchronously to the active mirrored group of redo log files. If one of the files in the group is damaged or unavailable, LGWR continues writing to other files in the group and logs an error in the LGWR trace file and in the system alert log. If all files in a group are damaged, or the group is unavailable because it has not been archived, LGWR cannot continue to function.
LGWR同步的写活动反映到重做日志文件的组中.如果在一个组里只有一个文件是的危害的和不可用的.在组LGWR继续写其它文件和日志在LGWR跟踪文件中有是有错误的,在系统的警告日志.如果所有的文件在一个组里是危险的.或组不可用的因为因为他不能被存档,LGWR功能不能被继续使用.