============= oracle数据库archivelog暴增分析 ====================
前言
归档量突然增长到981G/天,导致归档目录使用率告警
归档日志量异常暴增会导致磁盘空间爆满,数据库异常
1、归档日志量统计
SELECT TRUNC(FIRST_TIME) "TIME",
SUM(BLOCK_SIZE * BLOCKS) / 1024 / 1024 / 1024 "SIZE(GB)"
FROM V$ARCHIVED_LOG
GROUP BY TRUNC(FIRST_TIME) order by TRUNC(FIRST_TIME);
部分输出:
TIME SIZE(GB)
--------- ----------
09-JUN-21 63.345335
10-JUN-21 50.041029
11-JUN-21 43.3773184
12-JUN-21 41.8273354
13-JUN-21 36.834712
14-JUN-21 38.4342957
15-JUN-21 42.0742655
16-JUN-21 40.6740589
17-JUN-21 44.1439724
18-JUN-21 53.9158897
19-JUN-21 981.466756
2、日志生成量最大的对象 (按小时统计)
select * from (
SELECT to_char(begin_interval_time, 'YYYY_MM_DD HH24:MI') snap_time,
dhsso.object_name,
SUM(db_block_changes_delta)
FROM dba_hist_seg_stat dhss,
dba_hist_seg_stat_obj dhsso,
dba_hist_snapshot dhs
WHERE dhs.snap_id = dhss.snap_id
AND dhs.instance_number = dhss.instance_number
AND dhss.obj# = dhsso.obj#
AND dhss.dataobj# = dhsso.dataobj#
AND begin_interval_time> sysdate - 120/1440
GROUP BY to_char(begin_interval_time, 'YYYY_MM_DD HH24:MI'),
dhsso.object_name
order by 3 desc)
where rownum<=5;
SNAP_TIME OBJECT_NAME SUM(DB_BLOCK_CHANGES_DELTA)
---------------- ------------------------------ ---------------------------
2021_06_19 09:00 OMS_GOODSQTY_UPLOAD_GDST_IDX 1506104016
2021_06_19 09:00 OMS_GOODSQTY_UPLOAD_IDX 175114000
2021_06_19 09:00 OMS_GOODSQTY_UPLOAD 148411280
2021_06_19 09:00 BMS_ST_IO_DTLTMP_INOUTID_IDX 201616
2021_06_19 09:00 GRESA_SA_DTL_RSAID_IDX 138160
tips:也可以查awr的Segments by Physical Writes的数据,数据相对应
3、相关sql查询
SELECT to_char(begin_interval_time, 'YYYY_MM_DD HH24:MI'),
dbms_lob.substr(sql_text, 4000, 1),
dhss.instance_number,
dhss.sql_id,
executions_delta,
rows_processed_delta
FROM dba_hist_sqlstat dhss, dba_hist_snapshot dhs, dba_hist_sqltext dhst
WHERE UPPER(dhst.sql_text) LIKE '%OMS_GOODSQTY_UPLOAD%'
AND dhss.snap_id = dhs.snap_id
AND dhss.instance_Number = dhs.instance_number
AND dhss.sql_id = dhst.sql_id;
当前sql查询:
select a.username,a.sid,b.sql_text from v$session a,v$sql b
where a.sql_id=b.sql_id and b.sql_text like '%OMS_GOODSQTY_UPLOAD%';
4、查找关联SQL的session和module和machine
select username,program,module,machine from dba_hist_active_sess_history WHERE sql_id = 'cs3758yhdjxav';
处理方式及总结
排查出归档生成量最大的对象相关信息(用户名、对象名、程序名、模块、机器)反馈应用测排查相关业务,
紧急处理方式先停止相关异常业务,再进行业务侧优化。
新的业务上线前需要经过严格的测试,新业务上线前需要提前沟通,实时观察数据库情况,以便出现问题及时发现和处理;
数据库维护期间要保持高度警惕,认真观察,冷静分析。
<end>