A process is a mechanism in an operating system that can run a series of steps.
Oracle 的进程分类:
Client Processes:
用户使用一个应用程序,例如sqlplus,连接数据库,产生的操作系统进程,就是客户端进程;
oracle 服务器端进程:
Server Processes:
Oracle Database creates server processes to handle the requests of client processes
connected to the instance
所做的工作:
Parse and run SQL statements issued through the application,包括创建执行计划
Execute PL/SQL code
Read data blocks from data files into the database buffer cache
Return results
如果是dedicated server,那么,每个session都会产生一个server process;
如果是shared server,那么,oracle server固定产生一定量的server process,所有的会话共享;
Background Processes:
后台进程
The background processes perform maintenance tasks required to operate
the database and to maximize performance for multiple users;
Slave processes: perform additional tasks for a background or server process
Oracle 实例的后台进程名称:
SYS@orcl11g> select pname from v$process
2 where pname is not null
3* order by pname
SYS@orcl11g> /
PNAME
-----
CJQ0
CKPT
D000
DBRM
DBW0
DIA0
DIAG
GEN0
J000
J001
LGWR
MMAN
MMNL
MMON
PMON
PSP0
Q001
Q002
QMNC
RECO
S000
SMCO
SMON
VKRM
VKTM
W000
26 rows selected.
[oracle@db253 homework]$ ps -ef | grep ora_ | grep -v grep |cut -d '_' -f2
q002
vkrm
w000
j000
j001
pmon
psp0
vktm
gen0
diag
dbrm
dia0
mman
dbw0
lgwr
ckpt
smon
reco
mmon
mmnl
d000
s000
qmnc
cjq0
q001
smco
[oracle@db253 homework]$
后台进程的分类:
Mandatory Background Processes
This section describes the following mandatory background processes:
■ Process Monitor Process (PMON)
■ System Monitor Process (SMON)
■ Database Writer Process (DBWn)
■ Log Writer Process (LGWR)
■ Checkpoint Process (CKPT)
■ Manageability Monitor Processes (MMON and MMNL)
■ Recoverer Process (RECO)
Process Monitor Process (PMON):进程监视器
The process monitor (PMON) monitors the other background processes and performs
process recovery when a server or dispatcher process terminates abnormally
进程监视器负责监视其他进程,如果其他的进程出现异常关闭的情况,进程监视器负责进程恢复;
PMON is responsible for cleaning up the database buffer cache and freeing resources that the
client process was using.
进程监视器负责清理客户端进程所对应的server process的数据库缓存和释放资源;
PMON also registers information about the instance and dispatcher processes with the
Oracle Net listener;
进程监视器负责数据库实例的动态注册;
System Monitor Process (SMON):系统监视器进程
The system monitor process (SMON) is in charge of a variety of system-level cleanup duties.
系统监视器负责一些列系统级别的清理职责:
Performing instance recovery;
执行实例恢复;
Recovering terminated transactions;
恢复中断的事务
Cleaning up unused temporary segments;
清理不再使用的临时段;
Coalescing contiguous free extents within dictionary-managed tablespaces;
字典管理的表空间中负责回收连续的空闲的区;
Database Writer Process (DBWn):数据库写进程
The database writer process (DBWn) writes the contents of database buffers to data files.
数据库写进程负责将数据库缓冲的内容写回数据文件;
数据库写进程的数量一般一个够用了,但是,根据不同场景,可以设置更多的写进程:
DBW0
DBW1 through DBW9 and DBWa through DBWj
最多可以设置20个写进程;
数据库写进程触发的条件:
1.当server process扫描了一定数量的buffer之后,仍然没有找到可用的buffer,触发DBWn写;
2.根据检查点信息,定期的触发DBWn进程;
3.当发生drop 或者 truncate的时候,触发写进程;
4.表空间置为read only;
5.表空间置为offline;
6.当做begin backup的时候,也会触发DBWn进程;
Log Writer Process (LGWR):日志写进程
The log writer process (LGWR) manages the redo log buffer. LGWR writes one
contiguous portion of the buffer to the online redo log;
日志写进程负责管理日志缓冲区,将一段连续的日志缓冲区的内容写到日志文件;
LGWR的触发条件:
1.用户提交;
2.日志切换;
3.每隔三秒钟触发一次;
4.日志缓冲区达到1/3满,或者容量达到1M,触发LGWR;
5.DBWn进程触发的时候,首先触发LGWR;
LGWR and Commits:LGWR 和 提交
fast commit:当用户执行commit命令提交事务,oracle server仅仅驱动LGWR进程,
将这个事务相关的事务提交scn和redo entries写回了日志文件;
group commits: 组提交,当提交量非常大的时候,实现组提交;
Checkpoint Process (CKPT):检查点进程
The checkpoint process (CKPT) updates the control file and data file headers with
checkpoint information and signals DBWn to write blocks to disk;
检查点进程负责更新控制文件和数据文件头部的检查点信息;
还负责驱动DBWn进程去写脏块;
checkpint:检查点
检查点是一个事件;
A checkpoint is a crucial mechanism in consistent database shutdowns, instance recovery, and Oracle Database operation generally.
是一个重要的机制,一致性的数据库关闭,实例恢复,以及数据库的正常运行;
A data structure that indicates the checkpoint position, which is the SCN in the
redo stream where instance recovery must begin;
用来确定实例恢复的所需要的redo block的起始位置;
The writing of modified database buffers in the database buffer cache to disk;
正常运行中,用于控制数据库的buffer和数据文件的同步行为;
检查点出现的三个意义:
■ Reduce the time required for recovery in case of an instance or media failure
■ Ensure that dirty buffers in the buffer cache are written to disk regularly
■ Ensure that all committed data is written to disk during a consistent shutdown
检查点的类型:
Thread checkpoints:实例检查点
对应每个实例,将所有的脏块写回数据文件的行为;
database checkpoint:数据库检查点:
将数据库所有的对应的实例的脏块写回数据文件;
出现的时机:
Consistent database shutdown
ALTER SYSTEM CHECKPOINT statement
Online redo log switch
ALTER DATABASE BEGIN BACKUP statement
Tablespace and data file checkpoints:表空间&数据文件检查点
将某个表空间或者数据文件对应的脏块写回数据文件;
出现的时机:
表空间read only;
表空间offline normal;
shrinking a data file;
ALTER TABLESPACE BEGIN BACKUP
Incremental checkpoints:增量检查点
An incremental checkpoint is a type of thread checkpoint partly intended to avoid
writing large numbers of blocks at online redo log switches
目的是为了避免一次性大量的磁盘写入;
Manageability Monitor Processes (MMON and MMNL):管理监视进程
The manageability monitor process (MMON) performs many tasks related to the
Automatic Workload Repository (AWR);
The manageability monitor lite process (MMNL) writes statistics from the Active
Session History (ASH) buffer in the SGA to disk.
Recoverer Process (RECO):恢复进程
In a distributed database, the recoverer process (RECO) automatically resolves
failures in distributed transactions.
负责分布式数据库的分布式事务的恢复;
**********************************************
Optional Background Processes 可选的后台进程
Archiver Processes (ARCn):归档进程
The archiver processes (ARCn) copy online redo log files to offline storage
after a redo log switch occurs.
当在线重做日志发生切换后,如果数据库是处于归档模式,那么ARCn进程负责将在线重做日志拷贝到归档位置;
而且ARCn进程,还负责想standby database传递日志;
Job Queue Processes (CJQ0 and Jnnn):作业队列进程
Oracle Database uses job queue processes to run user jobs, often in batch mode;
oracle用这个进程来运行用户的作业,经常是处于批处理模式;
job queue slave processes (Jnnn):作业队列slave进程;
SYS@orcl11g> show parameter job_queue_pro
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes integer 1000
Flashback Data Archiver Process (FBDA):闪回数据归档进程
The flashback data archiver process (FBDA) archives historical rows of
tracked tables into Flashback Data Archives.
这个进程负责将被跟踪的表的历史记录写入闪回归档区;
Space Management Coordinator Process (SMCO):空间管理协调器进程
The SMCO process coordinates the execution of various space management related
tasks, such as proactive space allocation and space reclamation. SMCO dynamically
spawns slave processes (Wnnn) to implement the task.
与空间的预分配和回收机制有关的进程;Wnnn是slave进程;
****************************************************************
Slave Processes:
I/O Slave Processes:
Parallel Query Slaves