【AWR】該怎樣清理SYSAUX表空間相關資料(第二季)
在上一篇文章中檢視錶空間資訊是,還剩餘1662M,今天我再次檢視
SQL> set pagesize 9999 SQL> set linesize 132 SQL> col TABLESPACE_NAME for a25 SQL> select 2 f.tablespace_name, 3 a.total, 4 f.free, 5 round((f.free/a.total)*100) "% Free" 6 from 7 (select tablespace_name, sum(bytes/(1024*1024)) total from dba_data_files group by tablespace_name) a, 8 (select tablespace_name, round(sum(bytes/(1024*1024))) free from dba_free_space group by tablespace_name) f 9 WHERE a.tablespace_name = f.tablespace_name(+) 10 order by "% Free" 11 / TABLESPACE_NAME TOTAL FREE % Free ------------------------- ---------- ---------- ---------- SYSAUX 81920 1195 1 …………………………………………………………………….後邊省略 |
檢視快照資訊,發現快照最小值為31146
SQL> select snap_id, 2 to_char(begin_interval_time, 'YYYY-MM-DD'), 3 to_char(end_interval_time, 'YYYY-MM-DD') 4 from dba_hist_snapshot 5 order by snap_id;
SNAP_ID TO_CHAR(BE TO_CHAR(EN ---------- ---------- ---------- 31146 2013-12-21 2013-12-21 31146 2013-12-21 2013-12-21 31147 2013-12-21 2013-12-21 31147 2013-12-21 2013-12-21 31148 2013-12-21 2013-12-21 31148 2013-12-21 2013-12-21 31149 2013-12-21 2013-12-21 ………………….. 31228 2013-12-24 2013-12-24 31229 2013-12-24 2013-12-24 31229 2013-12-24 2013-12-24
162 rows selected. |
再檢視wrh$_active_session_history資料資訊,最小值也是31146,也就是說,之前快照資訊已經刪除,但空間沒釋放
SQL> select * from (select distinct SNAP_ID,DBID from sys.wrh$_active_session_history order by SNAP_ID) where rownum<=10;
SNAP_ID DBID ---------- ---------- 31146 2065804525 31147 2065804525 31148 2065804525 31149 2065804525 31150 2065804525 31151 2065804525 31152 2065804525 31153 2065804525 31154 2065804525 31155 2065804525 |
透過以下語句檢視,發現下面有兩個索引佔用空間也比較大
SQL> select * from (select segment_name,PARTITION_NAME,segment_type,bytes/1024/1024 from dba_segments where tablespace_name='SYSAUX' order by 4 desc) where rownum<=10; SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE BYTES/1024/1024 ------------------------------ ---------------------------- --------------- --------------- WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_2065804525_25627 TABLE PARTITION 23150 I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST INDEX 16125 I_WRI$_OPTSTAT_H_ST INDEX 12002 WRI$_OPTSTAT_HISTGRM_HISTORY TABLE 10008 WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_2065804525_25627 INDEX PARTITION 3030 WRI$_OPTSTAT_HISTHEAD_HISTORY TABLE 2135 WRH$_SYSMETRIC_HISTORY TABLE 1732 I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST INDEX 1685 WRH$_SYSMETRIC_HISTORY_INDEX INDEX 1671 WRH$_EVENT_HISTOGRAM_PK WRH$_EVENT__2065804525_25594 INDEX PARTITION 1291
10 rows selected. |
檢視索引資訊
SQL> select owner,index_name,table_owner,table_name,table_type from dba_indexes where index_name='I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST';
OWNER INDEX_NAME TABLE_OWNER TABLE_NAME TABLE_TYPE ---------- ------------------------------ ------------ ------------------------------ ----------- SYS I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST SYS WRI$_OPTSTAT_HISTGRM_HISTORY TABLE |
對該索引進行空間收縮操作
SQL> alter index I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST shrink space;
Index altered. ---------此命令執行時常2個小時,由於shrink是拆東牆補西牆,不會額外佔用其他可用空間,俺也就耐心等候了 |
待命令執行完成後,檢查表空間資訊
SQL> set pagesize 9999 SQL> set linesize 132 SQL> col TABLESPACE_NAME for a25 SQL> select 2 f.tablespace_name, 3 a.total, 4 f.free, 5 round((f.free/a.total)*100) "% Free" 6 from 7 (select tablespace_name, sum(bytes/(1024*1024)) total from dba_data_files group by tablespace_name) a, 8 (select tablespace_name, round(sum(bytes/(1024*1024))) free from dba_free_space group by tablespace_name) f 9 WHERE a.tablespace_name = f.tablespace_name(+) 10 order by "% Free" 11 /
TABLESPACE_NAME TOTAL FREE % Free ------------------------- ---------- ---------- ---------- UNDOTBS1 184320 9663 5 SYSAUX 81920 7223 9 ……………………. 哇,終於不是第一個了 |
再次檢視SYSAUX表空間空間詳細使用狀況,發現該索引騰出6G左右的空間來,繼續,使用同樣命令將索引I_WRI$_OPTSTAT_H_ST空間收縮一下
SQL> select * from (select segment_name,PARTITION_NAME,segment_type,bytes/1024/1024 from dba_segments where tablespace_name='SYSAUX' order by 4 desc) where rownum<=10; SEGMENT_NAME PARTITION_NAME SEGMENT_TYPE BYTES/1024/1024 ------------------------------ ---------------------------- --------------- --------------- WRH$_ACTIVE_SESSION_HISTORY WRH$_ACTIVE_2065804525_25627 TABLE PARTITION 23150 I_WRI$_OPTSTAT_H_ST INDEX 12002 I_WRI$_OPTSTAT_H_OBJ#_ICOL#_ST INDEX 10041.5625 WRI$_OPTSTAT_HISTGRM_HISTORY TABLE 10008 WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_2065804525_25627 INDEX PARTITION 3030 WRI$_OPTSTAT_HISTHEAD_HISTORY TABLE 2135 WRH$_SYSMETRIC_HISTORY TABLE 1732 I_WRI$_OPTSTAT_HH_OBJ_ICOL_ST INDEX 1685 WRH$_SYSMETRIC_HISTORY_INDEX INDEX 1671 WRH$_EVENT_HISTOGRAM_PK WRH$_EVENT__2065804525_25594 INDEX PARTITION 1291
10 rows selected. |
命令執行完成後,表空間使用資訊如下:
SQL> set pagesize 9999 SQL> set linesize 132 SQL> col TABLESPACE_NAME for a25 SQL> select 2 f.tablespace_name, 3 a.total, 4 f.free, 5 round((f.free/a.total)*100) "% Free" 6 from 7 (select tablespace_name, sum(bytes/(1024*1024)) total from dba_data_files group by tablespace_name) a, 8 (select tablespace_name, round(sum(bytes/(1024*1024))) free from dba_free_space group by tablespace_name) f 9 WHERE a.tablespace_name = f.tablespace_name(+) 10 order by "% Free" 11 /
TABLESPACE_NAME TOTAL FREE % Free ------------------------- ---------- ---------- ---------- UNDOTBS1 184320 223 0 SYSAUX 81920 11786 14 …………………………….. |
暫時就放心了,至少最近幾天SYSAUX空間不會滿,現在WRH$_ACTIVE_SESSION_HISTORY分割槽狀況還是不理想,正在跟蹤,目前資料快照保留策略為3天,等兩天後,將分割槽表WRH$_ACTIVE_2065804525_25627及其索引drop掉,空間就可以騰出很客觀的一部分了,更好的整理其他索引、表的資料。還是沒搞明白它是怎麼分割槽的,每天都去看,跟它死磕。
附:可透過以下命令檢視WRH$_ACTIVE_SESSION_HISTORY每個分割槽的最大最小快照號,方便清理資料:
檢視分割槽 select table_name,partition_name from dba_tab_partitions where table_name = 'WRH$_ACTIVE_SESSION_HISTORY'; alter session set "_swrf_test_action" = 72; ------------------------------------------------------------------------------ SQL> set serveroutput on declare CURSOR cur_part IS SELECT partition_name from dba_tab_partitions SQL> 2 3 4 WHERE table_name = 'WRH$_ACTIVE_SESSION_HISTORY'; 5 query1 varchar2(200); 6 query2 varchar2(200); 7 TYPE partrec IS RECORD (snapid number, dbid number); 8 TYPE partlist IS TABLE OF partrec; 9 Outlist partlist; 10 begin 11 dbms_output.put_line('PARTITION NAME SNAP_ID DBID'); 12 dbms_output.put_line('--------------------------- ------- ----------'); 13 for part in cur_part loop 14 query1 := 'select min(snap_id), dbid from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbid'; 15 execute immediate query1 bulk collect into OutList; 16 if OutList.count > 0 then 17 for i in OutList.first..OutList.last loop 18 dbms_output.put_line(part.partition_name||' Min '||OutList(i).snapid||' '||OutList(i).dbid); 19 end loop; 20 end if; 21 query2 := 'select max(snap_id), dbid from sys.WRH$_ACTIVE_SESSION_HISTORY partition ('||part.partition_name||') group by dbid'; 22 execute immediate query2 bulk collect into OutList; 23 if OutList.count > 0 then 24 for i in OutList.first..OutList.last loop 25 dbms_output.put_line(part.partition_name||' Max '||OutList(i).snapid||' '||OutList(i).dbid); 26 dbms_output.put_line('---'); 27 end loop; 28 end if; 29 end loop; 30 end; 31 / PARTITION NAME SNAP_ID DBID --------------------------- ------- ---------- WRH$_ACTIVE_2065804525_25627 Min 31146 2065804525 WRH$_ACTIVE_2065804525_25627 Max 31204 2065804525 --- WRH$_ACTIVE_2065804525_31206 Min 31206 2065804525 WRH$_ACTIVE_2065804525_31206 Max 31233 2065804525 ---
PL/SQL procedure successfully completed. |
清除過期快照
exec dbms_workload_repository.drop_snapshot_range(low_snap_id=>26501,high_snap_id=>26600,dbid=>2065804525) |
繼續ing
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29487349/viewspace-1082832/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【AWR】該怎樣清理SYSAUX表空間相關資料UX
- Oracle清理SYSAUX表空間OracleUX
- 【AWR】清理SYSAUX表空間資料(第三季非暴力不合作)UX
- AWR佔用sysaux表空間太大UX
- SYSAUX表空間清理之SM/OPTSTATUX
- 2.5.4.1 關於SYSAUX表空間UX
- AWR資料導致SYSAUX表空間一直增長的問題UX
- AWR不自動刪除導致SYSAUX表空間滿UX
- 32、SYSAUX表空間UX
- ORACLE的SYSAUX 表空間OracleUX
- Oracle10g以上sysaux表空間的維護和清理OracleUX
- 認識 SYSAUX 表空間(zt)UX
- 2.5.4 為 SYSAUX 表空間指定資料檔案屬性UX
- SYSAUX 表空間歷史統計資料過大purgeUX
- 怎樣移動Oracle資料庫的表空間Oracle資料庫
- Sybase資料庫空間相關資料庫
- OGG相關的CPATURE導致SYSAUX表空間異常暴增處理UX
- 表空間相關查詢
- Oracle表空間相關操作Oracle
- oracle之 SYSAUX表空間維護OracleUX
- SYSAUX表空間管理及恢復UX
- SYSAUX表空間佔用過大情況下的處理(AWR資訊過多)UX
- 清理oracle資料庫空間Oracle資料庫
- oracle臨時表空間相關Oracle
- 【原創】表空間相關操作
- 4.2.1.7 規劃 SYSTEM 和 SYSAUX 表空間UX
- sysaux 表空間爆滿處理方法UX
- sysaux 表空間不足問題處理UX
- 修復受損的SYSAUX表空間UX
- mac硬碟空間怎麼清理?這樣也能清理出上10G的磁碟空間Mac硬碟
- SYSAUX表空間滿對資料庫的影響以及解決措施UX資料庫
- MySQL 磁碟空間滿導致表空間相關資料檔案損壞故障處理MySql
- 10G 新特性系列: SYSAUX 表空間UX
- Oracle 表空間查詢相關sqlOracleSQL
- 從system/sysaux空間轉移TABLE&Index到其它表空間UXIndex
- 將ORACLE資料庫審計相關的表移動到其他表空間Oracle資料庫
- oracle sysaux表空間滿了處理辦法OracleUX
- Oracle - 表空間相關常用操作語句Oracle