分類: Oracle
問題描述:
對數據庫做檢查,發現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 DESC) WHERE 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此表,清空數據。