Oracle 記憶體管理方式

dawn009發表於2015-02-28

轉載於http://blog.csdn.net/tonyzhou_cn/article/details/9172639
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> 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 ------10.2.0.1是沒有這個引數的,

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29119536/viewspace-1443382/,如需轉載,請註明出處,否則將追究法律責任。

相關文章