Oracle   发布时间:2022-05-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了oracle 11G AWR不自动清理大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

理论上AWR数据应当根据保留时间,自动清理,但是实际上,经常碰到这样的:

col segment_name for a32;
set linesize 500;
set pagesize 500;
with t1 as (
select round(sum(bytes)/1024/1024) MB,segment_name from dba_segments where owner='SYS' 
group by segment_name
order by 1 desc )
select * from t1 where rownum<16;

然后WRH$开头的几个表占十几个G的情况,也就是AWR数据并没有完全被清理掉,检查策略一切正常:

sql> select INSTANCE_NUMBER,min(SAMPLE_TIME),max(SAMPLE_TIME) from 
WRH$_ACTIVE_SESSION_HISTORY group by INSTANCE_NUMBER;  2  

INSTANCE_NUMBER MIN(SAMPLE_TIME)                                                            MAX(SAMPLE_TIME)
---------------  -------------------------            --------------------------------------------------
              1 25-MAY-16 08.14.48.613 PM                                                   28-MAR-18 08.56.02.944 AM

sql>  select snap_interval,retention from dba_hist_wr_control;

SNAP_INTERVAL                                                               RETENTION
------------------------------------ ---------------------------------------------------------------------------
+00000 01:00:00.0                                                           +00008 00:00:00.0

sql>  select min(snap_ID),max(snap_ID) from WRH$_EVENT_HISTOGRAM;

MIN(SNAP_ID) MAX(SNAP_ID)
------------ ------------
           1        16015

MOS查一下BUG号14084247,从 11.2.0.3之后几乎都有这个问题,并且打了14084247 之后,貌似也不能解决,MOS又发一篇文章,手动清理,DOCID387914.1,步骤如下:
1检查分区情况

SELECT owner,segment_name,partition_name,segment_type,bytes/1024/1024/1024 Size_GB
FROM dba_segments
WHERE segment_name='WRH$_ACTIVE_SESSION_HISTORY';

2 修改隐含参数:
alter session set "_swrf_test_action" = 72;
3 再次检查分区情况
4 统计各个WRH表的最大,最小snap_ID

set serveroutput on 
declare 
CURSOR cur_part IS 
SELECT partition_name from dba_tab_partitions 
WHERE table_name = 'WRH$_ACTIVE_SESSION_HISTORY'; 

query1 varchar2(200); 
query2 varchar2(200); 

TYPE partrec IS RECORD (snAPId number,dbID number); 
TYPE partList IS table OF partrec; 

OutList partList; 
begin 
dbms_output.put_line('PARTITION name SNAP_ID DBID'); 
dbms_output.put_line('--------------------------- ------- ----------'); 

for part in cur_part loop 
query1 := 'select min(snap_ID),dbID from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbID'; 
execute immediate query1 bulk collect into OutList; 

if OutList.count > 0 then 
for i in OutList.first..OutList.last loop 
dbms_output.put_line(part.partition_name||' Min '||OutList(i).snAPId||' '||OutList(i).dbID); 
end loop; 
end if; 

query2 := 'select max(snap_ID),dbID from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbID'; 
execute immediate query2 bulk collect into OutList; 

if OutList.count > 0 then 
for i in OutList.first..OutList.last loop 
dbms_output.put_line(part.partition_name||' Max '||OutList(i).snAPId||' '||OutList(i).dbID); 
dbms_output.put_line('---'); 
end loop; 
end if; 

end loop; 
end; 
/

5 删除不需要的数据

6 运行 @?/rdbms/admin/awrinfo.sql再次检查下
7 最后建议重启一下MMON刷新:

alter system set "_swrf_mmon_flush"=false; 
alter system set "_swrf_mmon_flush"=true;

大佬总结

以上是大佬教程为你收集整理的oracle 11G AWR不自动清理全部内容,希望文章能够帮你解决oracle 11G AWR不自动清理所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: