Linux Oracle性能监控技巧
一 工具与平台选型
二 关键监控指标与阈值参考
sum(pinhits)/sum(pins)*100,低于95%考虑绑定变量、增大SHARED_POOL_SIZE或SQL解析优化。v$sysstat中disk/(memory+rows)比例,过高需调整PGA_AGGREGATE_TARGET或workarea_size_policy。select count(*) from v$session;,结合v$session查看ACTIVE/INACTIVE与来源程序,识别异常连接或连接风暴。三 高频SQL与等待事件定位
select disk_reads,sql_text from v$sql order by disk_reads desc fetch first 5 rows only;select buffer_gets,sql_text from v$sql order by buffer_gets desc fetch first 5 rows only;select sql_text,executions from v$sql order by executions desc fetch first 5 rows only;select se.SID, ses.username, n.name, se.VALUE from v$statname n, v$sesstat se, v$session ses where n.statistic#=se.statistic# and se.sid=ses.sid and ses.username is not null and n.name in ('CPU used by this session','db block gets','consistent gets','physical reads','sorts (disk)') order by sid, n.statistic#;四 表空间与存储健康
select f.tablespace_name, a.total, f.free, round((f.free/a.total)*100) "% Free" from (select tablespace_name, sum(bytes/1048576) total from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes/1048576) free from dba_free_space group by tablespace_name) f where a.tablespace_name=f.tablespace_name(+) order by "% Free";select name,status from v$datafile;select group#,status,type,member from v$logfile;select Segment_Name,Segment_Type,Tablespace_Name,(Extents/Max_extents)*100 Percent from dba_segments where Max_Extents!=0 and (Extents/Max_extents)*100>=95;select segment_name,status from dba_rollback_segs;五 自动化监控与告警实践