实习日志第5天·学习笔记Memory Architecture(一)

15章:Memory Architecture内存体系结构

本章讨论 Oracle 实例instance的内存体系结构。

·Introduction to Oracle Database Memory Structures

·Overview of the User Global Area      UGA用户全局区

·Overview of the Program Global Area   PGA程序全局区

·Overview of the System Global Area    SGA系统全局区

·Overview of Software Code Areas      软件代码区

 

Introduction to Oracle Database Memory Structures

在数据库实例启动时,数据库会分配出一个内存区域(a memory area),并且启动后台进程

memory area会存储以下信息:

·Program code  程序代码

·Information about each connected session, even if it is not currently active

   已连接的会话(session)信息,包括当前活动的(active)及非活动的会话

·Information needed during program execution, for example, the current state of a

query from which rows are being fetched

程序执行过程中所需的信息(例如,某个查询的状态)

·Information such as lock data that is shared and communicated among processes

   需要在 Oracle 进程间共享并进行通信的信息(例如,锁信息)

·Cached data, such as data blocks and redo records, that also exists on disk

   数据文件内数据的缓存(例如,数据块(data block)及重做日志条目(redo log entry))

 

Basic Memory Structures

Oracle 中的基本内存结构包括:

·SGA(System global area)

  The SGA is a group of shared memory structuresThe SGA is shared by all server and background processes。此区域由所有的服务进程(server process)和后台进程(background process)共享。

·PGA(Program global area)

  A PGA is a nonshared memory region that contains data and control information exclusively for use by an Oracle process. 此区域是每个服务进程和后台进程所私有的;即每个进程都有一个 属于自己的 PGAThe PGA is created by Oracle Database when an Oracle process is started.

·UGA(User Global Area)

The UGA is memory associated with a user session. UGA与用户会话session相关

·Software code areas  软件代码区

Software code areas are portions of memory used to store code that is being run or can be run.

   内存的一部分是软件代码区,用来存储正在运行或可能会被运行的代码

 

Oracle Database Memory Management

Memory management involves maintaining optimal sizes for the Oracle instance memory structures as demands on the database change.

based on the settings of memory-related initialization parameters.

The basic options for memory management are as follows:

·Automatic memory management

   给实例内存设定一个最大值target size,实例会自动分配SGAPGA的大小

·Automatic shared memory management

   SGA设定一个最大值(target size),另一个值是PGA的总值或管理每个PGA的值。进行自动管理

·Manual memory management

  与前两个设置总的内存空间大小进行自动管理相反,手动设置SGA每个组件的初始化参数和每个PGA的大小值

  SGA_MAX_SIZESGA_TARGET_SIZE的区别:SGA_MAX_SIZE是控制SGA最大大小的参数;SGA_TARGET_SIZE是自动共享内存管理(ASMM)的SGA设置参数(数值不能超过SGA_MAX_SIZE,为0意味着禁止ASMM自动共享内存管理)

http://blog.csdn.net/wh62592855/archive/2009/09/26/4595980.aspx

Overview of the User Global Area用户全局区

The UGA is session memory   UGA就是会话内存,专为会话变量(比如登录信息,会话信息)等等服务的

The OLAP page pool is also stored in the UGA. This pool manages OLAP data pages, which are equivalent to(等价于) data blocks

注意:The UGA must be available to a database session for the life of the session.

因此:the UGA cannot be stored in the PGA when using a shared server connection because the PGA is specific to a single process.the UGA is stored in the SGA)对于共享服务器而言

When using a dedicated server connection, the UGA is stored in the PGA.对于专用服务器而言

 

Overview of the Program Global Area程序全局区

The server process allocates memory structures that it requires in the PGA.

not shared by other processes or threads on the system

can use an initialization parameter to set a target maximum size of the instance PGA

注意:Background processes also allocate their own PGAs.后台进程同样有自己的PGA(但这里只讨论服务器进程)

Contents of the PGA

由于每个PGA的用途不同,所以并不是每个area都会存在在一个PGA

Private SQL Area

When a server process executes SQL or PL/SQL code, the process uses the private SQL area(私有 SQL区) to store bind variable(绑定变量) values, query execution state information, and query execution work areas. 私有 SQL 区(private SQL area)中包含绑定信息及运行时内存结构等数据。

Multiple private SQL areas in the same or different sessions can point to a single execution plan in the SGA. 多个私有 SQL 区可以和同一个共享 SQL 区相联系。(每个提交了 SQL 语句的会话都有一个私有 SQL 区。每个提交了相同 SQL 语句的用户都有自己的私有 SQL 区,但他们使用同一个共享 SQL 区(shared SQL area)。)

A private SQL area私有SQL区可以分为两个区域:

·The run-time area

  contains query execution state informationFor DML statements, the run-time area is freed when the SQL statement is closed.DML语句运行结束会自动释放)

   执行一个用户请求的首个步骤时才创建运行时区(creates the run-time area as the first step of an execute request.

·The persistent area

This area contains bind variable values. The persistent area is freed only when the cursor is closed.(包含绑定变量之类的数据,只在游标关闭时才会被释放)

两个area生命周期不同

私有 SQL 区的位置依赖于会话的连接类型。如果会话是通过专用服务器连接的(dedicated server),则私有 SQL 区位于服务进程(server process)的 PGA 内。如果会话是通过共享服务器连接的(shared server),那么私有 SQL 区的部分内容保存在 SGA 中。

SQL Work Areas

A work area is a private allocation of PGA memory used for memory-intensive operations.

/*对于复杂的查询来说(例如,决策支持系统中的查询),运行时区(run-time area)的大部分容量均供需要占用大量内存的操作创建工作区(work area)之用*/

PGA Usage in Dedicated and Shared Server Modes

PGA memory allocation depends on whether the database uses dedicated or shared

server connections.

 

Overview of the System Global Area系统全局区

SGA是一个可读写的区域,和后台进程一起构成了数据库实例。所以用户使用的服务器进程都能读取SGA的信息。也被称为共享全局区shared global area

每个实例都有属于自己的SGA。启动实例时会自动分配SGA的内存

can query the V$SGASTAT view for information about SGA components.

·Database Buffer Cache 数据缓存区

·Redo Log Buffer 重做日志缓存区

·Shared Pool 共享池

·Large Pool 大型池(可选)

·Java Pool   Java

·Streams Pool   数据流池

·Fixed SGA  

 

Database Buffer Cache

数据缓存的作用:

·优化物理I/O(Optimize physical I/O)

·经常访问的块保存在缓存里,不经常访问的写入磁盘(Keep frequently accessed blocks in  the buffer cache and write infrequently accessed blocks to disk

数据缓存的状态(Buffer States):

·Unused

·Clean

·Dirty

Every buffer has an access mode: pinned or free (unpinned).

Pointers to dirty and nondirty buffers exist on the same least recently used (LRU) LRU算法list, which has a hot end and cold end. A cold buffer is one that has not been recently used. A hot buffer is frequently accessed and has been recently used.

Buffer Modes

·Current mode

  A current mode get, also called a db block get

·Consistent mode

  A consistent read get is a retrieval of a read-consistent version of a block.

Buffer I/O

A logical I/O, also known as a buffer I/O

当没有在内存中找到所要求的缓存,数据库会用物理I/Oflash cachedisk建立缓存写入内存中,再用逻辑I/O读取这些缓存

Buffer Writes  The database writer (DBWn) process periodically writes cold, dirty buffers to disk

  DBWn数据库写进程讲缓存区的cold, dirty buffers写入磁盘disk

  DBWn会在以下情况下进行写缓存(writes buffers

·A server process cannot find clean buffers for reading new blocks into the database buffer cache.

The database uses the LRU to determine which dirty buffers to write. When dirty buffers reach the cold end of the LRU, the database moves them off the LRU to a write queue.待写列表中记录的是脏缓冲区(dirty buffer),即其中数据已被修改且尚未写入磁盘的缓冲区。最近最少使用列表中记录的是可用缓冲区(free buffer),锁定缓冲区(pinned buffer),及还没被移入待写列表的脏缓冲区。

·The database must advance the checkpoint, which is the position in the redo thread from which instance recovery must begin.

·Tablespaces are changed to read-only status or taken offline

Buffer Reads  When the number of clean or unused buffers is low, the database must remove buffers from the buffer cache. The algorithm depends on whether the flash cache is enabled

 

 

 

 只看到了database buffer,已经有点晕乎了,之后的内容还没看。预计下周看完剩余的SGA部分和software code area和下一章的进程结构process architecture。再回过头来理一下五章的具体知识点(或许放在周末有空的话),理出个思路来。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24005010/viewspace-684453/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24005010/viewspace-684453/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值