search
HomeDatabaseMysql TutorialORACLE实例的后台进程

Oralce实例由内存和后台进程构成。实例后台进程在启动实例时启动,在终止实例时终止运行。

下面就来介绍一下这些在后台辛勤工作的进程们。系统检测器(System Monitor,SMON)、进程监视器(Process Monitor,PMON)、数据库写入器(Database Writer,DBWn)、日志写入器(Log Writer,LGWR)、检查点进程(Checkpoint Process,CKPT)

1、SMON:安装和打开数据库。通过查找和验证数据库控制文件来安装数据库。此后,通过查找和验证所有数据文件和联机日志文件打开数据库。一旦打开数据库并使数据库处于使用状态,SMON就负责执行各种内部管理任务。

2、PMON:用户会话是连接到服务器进程的用户进程。服务器进程在会话创建时启动,在绘画结束时销毁。如果会话正常结束,则用户执行的任何工作都会有序完成,服务器进程将终止。如果非正常终止会话,PMON将销毁服务器进程,将其PGA内存返回给操作系统,并回滚任何尚在进行的未提交完成的事务。

3、DBWn:会话不直接将数据写入磁盘,而是写入到数据库高速缓存区。然后又数据库写入器负责将缓冲区写入到磁盘。一般来说一个实例可能有多个写入器。依次为DBW0,DBW1等。默认情况是8个CPU对应一个数据库写入器。

通常情况下,Oracle会尽可能的减少写入缓冲区的数量。因为IO操作会降低性能。真实情况中,如果出现会话对某些缓冲区执行写作,那么通常还会有会话对其进行操作。这样,就没有必要将其写入到磁盘了。

DBWn采用极懒算法执行写入:尽可能少,在尽可能少。有四种情况需要进行些操作:没有可用缓冲区、脏缓冲区过多、遇到三秒超时,遇到检查点。
没有可用缓冲区:服务器进程在将块复制到高速缓冲区之前,需要查找可用缓冲区。可用缓冲区是既不脏也未被占用的缓冲区。如果查找可用缓冲区时间过长(Oracle内部自行设定),则会将脏缓冲区写入到磁盘,以清理缓冲区。

脏缓冲区数量过多:在什么情况下谓多,有Oracle的内部阈值确定,如果超过了,就会将一些缓冲区写到磁盘

三秒超时:DBWn每三秒会对一些缓冲区清理一次。即使系统处于闲置状态,也会清理缓冲区。
请求检查点:遇到检查点时,会写入所有的缓冲区数据。此时系统性能下降。检查点只有在不得已的情况下才会设置。关闭数据库和关闭实例时会设置检查点,也可以使用命令来设置。
在这里需要注意一点,在会话提交事务时,DBWn什么也不做,DBWn按照自己的方式执行。此时需要执行的操作是:写入日志缓冲区的数据。

4、LGWR:日志写入器将日志缓冲区的内容写入到磁盘上的联机日志文件中。当会话发出COMMIT时,LGWR会实时写入:在LGWR将缓冲区写入磁盘时,会话将会被挂起。在Oracle体系结构中,LGWR是最大的瓶颈之一。DML的速度不能超过LGWR将更改矢量写入到磁盘的速度。在以下三种情况发生时,LGWR将转储日志缓冲区:

提交写入时:已提交事务的每个更改矢量都可以再磁盘上的重做日志中得到,并可以再此后应用于数据文件备份。

日志缓冲区的占用率达到1/3:在应用程序中,通常在非常短的时间内就能填充满日志缓冲区的1/3,这时强制LGWR将更改矢量准实时的写入磁盘。此后,当会话发生COMMIT时,几乎没有什么要写入的内容:COMMIT可以立即完成。

DBWn需要将脏缓冲区从数据库高速缓存区写入到数据文件时:在DBWn执行写入操作之前,总会执行LGWR的写入操作。目的是:始终可以逆转未提交的事务。DBWn可能会将未提交的事务写入数据文件,如果能过获取逆转事务所需的数据和更改矢量,这样做就不会产生问题。所以,在DBWn执行写入之前,需要执行LGWR的写入,以确保这些数据进入重做日志文件中。

5、CKPT:系统崩溃后,必须从重做日志提取与脏缓冲区对应的所有更改矢量,并将其应用于数据块。这就是恢复过程。频繁的检查点确保:可以将脏缓冲区快速写入磁盘,从而最大程度的减少崩溃发生后必须应用的重做量。在Oracle8i之后,采用增量检查点机制,DBWn以固定速率写出脏缓冲区,因此DBWn和LGWR之间始终有一个可以预见的差距。使用增量检查点时系统性能更加平稳,恢复时间可以预测。

当然,在10g之后,Oracle又新增了几个进程,这里简单介绍一下:
MMON:管理监视器(Maniageability Monitor),数据块的自我监视和自我调整的支持进程。
MMNL:MMON的辅助进程。
MMAN:支持内存分布的自动调整。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

How to use MySQL functions for data processing and calculationHow to use MySQL functions for data processing and calculationApr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

An efficient way to batch insert data in MySQLAn efficient way to batch insert data in MySQLApr 29, 2025 pm 04:18 PM

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

Steps to add and delete fields to MySQL tablesSteps to add and delete fields to MySQL tablesApr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function