10g、11g記憶體自動管理

oracle_mao發表於2011-12-14

SGA自動管理:
1、如何檢視SGA是否是自動管理?
在10G中,通過設定sga_target為零和非零值,可以完成手工和自動管理切換,如果sga_target非0,那麼就是自動管理。
而在11G 中,檢視sga是否是自動管理,可和sga_target沒有關係了,因為11g新特性中出現了memory_target引數,memory_target結合和sga和pga的管理(Oracle9i引入pga_aggregate_target,可以自動對PGA進行調整;
Oracle10引入sga_target,可以自動對SGA進行調整。Oracle11g則對這兩部分進行綜合,引入memory_target,可以自動調整所有的記憶體)
2、10g檢視sga自動管理
C:\Users\xiaomao>sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 12月 14 10:11:40 2
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter sga
NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
lock_sga                             boolean
FALSE
pre_page_sga                         boolean
FALSE
sga_max_size                         big integer
432M
sga_target                           big integer
432M
解析:這裡sga_target是一個非0的值,因為這裡看sga是自動管理的,而sga_target的值是小於等於sga_max_size的值得,如果我們手動將sga_target的值改大,是不可以的。
SQL> alter system set sga_target=440M;
alter system set sga_target=440M
*
第 1 行出現錯誤:
ORA-02097: 無法修改引數, 因為指定的值無效
ORA-00823: 指定的 sga_target 的值大於 sga_max_size

SQL> alter system set sga_target=440M scope=spfile;
系統已更改。
SQL> shutdown immediate
資料庫已經關閉。
已經解除安裝資料庫。
ORACLE 例程已經關閉。
SQL> startup
ORACLE 例程已經啟動。
Total System Global Area  461373440 bytes
Fixed Size                  1248512 bytes
Variable Size             134218496 bytes
Database Buffers          318767104 bytes
Redo Buffers                7139328 bytes
資料庫裝載完畢。
資料庫已經開啟。
SQL> show parameter sga
NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
lock_sga                             boolean
FALSE
pre_page_sga                         boolean
FALSE
sga_max_size                         big integer
440M
sga_target                           big integer
440M
官方文件解釋是說:
It is significant that SGA_TARGET includes the entire memory for the SGA, in contrast to earlier releases, in which memory for the internal and fixed SGA was added to the sum of the configured SGA memory parameters. Thus, SGA_TARGET gives you precise control over the size of the shared memory region allocated by the database. If SGA_TARGET is set to a value greater than SGA_MAX_SIZE at startup, then the latter is bumped up to accomodate SGA_TARGET. After startup, SGA_TARGET can be decreased or increased dynamically. However, it can not exceed the value of SGA_MAX_SIZE that was computed at startup
大概意思是說如果設定sga_target的值大於sga_max_size,在重啟db時,sga_max_size的值就會被覆蓋。

3、10g中,sga_target引數的官方解釋

SGA_TARGETProperty Description
Parameter type Big integer
Syntax SGA_TARGET = integer [K | M | G]
Default value 0 (SGA autotuning is disabled)
Modifiable ALTER SYSTEM
Range of values 64 to operating system-dependent
Basic Yes
SGA_TARGET specifies the total size of all SGA components. If SGA_TARGET is specified, then the following memory pools are automatically sized:
•Buffer cache (DB_CACHE_SIZE)
•Shared pool (SHARED_POOL_SIZE)
•Large pool (LARGE_POOL_SIZE)
•Java pool (JAVA_POOL_SIZE)
•Streams pool (STREAMS_POOL_SIZE)
解析:這裡說如果sga_target的值被指定,那麼這些pool_size就被動態管理

SQL> select name,value from v$parameter where name like '%pool_size%' or name like 'db_cache_size' ;
 
NAME                 VALUE
-------------------- ----------
shared_pool_size     0
large_pool_size      0
java_pool_size       0
streams_pool_size    0
db_cache_size        0
然後我們現在如何更快的檢視此時這些值的大小呢?那就要通過檢視一些隱含引數了
SQL> select a.ksppinm name,b.ksppstvl value
  2  from x$ksppi a,x$ksppcv b
  3  where a.indx=b.indx
  4  and (a.ksppinm like '%pool_size%'
  5  or a.ksppinm like '%target%' or a.ksppinm like '%db_cache_size%')
  6  ;
 
NAME                                     VALUE
---------------------------------------- --------------------------------------------------
_NUMA_pool_size                          Not specified
__shared_pool_size                       130023424
shared_pool_size                         0
__large_pool_size                        4194304                 --這裡就是large_pool_size的大小
large_pool_size                          0
__java_pool_size                         4194304              
java_pool_size                           0
__streams_pool_size                      0
streams_pool_size                        0
_io_shared_pool_size                     4194304
_backup_io_pool_size                     1048576
sga_target                               469762048
__db_cache_size                          322961408
db_cache_size                            0
_db_mttr_sim_target                     
archive_lag_target                       0
_fast_start_instance_recovery_target     0
_target_rba_max_lag_percentage           90
fast_start_io_target                     0
fast_start_mttr_target                   0
 
NAME                                     VALUE
---------------------------------------- --------------------------------------------------
db_flashback_retention_target            1440
global_context_pool_size                
pga_aggregate_target                     149946368
olap_page_pool_size                      0
_olap_page_pool_hit_target               100
 
25 rows selected
4、11g中檢視sga是否自動管理
主要是檢視memory_target這個引數。
SQL> show parameter mem

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
hi_shared_memory_address             integer     0
memory_max_target                    big integer 6464M
memory_target                        big integer 6464M
shared_memory_address                integer     0
而如果我們把memory_target的值擅自手動改大些,也會出現10g裡sga_target的問題

5、11g中檢視sga和pga大小
SQL> show parameter sga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
lock_sga                             boolean     FALSE
pre_page_sga                         boolean     FALSE
sga_max_size                         big integer 2336M
sga_target                           big integer 0
SQL> show parameter pga
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 0
由於sga和pga都是動態管理了,所以要看大小的話,還是需要看隱含引數的
SQL> select a.ksppinm name,b.ksppstvl value
  2  from x$ksppi a,x$ksppcv b
  3  where a.indx=b.indx
  4  and (a.ksppinm like '%sga_target%'
  5  or a.ksppinm like '%pga%target%');

NAME                                                                             VALUE
-------------------------------------------------------------------------------- --------------------------------------------------
sga_target                                                                       0
__sga_target                                                                     2449473536
pga_aggregate_target                                                             0
__pga_aggregate_target                                                           4328521728

以上為我的簡單理解~~如果誤理解,請指正

 

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

相關文章