system表空間爆滿解決方法

kunlunzhiying發表於2017-05-22
問題描述:
對資料庫做檢查,發現system表空間持續佔滿99%。使用如下語句檢視:
SQL> select b.tablespace_name "表空間",b.bytes/1024/1024 "大小M",(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 "已使用M",substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) "利用率" from dba_free_space a,dba_data_files b where a.file_id=b.file_id and b.tablespace_name='SYSTEM' group by b.tablespace_name,b.file_name,b.bytes order by b.tablespace_name;

表空間            大小M        已使用M     利用率
------------- ----------     ----------     ----------
SYSTEM             6770          6505         96.08%

從dba_segments中找出佔用SYSTEM表空間中排名前10位的大物件:
SQL> col segment_name for a15;
SQL> SELECT * FROM (SELECT SEGMENT_NAME, SUM(BYTES) / 1024 / 1024 MB FROM DBA_SEGMENTS WHERE TABLESPACE_NAME = 'SYSTEM' GROUP BY SEGMENT_NAME ORDER BY 2 DESCWHERE ROWNUM < 10;

SEGMENT_NAME     MB
--------------------    ----------
AUD$                         6016
IDL_UB1$                    280
SOURCE$                     80
IDL_UB2$                     33
C_TOID_VERSION#      24
C_OBJ#_INTCOL#        18
I_SOURCE1                   16
ARGUMENT$               13
C_OBJ#                         13
JAVA$MC$                   12
發現是AUD$審計表佔用資源量大。為了避免對整體效能造成影響,決定把AUD$遷移到其他表空間
解決步驟:
1,新建aud_space表空間和aud_index索引表空間
2,執行遷移命令,將AUD$表相關移到審計表空間中:
SQL> alter table aud$ move tablespace aud_space;

SQL> alter table audit$ move tablespace aud_space;

SQL> alter index i_audit rebuild online tablespace aud_index;

SQL> alter table audit_actions move tablespace aud_space;


SQL> alter index i_audit_actions rebuild online tablespace aud_index;

3,再此檢視SYSTEM表空間使用狀態:
SQL> select b.tablespace_name "表空間",b.bytes/1024/1024 "大小M",(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 "已使用M",substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) "利用率" from dba_free_space a,dba_data_files b where a.file_id=b.file_id and b.tablespace_name='SYSTEM' group by b.tablespace_name,b.file_name,b.bytes order by b.tablespace_name;
表空間            大小M        已使用M     利用率
------------- ----------     ----------     ----------
SYSTEM             6770       792.3125     11.70
可見SYSTEM表空間已經降下來了。
4,為了安全起見,AUD$表資料目前3千多萬,資料量大,後期考慮truncate此表,清空資料。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28211342/viewspace-2139678/,如需轉載,請註明出處,否則將追究法律責任。

相關文章