Oracle Memory Architecture - Oracle 体系结构篇 2

上一篇:Oracle Memory Architecture - Oracle 体系结构篇 1  http://blog.csdn.net/u010993297/article/details/9352695

1.What's SGA?

SGA系统全局区,S可以理解为SYSTEM,也可以理解为SHARE,系统全局区,也可以理解为共享全局区。

The SGA is a group of shared memory structures, known as SGA components,
that contain data and control information for one Oracle Database instance. The
SGA is shared by all server and background processes. Examples of data stored in
the SGA include cached data blocks and shared SQL areas.

SGA 是一组共享的内存结构,它包含oracle服务器的数据和控制信息。用于存储数据库信息的内存区,该信息为数据库所有进程所共享。

 

The SGA is a read/write memory area that, along with the Oracle background
processes, make up a database instance. All server processes that execute on behalf of
users can read information in the instance SGA. Several processes write to the SGA
during database operation.

SGA 是可以读写的内存区域,与oracle后台进程一起构成了数据库实例。

Note: The server and background processes do not reside within the SGA, but exist in a separate memory space.

服务器和后台进程不驻留在SGA,但存在于一个单独的内存空间。

Each database instance has its own SGA. Oracle Database automatically allocates
memory for an SGA at instance startup and reclaims the memory at instance
shutdown.

每一个实例只有一个SGA,生命周期是实例,实例停止,SGA消亡。SGA中的内容在实例启动期间,可以给私有进程共享。

 

When you start an instance with SQL*Plus or Oracle Enterprise Manager, the size of the SGA is shown as in the following example:

SQL> startup
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             343935360 bytes
Database Buffers           75497472 bytes
Redo Buffers                1900544 bytes
Database mounted.
Database opened

 

2. The SGA components

2.1 Granule

The SGA consists of several memory components, which are pools of memory used to satisfy a particular class of memory allocation requests. All SGA components except the redo log buffer allocate and deallocate space in units of  contiguous memory called granules. Granule size is platform-specific and is  determined by total SGA size.

SGA的由几种内存组成,这些内存池用来满足特定类的内存分配请求。所有SGA组件除了重做日志缓冲区分配和释放空间的内存单元被称为颗粒。内存的分配需要按照颗粒大小来分配,版本的变化,操作系统的不同,步长也不同。因此,必须按照步长来分配内存,可以用字典v$sga_dynamic_components来查询当前系统的步长。

SQL>  select component,granule_size/1024/1024 from V$SGA_DYNAMIC_COMPONENTS;

COMPONENT                      GRANULE_SIZE/1024/1024
------------------------------         --------------------------------------
shared pool                                                   4
large pool                                                      4
java pool                                                       4
streams pool                                                 4
DEFAULT buffer cache                                 4
KEEP buffer cache                                        4
RECYCLE buffer cache                                 4
DEFAULT 2K buffer cache                            4
DEFAULT 4K buffer cache                             4
DEFAULT 8K buffer cache                             4
DEFAULT 16K buffer cache                           4
DEFAULT 32K buffer cache                            4
Shared IO Pool                                               4
ASM Buffer Cache                                          4

14 rows selected.

--我的系统的步长默认为4m

2.2 SGA components

You can query the v$sgastat view for information about sga components. The most important SGA components are the following:

--三大必选组件

>Database Buffer Cache  数据库高速缓存区(database buffer cache),用来存放业务数据的共享的内存区域
>Redo Log Buffer             REDO日志缓存区,用来记录数据库的每个改动向量,其中包括系统的改动和UNDO的改动(UNDO其实也是一次REDO)。

>Shared Pool                   共享池,用来存放SQL解析树和字典对象定义的共享区域。

 

--其它可选组件
>Large Pool                     大池,用于存放对那些复杂的程序包分析、RMAN、UGA、异步IO等相关的数据             
>Java Pool                       JAVA池,是用来存放JAVA存储过程的分析信息
>Streams Pool                 流池
>Fixed SGA                     固定SGA,各平台固定大小的用于记录SGA结构的固定内存

2.3 The setting of the SGA

(1) 9I,ORACLE需要你先划分一个SGA的最大大小限额SGA_MAX_SIZE,用于划出最大多少的内存给ORACLE共享内存 使用。

     该参数只能通过文本参数修改或SPFILE的设  置,   并在重起后生效。
    10g实现SGA的自动管理,并设置了sga_target。我们称自动内存管理为AMM。
    11G,可以使用memory_target参数把PGA和SGA作为一个整体进行自动管理。
 
(2) SGA也会使用到虚拟内存,在有些平台甚至可以固定在物理内存内。
     我们知道一个进程使用的物理内存,会需要相应大小的虚拟内存,所以要设置合理的虚拟内存大小,以支持系统正常运转。通常情况:如果4G的物理内存,配置4G或者8G虚拟内  存就可以。
     虚拟内存是物理内存不够时进程内存暂时交还出去的内存。
 

(3) 内存分配需要按照颗粒大小来分配。
      比如颗粒是16M,原来总内存是32M,你把32M改为40M,那实际上会变成32M+16M=48M,48是16的整数倍。 
      所以必须按照步长进行分配内存。如果SGA小于128M,那么步长是4M,否则是16M。

      参考2.1节。

(4) 在10G,如果SGA_TARGET<>0,那么AMM生效,db_cache_size失效,_db_cache_size生效,物理内存的80%给SGA+PGA,60%给SGA,这个是初始配置,没有一个统一的标准。

    10G后,每个SGA中的组件可以自动分配,只要设置SGA_TARGET参数 大于0,我们称之为AMM。当你设置sga_target>0时,会启用AMM自动分配这些值:
    __db_cache_size
    __java_pool_size
    __large_pool_size
    __shared_io_pool_size
    __shared_pool_size
    __streams_pool_size    --查看这些隐含参数的sql网上有,感兴趣的同学可以搜搜。

    AMM后,各内存组件实际使用的内存由隐含参数决定了,不再是shared_pool_size,db_cache_size。

    如果设置sga_target=0,关闭AMM,那么下划线的参数失效,启用db_cache_size、shared_pool_size、large_pool这样的参数。
    如果设置sga_target<>0,启用AMM,那么db_cache_size、shared_pool_size、large_pool这些参数仍然有用,而且非常有用,这些参数指定了这些池的最小尺寸,以防止内存抖动。
    如果设置这些值为0,那么AMM会自动跟踪实例的负载,来自动调节这些内存组件的大小,如果负载大起大落,那内存设置也会大起大落,内存会发生剧烈的抖动,所以,我们要设置这几个参数到一个可以抖动的最小值,防止内存抖动太严重,所以AMM适合静态的环境,或者有趋势增大的环境。

 

--查看sga_target参数的设置
SQL> show parameters sga_target    

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_target                           big integer 120M

 

小结:理念的东西,真的让人感到很枯燥,有人说的,如果你过了这个痛苦期,往下的路就平坦多了。得休息一下,补点氧,继续。

待续,下一章继续学习。

 

 

 

 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值