溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

oracle 11G AWR不自動清理

發(fā)布時間:2020-04-02 00:10:42 來源:網(wǎng)絡(luò) 閱讀:3359 作者:snowhill 欄目:關(guān)系型數(shù)據(jù)庫

理論上AWR數(shù)據(jù)應(yīng)當(dāng)根據(jù)保留時間,自動清理,但是實(shí)際上,經(jīng)常碰到這樣的:

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數(shù)據(jù)并沒有完全被清理掉,檢查策略一切正常:

 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

select min(snap_id),max(snap_id) ,dbid from sys.WRH$_EVENT_HISTOGRAM group by dbid;

MOS查一下BUG號14084247,從 11.2.0.3之后幾乎都有這個問題,并且打了14084247 之后,貌似也不能解決,MOS又發(fā)一篇文章,手動清理,DOCID387914.1,步驟如下:
1檢查分區(qū)情況

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 修改隱含參數(shù):
alter session set "_swrf_test_action" = 72;
3 再次檢查分區(qū)情況
4 統(tǒng)計各個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 刪除不需要的數(shù)據(jù)

DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE(
low_snap_id IN NUMBER,
high_snap_id IN NUMBER
dbid IN NUMBER DEFAULT NULL);

6 運(yùn)行 @?/rdbms/admin/awrinfo.sql再次檢查下
7 最后建議重啟一下MMON刷新:

alter system set "_swrf_mmon_flush"=false; 
alter system set "_swrf_mmon_flush"=true; 
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI