AMM和ASMM理解


oracle11g新出参数  MEMORY_MAX_TARGET 和  MEMORY_TARGET 进行自动管理PGA 和SGA 称之为 自动化内存管理(Automatic Memory 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 and sga_target=非0 是自动内存管理
手工共享内存管理: memory_target=0 and sga_target=0   指定 share_pool_size 、db_cache_size 等 sga 参数
自动 PGA 管理: memory_target=0 and workarea_size_policy=auto  and PGA_AGGREGATE_TARGET=值
手动 PGA 管理: memory_target=0 and workarea_size_policy=manal  然后指定 SORT_AREA_SIZE 等 PGA 参数,一般不使用手动管理PGA

SQL> show parameter result_cache_size
用来缓存sql语句结果
NAME         TYPE          VALUE
------------------------------------ --------------------------------- ------------------------------
client_result_cache_size      big integer         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 from v$sgainfo;                                                               

NAME                             BYTES/1024/1024                                                                             
-------------------------------- ---------------                                                                                         
Fixed SGA Size                        1.31111908                                                                              
Redo Buffers                            5.015625                                                                                   
Buffer Cache Size                            496                                                                                    
Shared Pool Size                             216                                                                                    
Large Pool Size                                8                                                                                        
Java Pool Size                                 8                                                                                       
Streams Pool Size                              8                                                                                    
Shared IO Pool Size                            0                                                                                   
Granule Size                                   8                                                                                       
Maximum SGA Size                      742.328125                                                                        
Startup overhead in Shared Pool               64                                                                           

Free SGA Memory Available                      0                                                                             

 SQL> show parameter sga                           

NAME                                 TYPE        VALUE                                               
------------------------------------ ----------- -------                                                     
lock_sga                             boolean     FALSE                                               
pre_page_sga                         boolean     FALSE                                          
sga_max_size                         big integer 744M                                             
sga_target                           big integer 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_target 非0 说明 sga和pga是统一自动管理
就不用看sga_target 为0的意义

 

 


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

SQL> alter system set memory_target=0 scope=spfile;

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
说明 AMM管理方式和ASMM管理方式一样
 只要设置memory_target 为 0 是oracle内存手动管理,非0oracle内存自动管理

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
说明在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 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

说明在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 from v$sga_dynamic_components;

COMPONENT                                                                 M
---------------------------------------------------------------- ----------
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

COMPONENT                                                                 M
---------------------------------------------------------------- ----------
DEFAULT 32K buffer cache                                                  4
Shared IO Pool                                                            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

 


 

你可能感兴趣的:(oracle基础)