http://blog.csdn.net/lwei_998/article/details/7394638
SYSTEM表空间使用率达到了85%,查出是用来记录审计记录的aud$表占用了很大的空间。
备份后truncate掉AUD$,问题临时解决。记得oracle11.2可以把aud$迁移到普通的表空
间。于是试了一把,果然ok。
1.检查SYSTEM表空间使用情况
.检查SYSTEM表空间使用情况
[sql] view plaincopy
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] view plaincopy
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$表
[sql] view plaincopy
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] view plaincopy
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。
[sql] view plaincopy
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