Oracle 11g server architecture

  The main server and Oracle instances, databases, and Program Global Area foreground process components.

  Examples can be further divided into two parts System Global Area (SGA) and background processes (PMON, SMON, etc.), which, SGA using the operating system's memory resources, and the background process requires the use of CPU and memory resources. Database (Database) contains data files (Data files), control file (Control files) and redo log files (Redo log file), Database files stored in the hard disk. Program Global Area (PGA) is a non-shared memory area for managing user process private resources. Foreground process can be subdivided into user and server processes, they need to use the cpu and memory resources.

First, the System Global Area (SGA)

  System Global Area (System Global Area) is shared by all user processes a memory area, that is, data resources in the SGA may be common to use multiple user processes. SGA mainly by the data cache, shared pool, redo log buffer, Java pool and large pool and other memory structures. SGA With the launch of the database instance and loaded into memory, when the database instance is shut down, SGA area will disappear.

  1, data cache (Database buffer cache)

  Stored in the data cache Oracle system recently accessed data blocks (data block in the buffer area may also be referred to as a cache block). When a user makes a request to the database, if there is a request of the data in the data cache in the Oracle system reads data directly from the buffer cache and returned to the user, otherwise, Oracle will open the data file read request for data .

  If you can not find the desired data in the data cache, then the first Oracle reads the specified data block from a data file into a buffer, and then returns the requested data from the buffer to the user. Since the data cache is shared by all users, as long as some of the data block in the data file is requested over the current or other user, then the data blocks will be loaded into the data cache. When used in this way any access to the same data again, Oracle will not have to read data from a data file, but the data in the buffer can be directly returned to the user. Frequently or recently accessed data blocks are placed into the front end of a high speed data buffer, a data block is not frequently accessed are placed into the rear end of the data cache, when a high-speed buffer is filled, a number will automatically squeezed not frequently accessed data blocks.

  In the access speed, the memory read speed much faster than the physical hard disk, there is a data cache can greatly reduce the frequency of physical disk read, so as to improve the performance of the database server object. In order to facilitate the SGA memory management data, Oracle data cache is divided into the following three parts:

  (1) the dirty data area : dirty data stored in the region that has been modified data, the data waiting to be written to the data file. When an update or delete statement submitted to the command data to modify some database, then the data block is marked as "dirty", and then wait through a background process DBWR writes it to the data file.

  (2) free areas: a data block in the spare area does not contain any data that can be written to the data block, Oracle data block may be read from the data file, and store it in this region.

  (3) Reserved: Reserved area that contains the data block that is being accessed by the user and expressly reserved (i.e. cache block), these data blocks are retained in the buffer used in the future as data blocks.

  2, redo log buffer (Red log buffer cache)

  Redo log buffer for storing database log information generated during operation of modifying, before writing the log information to the redo log file, storing the redo log buffer first, and then, occurred at a checkpoint or redo when the amount of information in the log buffer reaches a certain peak, and finally by the log write process (LGWR) writes the contents of this buffer to the redo log files.

  Redo log buffer size specified by the LOG_Buffer parameter that may be dynamically modified after startup instance. With respect to the data cache, the redo log buffer size affect performance of the database small, generally larger redo log buffer can reduce the number of I / O read and write redo log file, for overall database performance has improved to some extent.

  3, shared pool (Shared pool)

  SGA shared pool of memory area is reserved for caching SQL statements, PL / SQL statements, data dictionary, resource lock, character set and other control structures. Shared pool contains a high-speed buffer (Library cache) and a high-speed buffer dictionary (Dictionary cache).

  Portion of the shared pool (1) when the buffer cache library, including two components of a shared SQL areas and private SQL area. Library buffer cache to store recently used in SQL statements, PL / text plan and execute SQL statements. The next time the same SQL statement or PL / SQL statements can be found directly in the database buffer cache before the implementation plan has been generated without the need to resolve the same SQL statement or PL / SQL statement again, thus improving the efficiency of the system .

  Each cached SQL or PL / SQL statements are divided into two parts, are stored in the shared SQL area and a private SQL area. Shared SQL area to store SQL or PL / SQL statement syntax analysis and implementation plan, if you later want to perform a similar statement again, you can use a shared SQL area already cached syntax analysis and implementation plan. Private SQL area bind variables to store information, such as the environment and the session SQL statement, the information belongs to the user private information execute the statement, and other users can not share the information.

  (2) high speed buffer for storing the dictionary data dictionary information inside Oracle system management needs, such as user name, a data object and permissions.

  Shared memory pool size can be dynamically changed, generally by modifying the value of the parameter SHARED_POOL_SIZE.

  4, a large pool (Large pool)

  Large pool area in the SGA memory structure is not necessary, only in certain special cases, examples need to use the large pool to relieve pressure access shared pool, common use case are the following:

  •   当使用回复管理器进行备份和回复操作时,大型池将作为 I/O 缓冲区作用。
  •   使用 I/O  Slave 仿真异步 I/O 功能时,大型池将被当作 I/O 缓冲区使用。
  •        执行具有大量排序操作的 SQL 语句。
  •        当使用并行查询时,大型池作为并行查询进程彼此交换信息的地方。

  大型池的缓存区大小是通过 Large_pool_size参数定义的,在 Oracle 11g中,用户可以使用 alter system  命令动态地修改其缓冲区的大小。

  5、Java池

  用来提供内存空间给 Java 虚拟机使用,目的是支持在数据库中运行 Java 程序包,其大小由 Java_Pool_size 参数决定

  6、流池

  Oracle 流池用于在数据库与数据库之间进行信息共享。如果没有用到 Oracle 流,就不需要设置该池。流池的大小由参数 STREAMS_Pool_size 决定。

二、程序全局区(PGA)

  程序全局区(Program Global Area)也可称做用户进程全局区,它的内存在进程私有区而不是共享区。虽然 PGA 是一个全局区,可以把代码,全局变量和数据结构都可以存放在其中,但区域内的资源并不像 SGA 一样被所有的用户进程所共享,而是每个 Oracle 服务器进程都只拥有属于自己的那部分 PGA资源。

  在程序全局区(PGA)中,一个服务进程只能访问属于它自己的那部分 PGA 资源区,各个服务进程的 PGA 区总和即为实例 PGA区的大小。通常 PGA 区由私有 SQL 区和会话区组成。

  1、私有 SQL区

  私有 SQL 区用于存储变量以及 SQL 语句运行时的内存结构信息,当每个用户连接到实例时,都会在实例中创建一个会话。这些会话可能会在 SGA 区中创建一个共享 SQL区,但在 PGA 区中可能会创建多个私有 SQL 区。把一个私有 SQL 区与对应的共享 SQL 区合并在一起,就可以获得一条 SQL语句的完整缓存数据。

  每个会话的私有 SQL 区可以再分为静态区和动态区两部分。静态区的信息在会话过程中保持不变,只有当会话结束时,静态区才会被释放掉;而动态区的信息在整个会话过程中是不断变化的,一旦 SQL 语句指定完毕,即使会话还没有结束,动态区也被释放掉。

  2、会话区

  会话区用于存放用户的会话信息(如登录用户名)。如果数据库处于共享服务器连接模式下,则会话区将位于 SGA 区域,而不是 PGA 中。

  查看程序全局区(PGA)的信息可以通过显示 pga 参数的内容来实现。

三、前台进程

  前台进程包括用户进程和服务进程,它不属于实例的一部分,但是用户在不知不觉中经常会用到它,使用前台进程能够实现用户与实例的沟通。

  1、用户进程

  用户进程是指那些能够产生或执行 SQL 语句的应用程序,无论是 SQL*Plus,还是其他应用程序,只要是能生成或执行 SQL 语句,都被称作用户进程。

  在用户进程中有两个非常重要的概念:连接和会话。连接是一个用户进程与实例之间建立的通信渠道,这个渠道可以通过操作系统上的相关通信机制或网络连接来实现。会话是指用户进程与实例之间建立连接后形成的用户与实例之间的交互方式,一般是用户发出请求,数据库实例为用户返回响应消息的方式。

  2、服务器进程

  服务进程就是用于处理用户会话过程中向数据库实例发出 SQL 语句或 SQL*Plus 命令,它可以分为专用服务器模式和共享服务器模式。在专用服务器模式下,每个用户进程都有一个专用的服务器进程,这个服务器进程代表用户进程执行 SQL 语句,必要时还可以回传执行结果给用户进程。在共享服务器模式下,每个用户进程不直接与服务器进程连接,而是连接到分派程序,每个分派程序可以同时连接多个用户进程。

四、后台进程

  Oracle 后台进程是一组运行与 Oracle 服务器端的后台程序,是 Oracle 实例的重要组成部分。这组后台进程有若干个,它们分工明确——分别完成不同的系统程序。

其中 SMON、PMON、DBWR、LGWR 和 CKRT 这5哥后台进程必须正常启动,否则将导致数据库崩溃。还有很多的辅助进程,用于实现相关的辅助功能,如果这些辅助进程发生问题,只会使某些功能受到影响,一般不会到时数据库实例崩溃。

  1、数据写入进程(DBWR)

   数据写入进程的主要任务是负责将内存中的 “脏” 数据块回写到数据文件中。“脏” 数据块是指高速数据缓冲区中的被修改过的数据块,这些数据块的内容与数据文件内容不一致。但 DBWR 并不是随时将所有的 “脏” 数据块都写入数据文件,只有满足一定的条件时, DBWR 进程才开始成批量地将 “脏” 数据写入数据文件, Oracle 这样做的目的是为了尽量减少 I/O 操作,提供 Oracle 服务器性能。通常在下面几种情况下,DBWR 进程将 “脏” 数据块写入数据文件。

  •   当用户进程执行插入或修改操作时,需要将 “新数据” 写入高速数据缓冲区,如果在高速数据缓冲区中没有找到足够大的空闲数据块来存放这些“新数据”,这时, Oracle 系统将启动 DBWR 进程并将 “脏” 数据块写入数据文件,已获得空闲数据块来存储这些 “新数据”。
  •        当检查点进程启动后,它会强制要求 DBWR 将某些 “脏” 数据块写入数据文件文件中。
  •   当 “脏” 数据块在高速数据缓冲区中存放超过3秒钟,DBWR 进程会自行启动并将某些 “脏”数据库写入到数据文件中。

  在某些比较繁忙的应用系统中,可以修改服务器参数文件 Spfile 的 DB_writer_processes 参数,以允许使用多个 DBWR 进程。但是 DBWR 进程的数量不应当超过系统处理器的数量,否则多余的 DBWR 不但无法发挥作用,反而会耗费系统资源。

  2、检查点进程(CKPT)

   检查点进程可以看做义工事件,当检查点事件发生时, CKPT 会要求 DBWR将某些 “脏” 数据块回写到数据文件。当用户进程发出数据请求时, Oracle 系统从数据文件中读取需要的数据并存放到高速数据缓冲区,用户对数据的操作时在缓冲区中进行的。当用户操作数据时,就会产生大量的日志信息并存储在崇左日志缓冲区,当 Oracle 系统满足一定条件时,日志写入经常(LGWR)会将日志信息写入到崇左日志文件组中,当发生日志切换时(写入操作正要从一个日志文件组切换到另一组时),就会启动检查点进程。

   DBA 还可以通过修改初始化参数 spfile 中的 checkpoint_process 参数为TRUE来启动检查点进程。

  3、日志写入进程(LGWR)

   日志写入进程用于将重做日志缓冲区中的数据写入重做日志文件。Oracle 系统首先将用户所做的修改日志信息写入日志文件,然后再将修改结果写入数据文件。

   Oracle 实例再运行中会产生大量日志信息,这些日志信息首先被记录在 SGA 的重做日志缓冲区中,当发生提交命令、或者重做日志缓冲区的信息满 1/3 ,或者日志信息存放超过3秒钟时,LGWR 进程就将日志信息从重做日志缓冲区中读出并写入日志文件组中序号较小的文件中,一个日志组写满后接着写另外一组。当 LGWR 进程将所有的日志文件都写过一遍后,它将再次转向第一个日志文件组重新覆盖。当 LGWR 进程写满一个日志文件组而转向写另外一组时,称之为日志切换。

  4、归档进程(ARCH)

   归档进程是一个可选择的进程,只有当 Oracle 数据库处于归档模式时,该进程才可能起到作用。若 Oracle 数据库处于归档模式,当各个日志文件组都被写满而即将被覆盖之前,先由归档进程(ARCH)把即将被覆盖的日志文件中的日志信息读出,然后再把这些 “读出的日志信息” 写入到归档日志文件中。

  当系统比较繁忙而导致 LGWR 进程处于等待 ARCH 进程时,可通过修改 LOG_Archive_max_processes 参数启动多个归档进程,从而提高归档写磁盘的速度。

  5、系统监控进程(SMON)

   系统监控进程时在数据库系统启动时恢复工作的强制性进程。例如:在并行服务器模式下,SMON 可以恢复另一个处于失败的数据库,使系统切换到另外一台正常的服务器上。

  6、进程监控进程(PMON)

   进程监控进程用于监控其他进程的状态,当有进程启动失败时,PMON 会清除失败的用户进程,释放用户进程所用的资源。

  7、锁定进程(LCKN)

   这个一个可选进程,并行服务器模式下可以出现过个锁定进程以利用与数据库通信。

  8、恢复进程(RECO)

   这是在分布式数据库模式下使用的一个可选进程,用于数据不一致时进行恢复工作。

  9、调度进程(DNNN)

   这是一个可选进程,在共享服务器模式下使用,可以启动多个调度进程。

  10、快照进程(SNPN)

   快照进程用于处理数据库快照的自动刷新,并通过 DBMS_job 包运行预定的数据库存储过程。

Guess you like

Origin www.cnblogs.com/niujifei/p/10954008.html