oracle 11g 自动内存管理(转:http://www.cnblogs.com/daduxiong/archive/2010/08/12/1798285.html)

 

Oracle对内存的管理的 优化从未间断,从8i到11g不断地提出新的管理概念。每个本版都对内存管理进行了简化:

  1. 8i->9i:PGA的自动管理;
  2. 9i->10g:SGA的自动管理;
  3. 10g->11g:MEMORY(SGA+PGA)的自动管理。

在11g中oracle引入了

1 MEMORY_TARGET:oracle所能使用的最大内存,该参数可以动态调整。<BR>MEMORY_MAX_TARGET:MEMORY_TARGET参数所能动态设定的最大值,不能动态调整,需要重启数据库。

注:oracle的内存管理方式可以根据本版向下兼容的,11g可以实现10g,9i,8i时的管理方式。

oracle环境:

下面通过一个小测试来看看oracle的内存分配(没有对PGA测试)。

 

01 SQL> select component,current_size,min_size,max_size from v$memory_dynamic_components;
02   
03 COMPONENT                      CURRENT_SIZE   MIN_SIZE   MAX_SIZE              
04 ------------------------------ ------------ ---------- ----------              
05 shared pool                       130023424  109051904  130023424              
06 large pool                          4194304    4194304    4194304              
07 java pool                           4194304    4194304    4194304              
08 streams pool                              0          0          0              
09 SGA Target                        322961408  322961408  322961408              
10 DEFAULT buffer cache              176160768  176160768  197132288              
11 KEEP buffer cache                         0          0          0              
12 RECYCLE buffer cache                      0          0          0              
13 DEFAULT 2K buffer cache                   0          0          0              
14 DEFAULT 4K buffer cache                   0          0          0              
15 DEFAULT 8K buffer cache                   0          0          0              
16   
17 COMPONENT                      CURRENT_SIZE   MIN_SIZE   MAX_SIZE              
18 ------------------------------ ------------ ---------- ----------              
19 DEFAULT 16K buffer cache                  0          0          0              
20 DEFAULT 32K buffer cache                  0          0          0              
21 Shared IO Pool                            0          0          0              
22 PGA Target                        218103808  213909504  218103808              
23 ASM Buffer Cache                          0          0          0              
24   
25 已选择16行。
26   
27 SQL> show parameter memory_target
28   
29 NAME                                 TYPE        VALUE                         
30 ------------------------------------ ----------- ------------------------------
31 memory_target                        big integer 516M                          
32   
33 SQL> run
34   1* select (322961408+218103808)/1024/1024||'M' "SGA+PGA" from dual
35   
36 SGA+                                                                           
37 ----                                                                           
38 516M

 

在此可以看出memory_target参数管理的内存是PGA与SGA之和。

单独计算SGA,通过shared pool,streams pool,java pool,large pool,buffer cache,
ASM Buffer Cache参数求和,计算得出当前SGA使用的大小
314572800

1 SQL> select (130023424+4194304+4194304+176160768) SGA from dual
2   2  ;
3   
4        SGA                                                                     
5 ----------                                                                     
6  314572800

通过SGA的目标值减去当前SGA的动态消耗。

 

1 SQL> select 322961408-314572800 "sga target-sga" from dual;<BR><BR>sga target-sga<BR>--------------<BR>       8388608<BR><BR>SQL> select * from v$sgastat where pool is null;<BR><BR>POOL         NAME                            BYTES                             <BR>------------ -------------------------- ----------                             <BR>             fixed_sga                     1375792                             <BR>             buffer_cache                167772160                             <BR>             log_buffer                    5804032                             <BR><BR>SQL> select 1375792+5804032 "fixed_sga+log_buffer" from dual;<BR><BR>fixed_sga+log_buffer                                                           <BR>--------------------                                                           <BR>             7179824                                                <BR>

在SGA中的包括LOG BUFFER,fixed_sga部分,在最开始的v$memory_dynamic_components视图中
并没有包括这两部分,也说明这两个部分是固定的值,不会动态的改变。
出去SGA动态消耗后,再减去固定消耗,得到当前SGA还剩余多少。

 

1 SQL> select 8388608-7179824 from dual;<BR><BR>8388608-7179824                                                                <BR>---------------                                                                <BR>        1208784<BR>

 

 

在动态分配视图的查询结果中包含Shared IO pool部分,以下是对该参数的说明:
Shared IO Pool Memory
Wait until a shared I/O pool buffer becomes available. This happens when processes are
using these buffers for I/O and the current process needs to wait for the release
of any one of the buffers to the shared I/O pool.

Wait Time: 10msec

Parameters: None                                                               

说明:shared IO pool参数设置是为了尽量减小进程IO的等待而专门配置的参数。
从分析角度看应该是属于PGA部分。

 

posted on 2010-08-17 11:33  草原和大树  阅读(990)  评论(0编辑  收藏  举报