2017-09-14 DBA日記,記oracle沒有采集awr信息一例

一、案例描述

在oracle 11g standard edition中生成awr報告內容爲空,查看dba_hist_sqlstat,dba_hist_time_model沒有內容。

二、問題定義

爲什麼在在oracle 11g standard沒有採集到awr report需要用到的信息呢?

三、診斷

收集數據

  1. 參數原因:網上案例收集,發現從oracle 11g開始awr 信息收集是由參數“control_management_pack_access”控制,在standard edition中,該參數的值爲“none",而在enterprise edittion中它的值是“DIAGNOSTIC+TUNING”,只要將該參數變更爲“DIAGNOSTIC+TUNING”,並重啓實例,即可以收集信息。
  2. 版權原因:據說標準版要收集awr信息是要買licence的。建議各大網友不要缺乏授權時使用。
  3. 過往的經驗:
    • timed_statistics = true
    • statistics_level =typtical
    • 還要有一個收集統計信息的進程要在。

分析

  1. 檢查過上一步的3所有要素,不符合該案例的現象。
  2. 嘗試執行1 ,成功

四、結論

這是由於在標準版把control_management_pack_access設爲none所致。修改爲“DIAGNOSTIC+TUNING”成功。

五、小插曲

在修改完這個參數及重啓實例後,執行以下腳本:

exec sys.dbms_workload_repositroy.create_snapshot();
--過10分鐘後
exec sys.dbms_workload_repositroy.create_snapshot();
生成awr report
@awrrpt ----需要用5分鐘
後來用alter session set events '10046 trace name context forever,level 7'追蹤
發現是以下語句花了400多秒:
with sn as (select DBID, STAT_ID, STAT_NAME
        from DBA_HIST_STAT_NAME

        where STAT_NAME not in ('DB time', 'logons current',

  'opened cursors current',
               'workarea memory allocated',

           'session cursor cache count',
               'session uga memory',
  'session uga memory max',
               'session pga memory', 'session pga
  memory max')
         and STAT_NAME not like '%wait time' and dbid = :dbid),

            s as (select distinct instance_number, stat_id

      from dba_hist_service_stat
                   where dbid = :dbid

                and snap_id = :eid)
      select b.stat_name st,

  e.value - b.value,
             round((e.value - b.value)/:ela,2),

      round((e.value - b.value)/:tran,2)
       from  dba_hist_sysstat b,

           dba_hist_sysstat e
       where b.snap_id         = :bid

  and e.snap_id         = :eid
         and b.dbid            = :dbid

 and e.dbid            = :dbid
         and b.instance_number = :inst_num

         and e.instance_number = :inst_num
         and b.stat_id         =
  e.stat_id
         and (e.stat_id, e.instance_number)
             in
  (select stat_id, instance_number from s)
         and e.stat_name in
  (select stat_name from sn)
         and e.value          >= b.value

   and e.value          >  0
       order by st;
       
懷疑是由於統計值不當所致:
exec SYS.DBMS_STATS.GATHER_SYSTEM_STATS();
exec SYS.DBMS_STATS.GATHER_DICTIONARY_STATS();
重運行一次:秒出

腳本記錄

cat >> /etc/sysctl.conf << eof
fs.aio-max-nr = 1048576
kernel.shmall = 26214400
kernel.shmmax = 108202976870
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max=4194304
net.core.wmem_max=2097152
kernel.panic = 10
kernel.panic_on_oops = 1
kernel.panic_on_unrecovered_nmi = 1
kernel.unknown_nmi_panic = 1
vm.dirty_ratio=10
eof 

sqlplus / as sysdba
create pfile from spfile
alter system set sga_max_size=16g scope=spfile;
alter system set sga_target=16g scope=spfile;
alter system set pga_aggregate_target=4G scope=spfile;
alter system set control_management_pack_access='DIAGNOSTIC+TUNING' scope=both;
shutdown immediate
startup
exec SYS.DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();

exec SYS.DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();
exec SYS.DBMS_STATS.GATHER_SYSTEM_STATS();
exec SYS.DBMS_STATS.GATHER_DICTIONARY_STATS();
@awrrpt
exit
發佈了73 篇原創文章 · 獲贊 6 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章