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

你可能感兴趣的