概念對比介紹 相信有些人會對ORACLE當中的AMM(Automatic Memory Management)與ASMM(Automatic Shared Memory Management)有些迷惑或混淆,不清楚兩者的異同,本文會從幾個方面來總結一下兩者的異同。如有不足或疏漏之處,敬請指正! 從O... ...
概念對比介紹
相信有些人會對ORACLE當中的AMM(Automatic Memory Management)與ASMM(Automatic Shared Memory Management)有些迷惑或混淆,不清楚兩者的異同,本文會從幾個方面來總結一下兩者的異同。如有不足或疏漏之處,敬請指正!
從ORACLE發佈的版本歷史(時間軸)來看,ORACLE的記憶體管理的大致歷程如下:
ORACLE 9i PGA自動管理,SGA手動管理
ORACLE 10g PGA自動管理,SGA自動管理(ASMM,自動共用記憶體管理)
ORACLE 11g PGA,SGA統一自動管理(AMM,自動記憶體管理)
ORACLE 12c 跟11g一樣,沒有變化
官方文檔的介紹資料如下:
· Oracle 9i
· Beginning with Oracle9i, the dynamic SGA infrastructure allowed for the sizing of the Buffer Cache, Shared Pool and the Large Pool without having to shut down the database. Key features being:
o Dynamic Memory resizing
o DB_CACHE_SIZE instead of DB_BLOCK_BUFFERS
o DB_nK_CACHE_SIZE for multiple block sizes
o PGA_AGGREGATE_TARGET Introduction of Automatic PGA Memory management
· Oracle Database 10g
· Automatic Shared Memory Management (ASMM) was introduced in 10g. You enable the automatic shared memory management feature by setting the SGA_TARGET parameter to a non-zero value.
· Oracle Database 11g
· Automatic Memory Management is being introduced in 11g. This enables automatic tuning of PGA and SGA with use of two new parameters named MEMORY_MAX_TARGET and MEMORY_TARGET
· Oracle Database 12c
Automatic Memory Management keeps the same behaviour as in 11g.
自動共用記憶體管理(Automatic Shared Memory Management ASMM)是ORACLE 10g開始引入的的新技術,ASMM用來實現SGA的自動管理。。當啟用自動共用記憶體管理後,不再需要為每個記憶體組件設定值,當然如果你設置SGA_TARGET的同時,設置了db_cache_size、shared_pool_size這些參數,那麼db_cache_size、shared_pool_size這些參數值會作為最小值要求。官方關於Automatic Shared Memory Management的介紹如下:
Automatic Shared Memory Management
In previous database releases, a database administrator (DBA) was required to manually specify different SGA component sizes by setting a number of initialization parameters, including the SHARED_POOL_SIZE, DB_CACHE_SIZE, JAVA_POOL_SIZE, and LARGE_POOL_SIZE parameters. Oracle Database 10g includes the Automatic Shared Memory Management feature which simplifies the SGA memory management significantly. In Oracle Database 10g, a DBA can simply specify the total amount of SGA memory available to an instance using the SGA_TARGET initialization parameter and the Oracle Database will automatically distribute this memory among various subcomponents to ensure most effective memory utilization.
When automatic SGA memory management is enabled, the sizes of the different SGA components are flexible and can adapt to the needs of a workload without requiring any additional configuration. The database automatically distributes the available memory among the various components as required, allowing the system to maximize the use of all available SGA memory.
ORACLE 10G版本開始推出了ASMM,自動SGA管理,它的出現一定程度上幫助DBA解決了管理SGA的問題,通過設置參數SGA_TARGET來控制ASMM,其中SGA_TARGET為零表示禁用ASMM,非零值表示啟用ASMM。但是在10G R1等早期版本,ASMM還不夠成熟,而且存在比較多的BUG,導致了比較多的問題。在ORACLE 10g R2後續版本中,ASMM才逐漸完善併成熟。
到了11g之後,ORACLE又實現了PGA和SGA的統一自動管理 ,這個稱之為自動化記憶體管理(Automatic Memory Management,AMM)。從這些演化歷程來看,ORACLE從最開始的手動配置各個組件參數,慢慢逐漸向智能化、傻瓜化、自動化的方向穩步前進。這個是一個必然的歷史趨勢。關於AMM的官方文檔介紹如下:
About Automatic Memory Management
The simplest way to manage instance memory is to allow the Oracle Database instance to automatically manage and tune it for you. To do so (on most platforms), you set only a target memory size initialization parameter (MEMORY_TARGET) and optionally a maximum memory size initialization parameter (MEMORY_MAX_TARGET). The instance then tunes to the target memory size, redistributing memory as needed between the system global area (SGA) and the instance program global area (instance PGA). Because the target memory initialization parameter is dynamic, you can change the target memory size at any time without restarting the database. The maximum memory size serves as an upper limit so that you cannot accidentally set the target memory size too high, and so that enough memory is set aside for the Oracle Database instance in case you do want to increase total instance memory in the future. Because certain SGA components either cannot easily shrink or must remain at a minimum size, the instance also prevents you from setting the target memory size too low.
If you create your database with Database Configuration Assistant (DBCA) and choose the basic installation option, automatic memory management is enabled. If you choose advanced installation, Database Configuration Assistant (DBCA) enables you to select automatic memory management.
ORACLE 11g 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。
Oracle Database 11g supports various memory management methods, which are chosen by initialization parameter settings. Oracle recommends that you enable the automatic memory management method.
- Automatic Memory Management – For Both the SGA and Instance PGA
- Automatic Shared Memory Management – For the SGA
- Manual Shared Memory Management – For the SGA
- Automatic PGA Memory Management –For the Instance PGA
- Manual PGA Memory Management – For the Instance PGA
ASMM切換到AMM
如下所示,當前實驗環境下自動記憶體管理已被禁用(memory_target=0)
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> show parameter memory_target ;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_target big integer 0
SQL> show parameter memory_max_target;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 0
SQL>
SQL> show parameter sga;