ORACLE SYSTEM表空間異常與審計的功能

wzq609發表於2014-04-02

背景說明:

      剛接手一個資料庫的時候,發現該資料庫的system表空間居然有21G,按照之前的資料庫管理經驗,目前管理過2TB的資料,SYSTEM表空間也沒有超過2GB,所以出於謹慎的態度,對當前system的表空間的內容進行了相應的瞭解。

 

問題排查:

     透過執行以下語句可以檢視每個表空間所存放資料段的情況,指令碼如下:

select A.SEGMENT_NAME,SUM(A.BYTES)/1024/1024/1024 GB,A.SEGMENT_TYPE   

from dba_extents a,v$datafile b,v$tablespace C 

where b.TS#=C.TS# AND C.NAME='SYSTEM' AND A.FILE_ID=B.FILE#

GROUP BY A.SEGMENT_NAME,A.SEGMENT_TYPE ORDER BY GB DESC

 

 

終於找到真相了,表AUD$佔用了20.4G的空間;

 

深入瞭解:關於aud$表

1、AUD$的介紹

When standard auditing is enabled (that is, you set AUDIT_TRAIL to DB or DB,EXTENDED), Oracle Database audits all data manipulation language (DML) operations, such as INSERTUPDATEMERGE, and DELETE on the SYS.AUD$ and SYS.FGA_LOG$ tables by non-SYS users. (It performs this audit even if you have not set audit options for the AUD$ and FGA_LOGS$ tables.) Typically, non-SYS users do not have access to these tables, except if they have been explicitly granted access. If a non-SYS user tampers with the data in the SYS.FGA_LOG$ and SYS.AUD$ tables, then Oracle Database writes an audit record for each action.Oracle Database audits SYS user's DELETE, INSERT, UPDATE, and MERGE operations on the SYS.FGA_LOG$ and SYS.AUD$ tables if you have set the AUDIT_SYS_OPERATIONS initialization parameter to TRUE. In this case the audit records of all SYS operations are written to whatever directory the AUDIT_FILE_DEST initialization parameter points to. If AUDIT_FILE_DEST is not set, then it writes the records to an operating system-dependent location.

AUD$是資料庫開啟審計後,記錄所有相關操作的表,所以可以確定資料庫開啟了審計的功能;

2、檢視資料庫的審計,show parameter aud;

發現資料庫啟用了DB級別的審計功能,相關審計級別如下:

None:是預設值,不做審計;

DB:將audit trail 記錄在資料庫的審計相關表中,如aud$,審計的結果只有連線資訊;

DB,Extended:這樣審計結果裡面除了連線資訊還包含了當時執行的具體語句;

OS:將audit trail 記錄在作業系統檔案中,檔名由audit_file_dest引數指定;

XML:10g裡新增的。

備註:ORACLE11G中審計是預設開啟的,而且是對DB進行審計;

 

 解決方法:

1、關閉資料庫的審計功能,一般都不建議在資料庫層面開啟審計功能,除非有要求;

關閉指令碼:alter system set audit_trail=none scope=spfile;  該引數為靜態引數,需要重啟;

2、完成後可以對整個表空間進行收縮,具體的操作方法,請檢視另外一個文件.......................................

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

相關文章