SYSTEM表空間使用率達到了85%,查出是用來記錄審計記錄的aud$表佔用了很大的空間。sql
備份後truncate掉AUD$,問題臨時解決。記得oracle11.2能夠把aud$遷移到普通的表空oracle
間。因而試了一把,果真ok。spa
1.檢查SYSTEM表空間使用狀況
.net
- SQL*Plus: Release 11.2.0.3.0 Production on Mon Mar 26 11:21:18 2012
- Copyright (c) 1982, 2011, Oracle. All rights reserved.
- Connected to:
- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
- With the Partitioning, Data Mining and Real Application Testing options
-
-
- SQL> select
- 2 b.tablespace_name "表空間",
- 3 b.bytes/1024/1024 "大小M",
- 4 (b.bytes-sum(nvl(a.bytes,0)))/1024/1024 "已使用M",
- 5 substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) "利用率"
- 6 from dba_free_space a,dba_data_files b
- 7 where a.file_id=b.file_id
- 8 and b.tablespace_name='SYSTEM'
- 9 group by b.tablespace_name,b.file_name,b.bytes
- 10 order by b.tablespace_name;
-
- 表空間 大小M 已使用M 利用率
- ------------------- ---------- ----------- ----------
- SYSTEM 4096 3485.9375 85.10
2.從dba_segments中找出佔用SYSTEM表空間中排名前10位的大對象。
對象
- SQL> col segment_name for a15;
- SQL> SELECT *
- 2 FROM (SELECT SEGMENT_NAME, SUM(BYTES) / 1024 / 1024 MB
- 3 FROM DBA_SEGMENTS
- 4 WHERE TABLESPACE_NAME = 'SYSTEM'
- 5 GROUP BY SEGMENT_NAME
- 6 ORDER BY 2 DESC)
- 7 WHERE ROWNUM < 10;
-
- 查出aud$佔用的很大的空間。
3.準備truncate aud$表
blog
- SQL> show parameter AUDIT_TRAIL
-
- NAME TYPE VALUE
- --------------- ----------- ---------
- audit_trail string DB
-
- <span style="color: rgb(255, 0, 0);">-- truncate aud$ 表須要有相關的權限。</span>
- SQL> truncate table aud$;
- Table truncated
4.truncate後檢查system表空間使用狀況,發現使用率由85%下降到29.44%
索引
- SQL> ANALYZE TABLE aud$ COMPUTE STATISTICS;
- Table analyzed.
-
- SQL> select
- 2 b.tablespace_name "表空間",
- 3 b.bytes/1024/1024 "大小M",
- 4 (b.bytes-sum(nvl(a.bytes,0)))/1024/1024 "已使用M",
- 5 substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) "利用率"
- 6 from dba_free_space a,dba_data_files b
- 7 where a.file_id=b.file_id
- 8 and b.tablespace_name='SYSTEM'
- 9 group by b.tablespace_name,b.file_name,b.bytes
- 10 order by b.tablespace_name;
-
- 表空間 大小M 已使用M 利用率
- ---------------- ---------- ---------- ----------
- SYSTEM 4096 1206 29.44
5.爲了不system表空間爆滿對數據的影響,把aud$從system表空間遷移到普通表空間AUD_FILE。
get
- SQL> BEGIN
- 2 DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION(
- 3 AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
- 4 AUDIT_TRAIL_LOCATION_VALUE => 'AUD_FILE');
- 5 END;
- 6 /
-
- SQL> col owner for a5;
- SQL> SELECT OWNER, TABLE_NAME, TABLESPACE_NAME
- 2 FROM DBA_TABLES
- 3 WHERE TABLE_NAME = 'AUD$'
- 4 AND OWNER = 'SYS';
-
- OWNER TABLE_NAME TABLESPACE_NAME
- ----- ------------------------------ ------------------------------
- SYS AUD$ TD_FILB
本文轉自lwei_998的專欄
http://blog.csdn.net/lwei_998/article/details/7394638string
如下步驟能夠參考:it
1.查找AUD$表大小
select OWNER,SEGMENT_NAME,SEGMENT_TYPE,TABLESPACE_NAME,BYTES/1024/1024 MB from dba_segments where SEGMENT_TYPE='TABLE' and SEGMENT_NAME='AUD$';
2.查找AUD$是否有索引
select di.table_name, di.index_name from dba_indexes di where di.table_name='AUD$';
3. 關閉審計
SQL> noaudit connect;
4.統計AUD$表記錄(多統計幾回,確認審計是否關閉)
SQL> select count(*) from AUD$ ;
5. 備份AUD$表
exp "'/ as sysdba'" tables=SYS.AUD$ file=/opt/oracle/aud.dmp log=/opt/oracle/aud.log buffer=1024000
6. 清理AUD$
truncate table AUD$;
7.檢查AUD$表
select count(*) from AUD$ ;
8. 開啓審計
audit connect;
9.檢查AUD$表是否正常.
select count(*) from AUD$ ;