zoukankan      html  css  js  c++  java
  • oracle IO CPU统计


      IO表现在两个方面,IOPS和吞吐量,我们OLTP系统,一般比较关心IOPS,及每个IO的响应时间,

     
      以前针对IOPS统计,我们一直是按照statspack的physical reads+physical writes来统计,这个是很不准确的
     
      按照文档的解释:
     
      physical reads:Total number of data blocks read from disk
     
      这个是按照block读取的数量来统计的,oracle的IO种类有很多,如果是scatter read或者parallel read,一个IO会读取多块的,
     
      这样计算IOPS会偏大,重新调整后,发现统计出来的曲线和从存储段观察的比较吻合
     
      9I:
    
      –IOPS&MBPS
    
      select sum(iops) as iops,sum(mbps) as mbps
    
      from (
    
      select sum(phyrds + phywrts) as IOPS,
    
      sum(phyblkrd + phyblkwrt) as MBPS
    
      from (select a.phyrds,a.phywrts,a.phyblkrd * b.block_size / 1024 / 1024 as phyblkrd,a.phyblkwrt * b.BLOCK_SIZE / 1024 / 1024 as phyblkwrt
    
      from v$filestat a,v$datafile b
    
      where a.file# = b.file#)
    
      union all
    
      select sum(decode(name,’redo writes’,value,’0′)) as IOPS,
    
      sum(decode(name,’redo size’,value,’0′)) / 1024 / 1024 as MBPS
    
      from v$sysstat where name in( ‘redo writes’,'redo size’));
    
      10G/11G
    
      –IOPS&MBPS
    
      select sum(decode(name,’physical read IO requests’,value,’physical write IO requests’,value,0)) as iops,
    
      sum(decode(name,’physical read bytes’,value,’physical write bytes’,value,0)) / 1024 / 1024 as mbps
    
      from v$sysstat
    
      where name in (’physical read IO requests’,'physical write IO requests’,
    
      ‘physical read bytes’,'physical read total bytes’,
    
      ‘physical write bytes’,'physical write total bytes’,'physical read total IO requests’,'physical write total IO requests’
    
      );
    
      最近将这些统计指标做进了监控系统,看看效果怎么样
     

    oracle数据库查询表空间使用率,IO吞吐量,内存使用率sql

    1.查询表空间使用率

    select a.tablespace_name, total, free,(total-free) as usage from

    (select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a,

    (select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b

    where a.tablespace_name = b.tablespace_name;

    结果展示:

    2.查看总消耗时间最多的前10条SQL语句

    select *

    from (select v.sql_id,

    v.child_number,

    v.sql_text,

    v.elapsed_time,

    v.cpu_time,

    v.disk_reads,

    rank() over(order by v.elapsed_time desc) elapsed_rank

    from v$sql v) a

    where elapsed_rank <= 10;

    3.查看CPU消耗时间最多的前10条SQL语句

    select *

    from (select v.sql_id,

    v.child_number,

    v.sql_text,

    v.elapsed_time,

    v.cpu_time,

    v.disk_reads,

    rank() over(order by v.cpu_time desc) elapsed_rank

    from v$sql v) a

    where elapsed_rank <= 10;

    4.查看消耗磁盘读取最多的前10条SQL语句

    select *

    from (select v.sql_id,

    v.child_number,

    v.sql_text,

    v.elapsed_time,

    v.cpu_time,

    v.disk_reads,

    rank() over(order by v.disk_reads desc) elapsed_rank

    from v$sql v) a

    where elapsed_rank <= 10;

    5. IOps和IO吞吐量 (oracle 11g)

    select sum(decode(name,'physical read IO requests',value,'physical write IO requests',value,0)) as iops,

    sum(decode(name,'physical read bytes',value,'physical write bytes',value,0)) / 1024 / 1024 as mbps from v$sysstat

    where name in ('physical read IO requests','physical write IO requests','physical read bytes','physical read total bytes',

    'physical write bytes','physical write total bytes','physical read total IO requests','physical write total IO requests');

    结果展示:

    参考:https://www.2cto.com/database/201309/241170.html

    6.内存使用情况

    SGA / PGA 使用情况

    -- pctused: 使用率

    select name,total,round(total-free,2) used, round(free,2) free,round((total-free)/total*100,2) pctused from

    (select 'SGA' name,(select sum(value/1024/1024) from v$sga) total,

    (select sum(bytes/1024/1024) from v$sgastat where name='free memory')free from dual)

    union

    select name,total,round(used,2)used,round(total-used,2)free,round(used/total*100,2)pctused from (

    select 'PGA' name,(select value/1024/1024 total from v$pgastat where name='aggregate PGA target parameter')total,

    (select value/1024/1024 used from v$pgastat where name='total PGA allocated')used from dual);

    --内存使用率(待续)

  • 相关阅读:
    python中filter、map、reduce的区别
    Python属性和内建属性
    3分钟学会Python 针对Excel操作
    python重要函数eval
    python中用修饰器进行异常日志记录
    python 生成器中的send、移动平均值、列表表达式相关
    python中如何将字符串连接在一起,多倍的字符串如何输出
    Python将一个已知的utc时间字符串转换为东八区时间
    Python有参函数的使用
    Linux--虚拟环境
  • 原文地址:https://www.cnblogs.com/yaoyangding/p/15739100.html
Copyright © 2011-2022 走看看