根據v$db_cache_advice動態視圖調整db_cache_size

select size_for_estimate, buffers_for_estimate ,ESTD_PHYSICAL_READ_factor,ESTD_PHYSICAL_READS from v$db_cache_advice  
  2      where block_size='8192' and advice_status='ON';

中,size_for_estimate表示預計的數據庫高速緩衝區的大小(即:db_cache_size的值)。ESTD_PHYSICAL_READS表示預計的物理讀。

當增加數據庫高速緩衝區的的時候,物理讀(ESTD_PHYSICAL_READS)越少,說明命中率越高。

 

 

 

1.優化緩衝區大小、提高服務器的命中率
db_cache_size                        big integer 838860800
2.查看緩衝區命中率是否需要調優.

select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
     "Buffer Cache Hit Ratio" 
  from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
  where physical.name = 'physical reads'
  and direct.name='physical reads direct'
  and lobs.name='physical reads direct (lob)'
  and logical.name='session logical reads';
當命中率>90%說明命中率很高了

3。獲取推薦的值
select name,size_for_estimate,v$db_cache_advice.ESTD_PHYSICAL_READS from v$db_cache_advice  
where block_size='8192' and advice_status='ON';

set linesize 1000
---20100619Oracle9i數據 Solaris 9i操作系統
SQL> set linesize 1000
SQL> select size_for_estimate, buffers_for_estimate ,ESTD_PHYSICAL_READ_factor,ESTD_PHYSICAL_READS from v$db_cache_advice  
    where block_size='8192' and advice_status='ON';

SIZE_FOR_ESTIMATE BUFFERS_FOR_ESTIMATE ESTD_PHYSICAL_READ_FACTOR ESTD_PHYSICAL_READS
----------------- -------------------- ------------------------- -------------------
               80                 9925                   28.9757          1436311200
              160                19850                    2.1053           104360120
              240                29775                    1.5819            78413087
              320                39700                    1.4262            70693980
              400                49625                    1.3543            67131735
              480                59550                     1.278            63349434
              560                69475                    1.1893            58954568
              640                79400                    1.1325            56135206
              720                89325                    1.0762            53347837
              800                99250                         1            49569438
              880               109175                     .7067            35030953

SIZE_FOR_ESTIMATE BUFFERS_FOR_ESTIMATE ESTD_PHYSICAL_READ_FACTOR ESTD_PHYSICAL_READS
----------------- -------------------- ------------------------- -------------------
              960               119100                     .3991            19784701
             1040               129025                     .2305            11423374
             1120               138950                     .1927             9552903
             1200               148875                     .1506             7466278
             1280               158800                     .1501             7438186
             1360               168725                     .1501             7438186
             1440               178650                     .1501             7438186
             1520               188575                     .1501             7438186
             1600               198500                     .1501             7438186
SIZE_FOR_ESTIMATE  M 爲單位:
當SIZE_FOR_ESTIMATE=80M 的時候 ESTD_PHYSICAL_READS=1436311200
當SIZE_FOR_ESTIMATE=1120M 的時候 ESTD_PHYSICAL_READS=9552903
當SIZE_FOR_ESTIMATE=1280M 的時候 ESTD_PHYSICAL_READS=7438186
之後ESTD_PHYSICAL_READS固定了
所以應該過大db_cache_size=1120M的值使得
4.修改發現DB_cache_size太大了。過大SGA區域解決
alter system set db_cache_size=1120M
--sga設置太小了導致
SQL>  alter system set db_cache_size=1120M;
alter system set db_cache_size=1120M
*
ERROR 位於第 1 行:
ORA-02097: 無法修改參數,因爲指定的值無效
ORA-00384: 沒有足夠的內存來增加高速緩存的大小
之前的值
sga_max_size                         big integer 1494715120
SQL>alter system set SGA_MAX_SIZE=3500M scope=spfile; 
系統已更改。

重新啓動與關閉解決
SQL> shutdown immediate
數據庫已經關閉。
已經卸載數據庫。
ORACLE 例程已經關閉。
SQL> startup
ORACLE 例程已經啓動。

Total System Global Area 3675756336 bytes
Fixed Size                   735024 bytes
Variable Size            2835349504 bytes
Database Buffers          838860800 bytes
Redo Buffers                 811008 bytes
數據庫裝載完畢。
數據庫已經打開。
查看命中率\當前只有80的滿足要求
SQL> select size_for_estimate, buffers_for_estimate ,ESTD_PHYSICAL_READ_factor,ESTD_PHYSICAL_READS from v$db_cache_advice 
  2      where block_size='8192' and advice_status='ON';

SIZE_FOR_ESTIMATE BUFFERS_FOR_ESTIMATE ESTD_PHYSICAL_READ_FACTOR ESTD_PHYSICAL_READS
----------------- -------------------- ------------------------- -------------------
               80                 9925                         1                1528
              160                19850                         1                1528
              240                29775                         1                1528
              320                39700                         1                1528
              400                49625                         1                1528
              480                59550                         1                1528
              560                69475                         1                1528
              640                79400                         1                1528
              720                89325                         1                1528
              800                99250                         1                1528
              880               109175                         1                1528

SIZE_FOR_ESTIMATE BUFFERS_FOR_ESTIMATE ESTD_PHYSICAL_READ_FACTOR ESTD_PHYSICAL_READS
----------------- -------------------- ------------------------- -------------------
              960               119100                         1                1528
             1040               129025                         1                1528
             1120               138950                         1                1528
             1200               148875                         1                1528
             1280               158800                         1                1528
             1360               168725                         1                1528
             1440               178650                         1                1528
             1520               188575                         1                1528
             1600               198500                         1                1528
命中率降低了?         
    SQL> select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
  2       "Buffer Cache Hit Ratio" 
  3    from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
  4    where physical.name = 'physical reads'
  5    and direct.name='physical reads direct'
  6    and lobs.name='physical reads direct (lob)'
  7    and logical.name='session logical reads';

Buffer Cache Hit Ratio
----------------------
            .906673167

繼續縮小SGA大小
SQL>alter system set SGA_MAX_SIZE=3000M scope=spfile;

SQL> shutdown immediate
數據庫已經關閉。
已經卸載數據庫。
ORACLE 例程已經關閉。
SQL> startup
ORACLE 例程已經啓動。

Total System Global Area 3155661888 bytes
Fixed Size                   734272 bytes
Variable Size            2315255808 bytes
Database Buffers          838860800 bytes
Redo Buffers                 811008 bytes
數據庫裝載完畢。
數據庫已經打開。
select size_for_estimate, buffers_for_estimate ,ESTD_PHYSICAL_READ_factor,ESTD_PHYSICAL_READS from v$db_cache_advice  
    where block_size='8192' and advice_status='ON';


繼續測試:等待30分鐘之後測試
    SQL> alter system set db_cache_size=1120M;
    
    select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
     "Buffer Cache Hit Ratio" 
  from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
  where physical.name = 'physical reads'
  and direct.name='physical reads direct'
  and lobs.name='physical reads direct (lob)'
  and logical.name='session logical reads';
  ---命中率逐漸的提高了
  ---半個小時之後查詢命中率是98%
  SQL> select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
  2       "Buffer Cache Hit Ratio" 
  3    from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
  4    where physical.name = 'physical reads'
  5    and direct.name='physical reads direct'
  6    and lobs.name='physical reads direct (lob)'
  7    and logical.name='session logical reads';

Buffer Cache Hit Ratio
----------------------
            .980309028
-----查詢推薦的值
show parameter db_block_size
8192

select name,size_for_estimate,v$db_cache_advice.ESTD_PHYSICAL_READS from
v$db_cache_advice  where block_size='8192' and advice_status='ON';

NAME                 SIZE_FOR_ESTIMATE ESTD_PHYSICAL_READS
-------------------- ----------------- -------------------
DEFAULT                            112                9581
DEFAULT                            224                9514
DEFAULT                            336                9514
DEFAULT                            448                9514
DEFAULT                            560                9514
DEFAULT                            672                9514
DEFAULT                            784                9514
DEFAULT                            896                9514
DEFAULT                           1008                9514
DEFAULT                           1120                9514
DEFAULT                           1232                9514

NAME                 SIZE_FOR_ESTIMATE ESTD_PHYSICAL_READS
-------------------- ----------------- -------------------
DEFAULT                           1344                9514
DEFAULT                           1456                9514
DEFAULT                           1568                9514
DEFAULT                           1680                9514
DEFAULT                           1792                9514
DEFAULT                           1904                9514
DEFAULT                           2016                9514
DEFAULT                           2128                9514
DEFAULT                           2240                9514
顯示只要112M大小的空間就可以穩定降低ESTD_PHYSICAL_READS
alter system set db_cache_size=112M
NAME                 SIZE_FOR_ESTIMATE ESTD_PHYSICAL_READS
-------------------- ----------------- -------------------
DEFAULT                             16                   0
DEFAULT                             32                   0
DEFAULT                             48                   0
DEFAULT                             64                   0
DEFAULT                             80                   0
DEFAULT                             96                   0
DEFAULT                            112                   0
DEFAULT                            128                   0
DEFAULT                            144                   0
DEFAULT                            160                   0
DEFAULT                            176                   0

NAME                 SIZE_FOR_ESTIMATE ESTD_PHYSICAL_READS
-------------------- ----------------- -------------------
DEFAULT                            192                   0
DEFAULT                            208                   0
DEFAULT                            224                   0
DEFAULT                            240                   0
DEFAULT                            256                   0
DEFAULT                            272                   0
DEFAULT                            288                   0
DEFAULT                            304                   0
DEFAULT                            320                   0
---查看命中率
  select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
     "Buffer Cache Hit Ratio" 
  from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
  where physical.name = 'physical reads'
  and direct.name='physical reads direct'
  and lobs.name='physical reads direct (lob)'
  and logical.name='session logical reads';

Buffer Cache Hit Ratio
----------------------
            .982795739
說明Oracle更換峯值的情況決定db_cache_size的大小。
所以設置最大峯值滿足的情況。
alter system set db_cache_size=1120M;滿足峯值的時候最大值
select name,size_for_estimate,v$db_cache_advice.ESTD_PHYSICAL_READS from
v$db_cache_advice  where block_size='8192' and advice_status='ON';


oracle10g Solaris 10 sparc系統調整

--查
  select name,size_for_estimate,v$db_cache_advice.ESTD_PHYSICAL_READS from
v$db_cache_advice  where block_size='8192' and advice_status='ON';

-------------------- ----------------- -------------------
DEFAULT                            128             1206647
DEFAULT                            256             1067789
DEFAULT                            384              987752
DEFAULT                            512              965164
DEFAULT                            640              913815
DEFAULT                            768              893485
DEFAULT                            896              867321
DEFAULT                           1024              808884
DEFAULT                           1152              599909
DEFAULT                           1280              344618
--此時開始保持在一個穩定的讀取值
alter system set db_cache_size=1196M

DEFAULT                           1296              321763

NAME                 SIZE_FOR_ESTIMATE ESTD_PHYSICAL_READS
-------------------- ----------------- -------------------
DEFAULT                           1408              285030
DEFAULT                           1536              280506
DEFAULT                           1664              280325
DEFAULT                           1792              279816
DEFAULT                           1920              266871
DEFAULT                           2048              235838
DEFAULT                           2176              231298
DEFAULT                           2304              228483
DEFAULT                           2432              224971
DEFAULT                           2560              219467
--修改
alter system set db_cache_size=1196M
--查看命中率
  select 1 - ((physical.value - direct.value - lobs.value) / logical.value)
     "Buffer Cache Hit Ratio" 
  from v$sysstat physical,v$sysstat direct,v$sysstat lobs,v$sysstat logical
  where physical.name = 'physical reads'
  and direct.name='physical reads direct'
  and lobs.name='physical reads direct (lob)'
  and logical.name='session logical reads';

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