Oracle SYSAUX空間問題的解決方案

來源:互聯網
上載者:User

通過修改了AWR收集頻率之後(http://zxf261.blog.51cto.com/701797/762046),發現SYSAUX資料表空間還是佔用嚴重。

下面介紹一下如何清理SYSAUX資料表空間

一.清理SYSAUX下的曆史統計資訊

1.將曆史統計資訊保留時間設為無限

exec dbms_stats.alter_stats_history_retention(-1);

2.truncate較大的TABLE

truncate table sys.WRI$_OPTSTAT_HISTHEAD_HISTORY;

truncate table sys.WRI$_OPTSTAT_HISTGRM_HISTORY;

3.清理曆史統計資訊

exec dbms_stats.purge_stats(sysdate-101);

exec dbms_stats.purge_stats(sysdate-51);

exec dbms_stats.purge_stats(sysdate-5);

4.將曆史統計資訊保留時間設為10天

exec dbms_stats.alter_stats_history_retention(10);

5.將曆史統計資訊相關的表進行MOVE

alter table sys.WRI$_OPTSTAT_HISTHEAD_HISTORY move tablespace sysaux;

alter index sys.I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST rebuild online;

alter index sys.I_WRI$_OPTSTAT_HH_ST rebuild online;

alter table sys.WRI$_OPTSTAT_HISTGRM_HISTORY move tablespace sysaux;

alter index sys.I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST rebuild online;

alter index sys.I_WRI$_OPTSTAT_H_ST rebuild online;

alter table sys.WRI$_OPTSTAT_IND_HISTORY move tablespace sysaux;

alter index sys.I_WRI$_OPTSTAT_IND_OBJ#_ST rebuild online;

alter index sys.I_WRI$_OPTSTAT_IND_ST rebuild online;

alter table sys.WRI$_OPTSTAT_TAB_HISTORY move tablespace sysaux;

更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

alter index sys.I_WRI$_OPTSTAT_TAB_OBJ#_ST rebuild online;

alter index sys.I_WRI$_OPTSTAT_TAB_ST rebuild online;

ALTER TABLE SYS.WRI$_OPTSTAT_OPR MOVE TABLESPACE SYSAUX;

ALTER TABLE SYS.WRI$_OPTSTAT_AUX_HISTORY MOVE TABLESPACE SYSAUX;

ALTER INDEX SYS.I_WRI$_OPTSTAT_AUX_ST REBUILD ONLINE;

ALTER INDEX SYS.I_WRI$_OPTSTAT_OPR_STIME REBUILD ONLINE;

6.對MOVE表的統計資訊進行收集

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRI$_OPTSTAT_HISTHEAD_HISTORY’,cascade => TRUE);

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRI$_OPTSTAT_HISTGRM_HISTORY’,cascade => TRUE);

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRI$_OPTSTAT_IND_HISTORY’,cascade => TRUE);

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRI$_OPTSTAT_TAB_HISTORY’,cascade => TRUE);

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRI$_OPTSTAT_OPR’,cascade => TRUE);

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRI$_OPTSTAT_AUX_HISTORY’,cascade => TRUE);

二.清理SYAUX下的無效ASH資訊

1.檢查是否有無效的ASH資訊

select count(*)

from sys.wrh$_active_session_history a

where not exists (select 1

from sys.wrm$_snapshot b

where a.snap_id = b.snap_id

and a.dbid = b.dbid

and a.instance_number = b.instance_number);

2.清理無效的ASH資訊

delete

from sys.wrh$_active_session_history a

where not exists (select 1

from sys.wrm$_snapshot b

where a.snap_id = b.snap_id

and a.dbid = b.dbid

and a.instance_number = b.instance_number);

3.對ASH表清理後的磁碟重組

alter table sys.wrh$_active_session_history enable row movement;

alter table sys.wrh$_active_session_history shrink space cascade;

alter table sys.wrh$_active_session_history disable row movement;

4.收集磁碟重組後表的統計資訊

EXEC dbms_stats.gather_table_stats(ownname => ‘SYS’,tabname => ‘WRH$_ACTIVE_SESSION_HISTORY’,cascade => TRUE);

3.檢查資料表空間可收縮的的位置

select a.FILE#,

a.NAME,

a.BYTES / 1024 / 1024 mb,

ceil(HWM * A.BLOCK_SIZE) / 1024 / 1024 RESIZETO,

‘ALTER DATABASE DATAFILE ”’ || A.NAME || ”’ RESIZE ‘ ||

(trunc(CEIL(HWM * A.BLOCK_SIZE) / 1024 / 1024)+20) || ‘M;’ RESIZECMD

from v$datafile a,

(SELECT C.file_id, MAX(C.block_id + C.blocks – 1) HWM

FROM DBA_EXTENTS C

GROUP BY FILE_ID) B

WHERE A.FILE# = B.FILE_ID

AND a.tablespace=’SYSAUX’

ORDER BY 5;

三.SYSAUX清理後的檢查

1.清理後的無效INDEX檢查

select * from dba_indexes where status<>‘VALID’ AND STATUS<>‘N/A’;

SELECT * FROM DBA_IND_PARTITIONS WHERE STATUS<>‘USABLE’ AND STATUS<>‘N/A’;

SELECT * FROM DBA_IND_SUBPARTITIONS WHERE STATUS<>‘USABLE’;

上面語句應均無資料返回,如有則對這些INDEX進行重建

2.清理後的INDEX並行度檢查

select * from dba_indexes where degree not in (’1′,’0′,’DEFAULT’);

本文出自 “richard的筆記-積微成著” 部落格,請務必保留此出處http://zxf261.blog.51cto.com/701797/776496

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.