11g自動內存設置-整理自官方文檔

The simplest way to manage instance memory is to allow the Oracle Database instance to automatically manage and tune it for you.

一種簡單管理內存的方式是:讓oracle自動爲你管理和調優!

 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).

多數平臺上,你只需設置初始化參數MEMORY_TARGET,再隨意(大於後者等於MEMORY_TARGET)設置初始化參數MEMORY_MAX_TARGET

 The total memory that the instance uses remains relatively constant, based on the value of MEMORY_TARGET, and the instance automatically distributes memory between the system global area (SGA) and the instance program global area (instance PGA). As memory requirements change, the instance dynamically redistributes memory between the SGA and instance PGA.

實例的總內存以MEMORY_TARGET設置的值爲準(開機時oracle以MEMORY_TARGET參數值爲準給instance分配內存!如果業務需要分配更大內存,oracle將自動擴展,但不能超過MEMORY_MAX_TARGET的值),實例根據需要自動分配內存給SGA和PGA

When automatic memory management is not enabled, you must size both the SGA and instance PGA manually.

當自動內存管理未啓用時,你必須指定SGA和PGA的內存大小

Because the MEMORY_TARGET initialization parameter is dynamic, you can change MEMORY_TARGET at any time without restarting the database.

MEMORY_TARGET 是一個動態參數,可以再任何需要的時候進行調整而不必重啓實例!

MEMORY_MAX_TARGET, which is not dynamic, serves as an upper limit so that you cannot accidentally set MEMORY_TARGET too high, and so that enough memory is set aside for the 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 MEMORY_TARGET too low.

MEMORY_MAX_TARGET是一個靜態參數,作爲一個上限值(限制MEMORY_TARGET參數),你不能將MEMORY_TARGET設置的過高,並且要保留足夠的內存來滿足在以後實例的擴張。但是實例總是不允許你將MEMORY_TARGET參數設置的過低,因爲SGA的組件大小有最小值限定,還有些組件是很難縮小的!

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.

如果你用DBCA創建數據庫並且選擇基本安裝選項,自動內存默認是啓用的!假如你是高級安裝你也可以選擇啓用自動內存管理!

 開啓自動內存管理的步驟:

1:Start SQL*Plus and connect to the database as SYSDBA.

以sys用戶登錄

2:Calculate the minimum value for MEMORY_TARGET as follows:

計算MEMORY_TARGET 的最小值!

a:Determine the current sizes of SGA_TARGET and PGA_AGGREGATE_TARGET by entering the following SQL*Plus command:

確定SGA_TARGET ,PGA_AGGREGATE_TARGET 參數的大小:

show parameter target

NAME                          TYPE        VALUE
------------------------------ ----------- ----------------
archive_lag_target             integer     0
db_flashback_retention_target  integer     1440
fast_start_io_target           integer     0
fast_start_mttr_target         integer     0
memory_max_target              big integer 0
memory_target                  big integer 0
pga_aggregate_target           big integer 90M
sga_target                     big integer 272M

b:Run the following query to determine the maximum instance PGA allocated since the database was started:Run the following query to determine the maximum instance PGA allocated since the database was started:

確定從數據庫啓動以來實例分配給PGAde 的最大值:

 select value/1024/1024||'m' from v$pgastat where name='maximum PGA allocated';

c:Compute the maximum value between the query result from step 2b and PGA_AGGREGATE_TARGET. Add SGA_TARGET to this value.

計算memory_target 最大值

memory_target = sga_target + max(pga_aggregate_target, maximum PGA allocated)
For example, if SGA_TARGET is 272M and PGA_AGGREGATE_TARGET is 90M as shown above, and if the maximum PGA allocated is determined to be 120M, then MEMORY_TARGET should be at least 392M (272M + 120M).

例如,如果SGA_TARGET is 272M, PGA_AGGREGATE_TARGET is 90M,maximum PGA allocated is 120M,那麼MEMORY_TARGET 的最小值爲:392M (272M + 120M)。

這只是他的最小值!你也可以將值設置的更大,前提是有足夠的物理內存!

3:For the MEMORY_MAX_TARGET initialization parameter, decide on a maximum amount of memory that you would want to allocate to the database for the foreseeable future. That is, determine the maximum value for the sum of the SGA and instance PGA sizes. This number can be larger than or the same as the MEMORY_TARGET value that you chose in the previous step.

MEMORY_MAX_TARGET 這個參數的設置要大於或者等於MEMORY_TARGET 參數的值。根據網上的一些經驗之談MEMORY_MAX_TARGET = OS_MEMORY*80%這參數的值沒有固定公式可參考!要根據實際情況來確定!!

修改參數的腳本:

ALTER SYSTEM SET MEMORY_MAX_TARGET = nM SCOPE = SPFILE;
如果修改了該參數MEMORY_MAX_TARGET 需重啓實例!

The dynamic performance view V$MEMORY_DYNAMIC_COMPONENTS shows the current sizes of all dynamically tuned memory components, including the total sizes of the SGA and instance PGA.

動態視圖V$MEMORY_DYNAMIC_COMPONENTS 顯示了當前動態內存組件的大小。包括SGA,PGA的總大小!

The view V$MEMORY_TARGET_ADVICE provides tuning advice for the MEMORY_TARGET initialization parameter.

SQL>  select * from v$memory_target_advice order by memory_size;
 
MEMORY_SIZE MEMORY_SIZE_FACTOR ESTD_DB_TIME ESTD_DB_TIME_FACTOR    VERSION
----------- ------------------ ------------ ------------------- ----------
        180                 .5          458               1.344          0
        270                .75          367              1.0761          0
        360                  1          341                   1          0
        450               1.25          335               .9817          0
        540                1.5          335               .9817          0
        630               1.75          335               .9817          0
        720                  2          335               .9817          0

The row with the MEMORY_SIZE_FACTOR of 1 shows the current size of memory, as set by the MEMORY_TARGET initialization parameter, and the amount of DB time required to complete the current workload. In previous and subsequent rows, the results show several alternative MEMORY_TARGET sizes. For each alternative size, the database shows the size factor (the multiple of the current size), and the estimated DB time to complete the current workload if the MEMORY_TARGET parameter were changed to the alternative size. Notice that for a total memory size smaller than the current MEMORY_TARGET size, estimated DB time increases. Notice also that in this example, there is nothing to be gained by increasing total memory size beyond 450MB. However, this situation might change if a complete workload has not yet been run.





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章