【Oracle】Oracle体系结构(二):内存结构
二、进程组成
1、进程的种类
Oracle实例有一下几种不同的进程:
1 )客户端进程
client process(也叫用户进程,因为是在客户端的)
是连接到Oracle数据库实例的应用程序或工具,比如SQLPLUS,比如其他的软件
它不会直接连到数据库!而是与服务器进程进行交互
2)数据库进程
Database processes 其中包括:
后台进程 background process
服务器进程 server process
从属进程.....
3) 守护/应用程序 进程
Daemon and Application processes,其中包括:
Nertworking listeners 网络监听进程
Grid infrastructure dameons ASM与RAC相关的进程
2、会话是怎么产生的?
会话(session)就是user process 与 server process 连接产生的
session的信息保存在 PGA 的UGA中
3、服务器进程 Server Process
作用:用来处理客户端发出的请求。客户端进程总是通过单独的服务器进程与数据库通信。
如果有20个客户端进程连接到实例,就有20个server process提供服务
执行的任务:
1)复制处理SQL,包括接收sql语句,找执行计划与解析sql
2)读数据,包括读buffer cache和数据文件中的数据
3)返回信息给用户
4、后台进程 Background Process
后台进程的种类
后台有很多进程中,但是有五大进程是必须有的,它们分别是:
- PMON
- SMON
- DBWn
- LGWR
- CKPT
## 这是9i的启动顺序。,仅作参考 PMON started with pid=2 DBW0 started with pid=3 LGWR started with pid=4 CKPT started with pid=5 SMON started with pid=6 RECO started with pid=7
查看后台进程
select pname,program from v$process where pname is not null PNAME PROGRAM ----- ------------------------------------------------ PMON oracle@txy.example.com (PMON) CLMN oracle@txy.example.com (CLMN) PSP0 oracle@txy.example.com (PSP0) VKTM oracle@txy.example.com (VKTM) GEN0 oracle@txy.example.com (GEN0) MMAN oracle@txy.example.com (MMAN) RECO oracle@txy.example.com (RECO) GEN1 oracle@txy.example.com (GEN1) SCMN oracle@txy.example.com (SCMN) DIAG oracle@txy.example.com (DIAG) OFSD oracle@txy.example.com (OFSD) SCMN oracle@txy.example.com (SCMN) DBRM oracle@txy.example.com (DBRM) VKRM oracle@txy.example.com (VKRM) SVCB oracle@txy.example.com (SVCB) PMAN oracle@txy.example.com (PMAN) DIA0 oracle@txy.example.com (DIA0) DBW0 oracle@txy.example.com (DBW0) LGWR oracle@txy.example.com (LGWR) CKPT oracle@txy.example.com (CKPT) PNAME PROGRAM ----- ------------------------------------------------ LG00 oracle@txy.example.com (LG00) SMON oracle@txy.example.com (SMON) LG01 oracle@txy.example.com (LG01) SMCO oracle@txy.example.com (SMCO) W004 oracle@txy.example.com (W004) LREG oracle@txy.example.com (LREG) PXMN oracle@txy.example.com (PXMN) MMNL oracle@txy.example.com (MMNL) MMON oracle@txy.example.com (MMON) D000 oracle@txy.example.com (D000) S000 oracle@txy.example.com (S000) TMON oracle@txy.example.com (TMON) QM02 oracle@txy.example.com (QM02) TT00 oracle@txy.example.com (TT00) TT01 oracle@txy.example.com (TT01) TT02 oracle@txy.example.com (TT02) AQPC oracle@txy.example.com (AQPC) CJQ0 oracle@txy.example.com (CJQ0) P000 oracle@txy.example.com (P000) P001 oracle@txy.example.com (P001) P002 oracle@txy.example.com (P002) PNAME PROGRAM ----- ------------------------------------------------ P003 oracle@txy.example.com (P003) P004 oracle@txy.example.com (P004) P005 oracle@txy.example.com (P005) P006 oracle@txy.example.com (P006) P007 oracle@txy.example.com (P007) W003 oracle@txy.example.com (W003) Q002 oracle@txy.example.com (Q002) Q003 oracle@txy.example.com (Q003) W000 oracle@txy.example.com (W000) W006 oracle@txy.example.com (W006) 51 rows selected
[root@txy ~]# ps -ef | grep smon oracle 6221 1 0 Feb12 ? 00:00:17 ora_smon_txydb [root@txy ~]# ps -ef | grep "ora_*" oracle 3525 1 0 16:00 ? 00:00:00 ora_w007_txydb oracle 4153 1 0 16:02 ? 00:00:00 ora_w006_txydb oracle 6170 1 0 Feb12 ? 00:00:55 ora_pmon_txydb oracle 6172 1 0 Feb12 ? 00:00:24 ora_clmn_txydb oracle 6174 1 0 Feb12 ? 00:02:49 ora_psp0_txydb oracle 6182 1 0 Feb12 ? 03:14:41 ora_vktm_txydb oracle 6186 1 0 Feb12 ? 00:00:46 ora_gen0_txydb oracle 6188 1 0 Feb12 ? 00:00:22 ora_mman_txydb oracle 6192 1 0 Feb12 ? 00:03:38 ora_gen1_txydb oracle 6196 1 0 Feb12 ? 00:00:46 ora_diag_txydb oracle 6198 1 0 Feb12 ? 00:00:24 ora_ofsd_txydb oracle 6202 1 0 Feb12 ? 00:10:06 ora_dbrm_txydb oracle 6204 1 0 Feb12 ? 00:21:15 ora_vkrm_txydb oracle 6206 1 0 Feb12 ? 00:00:48 ora_svcb_txydb oracle 6208 1 0 Feb12 ? 00:01:45 ora_pman_txydb oracle 6210 1 0 Feb12 ? 00:10:19 ora_dia0_txydb oracle 6212 1 0 Feb12 ? 00:01:21 ora_dbw0_txydb oracle 6214 1 0 Feb12 ? 00:00:37 ora_lgwr_txydb oracle 6216 1 0 Feb12 ? 00:03:15 ora_ckpt_txydb oracle 6218 1 0 Feb12 ? 00:00:28 ora_lg00_txydb oracle 6221 1 0 Feb12 ? 00:00:17 ora_smon_txydb oracle 6223 1 0 Feb12 ? 00:00:14 ora_lg01_txydb oracle 6225 1 0 Feb12 ? 00:01:17 ora_smco_txydb oracle 6227 1 0 Feb12 ? 00:00:10 ora_reco_txydb oracle 6231 1 0 Feb12 ? 00:00:38 ora_lreg_txydb oracle 6235 1 0 Feb12 ? 00:00:21 ora_pxmn_txydb oracle 6239 1 0 Feb12 ? 00:09:18 ora_mmon_txydb oracle 6241 1 0 Feb12 ? 00:04:50 ora_mmnl_txydb oracle 6243 1 0 Feb12 ? 00:00:15 ora_d000_txydb oracle 6245 1 0 Feb12 ? 00:00:43 ora_s000_txydb oracle 6247 1 0 Feb12 ? 00:00:13 ora_tmon_txydb oracle 6274 1 0 Feb12 ? 00:00:12 ora_tt00_txydb oracle 6276 1 0 Feb12 ? 00:00:10 ora_tt01_txydb oracle 6278 1 0 Feb12 ? 00:00:36 ora_tt02_txydb oracle 6282 1 0 Feb12 ? 00:00:11 ora_aqpc_txydb oracle 6287 1 0 Feb12 ? 00:04:19 ora_p000_txydb oracle 6289 1 0 Feb12 ? 00:04:15 ora_p001_txydb oracle 6291 1 0 Feb12 ? 00:03:29 ora_p002_txydb oracle 6293 1 0 Feb12 ? 00:03:17 ora_p003_txydb oracle 6295 1 0 Feb12 ? 00:00:44 ora_p004_txydb oracle 6297 1 0 Feb12 ? 00:00:45 ora_p005_txydb oracle 6299 1 0 Feb12 ? 00:00:44 ora_p006_txydb oracle 6301 1 0 Feb12 ? 00:00:45 ora_p007_txydb oracle 6479 1 0 Feb12 ? 00:25:44 ora_cjq0_txydb oracle 6560 1 0 Feb12 ? 00:00:12 ora_qm02_txydb oracle 6564 1 0 Feb12 ? 00:00:14 ora_q002_txydb oracle 6566 1 0 Feb12 ? 00:00:12 ora_q003_txydb oracle 7215 1 0 Feb12 ? 00:00:15 /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr LISTENER -inherit oracle 8819 1 0 16:17 ? 00:00:00 ora_w005_txydb oracle 22122 1 0 17:00 ? 00:00:00 ora_w003_txydb oracle 22441 1 0 17:01 ? 00:00:00 ora_w000_txydb root 24466 24177 0 17:08 pts/0 00:00:00 grep --color=auto ora_* [root@txy ~]#
1)DBWn
DBWn(Database Writer Process)是数据库写入进程,作用是将buffer cache中的脏块(已修改的块)写入到磁盘,释放buffer cache里面的空间。
推进检查点。
注意:写入的是异处理的的,用户修改了数据,发起commit时不是立刻写进数据文件里
触发条件
DBWn在下列条件会将脏数据块写入到磁盘中:
- 如果脏数据块超过一定限度时
- 每3秒启动一次DBWn
- DROP或者TRUNCATE表是
- 当表空间OFFLINE时
- 当表空间发生BEGIN BACKUPO时
- 发生CKPT检查点经常
- 数据库不易shutdown abort形式关闭时
- 没有了空间缓冲区时
怎么判断哪些脏块应该写入磁盘
LRU算法
2)LGWR
LGWR(log wirter process) 日志写入器进程
关键字:转储
前面我们已经了解了redo log buffer的作用,redo log buffer是循环写的,如不将buffer内的内容写进文件里就会满了,满了之后就会把旧的删除,所以这部分的redo log就会丢失了。
LGWR进程的作用就是将日志缓冲区内内容写进redo log file里,这个过程成为“日志缓冲区转储”
与DBWn不同,LGWR几乎是实时写入到redo log buffer中的:会话发出commit,LGWR将缓冲区写入到磁盘,此时会话将刮起,事务记录为已经提交(因此是不可逆的)。
以下几种情况LGWR将复制重做条目至redo log file
1)提交事务:COMMIT之后,在LGWR真正将redo log buffer写入到磁盘前,会话将挂起。只有在写操作完成之后,才返回提交成功的信息给会话,服务器进程才能正常工作。这种操作可以确保事务永不丢失:已提交事务的每个变更向量都可以在磁盘上的重做日志中找到,并且可以应用于数据备份。因此,如果数据库被损坏,可以通过备份进行还原,可以做到重做子备份以来执行的所有工作
2)日志缓冲区的的占用率达到1/3
3)在DBWn将脏数据块从buffer cache写入到磁盘之前。
4)自LGWR上一次写入已过了三秒。
5)联机重做日志切换时
3)CKPT
checkpoint process 检查点进程
使用检查点信息更新控制文件和数据文件头,并通知 DBWn 将块写入磁盘。检查点信息包括检查点位置、 SCN、 联机重做日志中 的起始恢复位置等等。
检查点信息记录在
1)控制文件(control file)
2)每个数据文件头(datafile)
4)PMON
PMON(Process Monitor process)进程监视器进程.
它的作用:
1 监视其他的后台进程,异常时执行进程回复,会回滚事务
2 清理buffer cache
3 将实例注册到Oracle Net Listener (12c后由LRRG完成了)
4 释放异常终止进程的资源、释放锁、
5)SMON
SMON(system monitor process)系统监视进程。更多地完成一些系统级别的功能,比如数据库startup。
与PMON一样也有着清理的功能,不过是系统级别的清理。
主要作用:
1)清理
清理临时段(这里的临时段不是临时表空间的段,是指永久表空间的上的临时段);当然临时表空间中的临时段也是SMON清理的
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?