oracle11g新出参数 MEMORY_MAX_TARGET 和  MEMORY_TARGET 进行自动管理PGA 和SGA 称之为 自动化内存管理(AutomaticMemory Management,AMM)              
MEMORY_MAX_TARGET  :MEMORY_TARGET所能设定的最大值。非动态可调                                                                                                                                              
MEMORY_TARGET :操作系统上 Oracle 所能使用的最大内存值。动态参数,MEMORY_TARGET 是PAG 和SGA的总和.memory_target 为 0 是手动管理,非0为自动管理    
sga_max_size : sga_max_size 是sga的最大值                                                                                                         
sga_target  :  sga_target   是自动和手段管理 sga_target 为0 是手动管理,非0 是自动管理      

oracle 11g 引入参数mymory_max_target 和memory_target 就是oracle的新特性自动内存管理,AMM 的引入, 组合出来有 5 种内存管理形式.
自动内存管理(AMM): memory_target=非0,是自动内存管理  ,如果初始化参数 LOCK_SGA = true ,则AMM 是不可用的。

自动共享内存管理(ASMM): 在memory_target=0 andsga_target=非0 是自动内存管理
手工共享内存管理: memory_target=0 and sga_target=0   指定 share_pool_size 、db_cache_size 等 sga 参数
自动 PGA 管理: memory_target=0 andworkarea_size_policy=auto  and PGA_AGGREGATE_TARGET=值
手动 PGA 管理: memory_target=0 andworkarea_size_policy=manal  然后指定 SORT_AREA_SIZE 等 PGA 参数,一般不使用手动管理PGA

SQL> show parameter result_cache_size
用来缓存sql语句结果
NAME        TYPE          VALUE
------------------------------------ ---------------------------------------------------------------
client_result_cache_size      biginteger         0

 

 

 如果指定了memory_target 而没有指定memory_max_target 重启后,memory_max_target 和memory_target 大小相等
如果指定了memory_max_target 而没有指定memory_target重启后memory_target 为0

SQL> show parameter memory

NAME                                TYPE        VALUE
------------------------------------ ----------- ---------------------------
hi_shared_memory_address            integer     0
memory_max_target                   big integer 1232M
memory_target                       big integer 1232M
shared_memory_address               integer     0


当设置 memory_max_target < memory_target 时:
SQL> alter system set memory_max_target=1000M scope=spfile;

系统已更改。

SQL> shut immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL>
SQL>
SQL>
SQL> startup
ORA-00837: Specified value of MEMORY_TARGET greater than MEMORY_MAX_TARGET

11g AMM管理方式:                                                                                                                
SQL> select name,bytes/1024/1024 fromv$sgainfo;                                                               

NAME                            BYTES/1024/1024                                                                             
-----------------------------------------------                                                                                         
Fixed SGASize                       1.31111908                                                                              
RedoBuffers                           5.015625                                                                                   
Buffer CacheSize                           496                                                                                    
Shared PoolSize                            216                                                                                    
Large PoolSize                               8                                                                                        
Java PoolSize                                8                                                                                       
Streams PoolSize                             8                                                                                    
Shared IO PoolSize                           0                                                                                   
GranuleSize                                  8                                                                                       
Maximum SGASize                     742.328125                                                                        
Startup overhead in SharedPool              64                                                                          

Free SGA MemoryAvailable                     0                                                                             

 SQL> show parametersga                           

NAME                                TYPE        VALUE                                               
------------------------------------ ------------------                                                     
lock_sga                            boolean     FALSE                                               
pre_page_sga                        boolean    FALSE                                          
sga_max_size                        big integer744M                                             
sga_target                          big integer0                                                       

SQL> show parametermemory                                             

  NAME                                TYPE       VALUE                           
------------------------------------ ------------------                                 
hi_shared_memory_address            integer    0                       
memory_max_target                   big integer1232M                  
memory_target                       big integer1232M                        
shared_memory_address               integer    0                           

从上面的参数可以看出,memory_target 非0 说明sga和pga是统一自动管理
就不用看sga_target 为0的意义


在10g管理方式是自动共享内存管理(AutomaticShare Memory Manage) ASMM
ASMM
方式管理,把memory_target 设置为0

SQL> alter systemset memory_target=0 scope=spfile;

SQL> show parametermemory

NAME                                TYPE        VALUE
------------------------------------ ----------- ---------
hi_shared_memory_address            integer     0
memory_max_target                   big integer 0
memory_target                       big integer 0
shared_memory_address               integer     0
说明 AMM管理方式和ASMM管理方式一样
 只要设置memory_target 为 0 是oracle内存手动管理,非0oracle内存自动管理

SQL> show parametersga

NAME                                TYPE        VALUE
------------------------------------ ----------- -------
lock_sga                            boolean     FALSE
pre_page_sga                        boolean     FALSE
sga_max_size                        big integer 144M
sga_target                          big integer 144M
说明在memory_target=0的情况下,oracle内存的手动管理,sga_target=144M,sga的自动管理


SQL> show parameter memory

NAME                                TYPE        VALUE
------------------------------------ ----------- -----------
hi_shared_memory_address            integer     0
memory_max_target                   big integer 0
memory_target                       big integer 0
shared_memory_address               integer     0

SQL> alter system setsga_target=0 ;

系统已更改。

SQL> show parameter sga

NAME                                TYPE        VALUE
------------------------------------ ----------- --------------------
lock_sga                            boolean     FALSE
pre_page_sga                        boolean     FALSE
sga_max_size                        big integer 144M
sga_target                          big integer 0

说明在memory_target=0的情况下,oracle内存的手动管理,sga_target=0M,sga是手动管理

 

SQL> show parameter sga

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
lock_sga                            boolean     FALSE
pre_page_sga                        boolean     FALSE
sga_max_size                        big integer 144M
sga_target                          big integer 0
SQL> alter   system set sga_target=120;

系统已更改。

SQL> show parameter sga

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
lock_sga                            boolean     FALSE
pre_page_sga                        boolean     FALSE
sga_max_size                        big integer 144M
sga_target                          big integer 144M

 

SQL> select component, granule_size/1024/1024 M fromv$sga_dynamic_components;

COMPONENT                                                                M
---------------------------------------------------------------- ----------
sharedpool                                                              4
largepool                                                               4
javapool                                                                4
streamspool                                                             4
DEFAULT buffercache                                                     4
KEEP buffercache                                                        4
RECYCLE buffercache                                                     4
DEFAULT 2K buffercache                                                  4
DEFAULT 4K buffercache                                                  4
DEFAULT 8K buffercache                                                  4
DEFAULT 16K buffercache                                                 4

COMPONENT                                                                M
---------------------------------------------------------------- ----------
DEFAULT 32K buffercache                                                 4
Shared IOPool                                                           4
ASM Buffer Cache                                                         4

已选择14行。

granule size 是 4M大小

 

SQL> alter   system set sga_target=120M;
alter   system set sga_target=120M
*
第 1 行出现错误:
ORA-02097: 无法修改参数, 因为指定的值无效
ORA-00827: 无法将 sga_target 压缩到指定值

 

SQL> alter   system set sga_target=0;

系统已更改。


SQL> show parameter sga

NAME                                TYPE        VALUE
------------------------------------ ----------- ------------
lock_sga                            boolean     FALSE
pre_page_sga                        boolean     FALSE
sga_max_size                        big integer 144M
sga_target                          big integer 0