AUDIT_TRAIL設定及審計日誌清理

renjixinchina發表於2014-05-30

  

1.      初始化引數AUDIT_TRAIL用於控制資料庫審計,取值說明:

  • none 禁用資料庫審計
  • os 啟用資料庫審計,並將資料庫審計記錄定向到作業系統審計記錄
  • db 啟用資料庫審計,並將資料庫所有審計記錄定向到資料庫的SYS.AUD$
  • db,extended 啟用資料庫審計,並將資料庫所有審計記錄定向到資料庫的SYS.AUD$表。另外,填充SYS.AUD$表的SQLBIND 列和SQLTEXT CLOB 列。
  • xml 啟用資料庫審計,並將所有記錄寫到XML格式的作業系統檔案中。
  • xml,extended 啟用資料庫審計,輸出審計記錄的所有列,包括SqlTextSqlBind的值。

Oracle公司還推薦使用基於OS檔案的審計日誌記錄方式(OS audit trail files)

2.      不同設定下audit  trail的位置如下:

 

3.      db 選項下的aud$表的遷移

在日常的資料庫維護中,經常出現因為資料庫登入審計的功能啟動,導致system表空間被用滿.從而出現異常,一般建議把aud$相關物件遷移到其他表空間,從而避免system被用完的風險.

10g及以前遷移方法

alter table AUDIT$ move tablespace users;

alter table AUDIT_ACTIONS move tablespace users;

alter table AUD$ move tablespace users;

alter table AUD$ move lob(SQLBIND) store as SYS_IL0000000384C00041$$ (tablespace users);

alter table AUD$ move lob(SQLTEXT) store as SYS_IL0000000384C00041$$ (tablespace users);

alter index I_AUDIT rebuild online tablespace users;

alter index I_AUDIT_ACTIONS rebuild online tablespace users;

11g以後

可以使用DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION進行遷移

conn / as sysdba

 

BEGIN

DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION(audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_DB_STD,

audit_trail_location_value => 'USERS');

END;

/

4.      審計日誌清理

10g及以前通過手工清理的方式或自定義作業來定期清理

DELETE FROM SYS.AUD$;

DELETE FROM SYS.AUD$

     WHERE obj$name='EMP';

OSXML選項下進行手動刪除審計檔案

 

 

11g 新特性

通過DBMS_AUDIT_MGMT包下的子過程進行手動或定期清理,功能如下

Subprogram

Description

CLEAN_AUDIT_TRAIL Procedure

Deletes audit trail records/files that have been archived

CLEAR_LAST_ARCHIVE_TIMESTAMP Procedure

Clears the timestamp set by the SET_LAST_ARCHIVE_TIMESTAMP Procedure

CREATE_PURGE_JOB Procedure

Creates a purge job for periodically deleting the audit trail records/files

DEINIT_CLEANUP Procedure

Undoes the setup and initialization performed by the INIT_CLEANUP Procedure

DROP_PURGE_JOB Procedure

Drops the purge job created using the CREATE_PURGE_JOB Procedure

INIT_CLEANUP Procedure

Sets up the audit management infrastructure and sets a default cleanup interval for audit trail records/files

IS_CLEANUP_INITIALIZED Function

Checks to see if the INIT_CLEANUP Procedure has been run for an audit trail type

SET_LAST_ARCHIVE_TIMESTAMP Procedure

Sets a timestamp indicating when the audit records/files were last archived

SET_PURGE_JOB_INTERVAL Procedure

Sets the interval at which the CLEAN_AUDIT_TRAIL Procedure is called for the purge job that you specify

SET_PURGE_JOB_STATUS Procedure

Enables or disables the purge job that you specify

 

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

相關文章