Oracle 审计表AUD$迁移表空间及创建清理job

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle 审计表AUD$迁移表空间及创建清理job相关的知识,希望对你有一定的参考价值。

Oracle 10.2.0.5以上的版本可以使用DBMS_AUDIT_MGMT清理audit
1、查看audit是否已经打开
SQL> show parameter audit_trail

NAME TYPE VALUE


audit_trail string DB, EXTENDED

2、创建audit tablespace
create tablespace ts_audit datafile ‘/oradata/ora10g/audit01.dbf‘ size 4000M autoextend off;
3、设置清理频率

BEGIN
DBMS_AUDIT_MGMT.INIT_CLEANUP(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
default_cleanup_interval => 12 / hours /);
END;
/

4、将AUD$从SYSTEM表空间迁移到新的表空间
BEGIN
DBMS_AUDIT_MGMT.SET_AUDIT_TRAIL_LOCATION(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
audit_trail_location_value => ‘TS_AUDIT‘);
END;
/
5、设置last archive timestamp,保留30天
BEGIN
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
last_archive_time => SYSDATE-30);
END;
/

6、设置last archive timestamp job,保留30天
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => SET_AUDIT_ARCHIVE_TIMESTAMP‘,
job_type => ‘PLSQL_BLOCK‘,
job_action => ‘BEGIN DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,LAST_ARCHIVE_TIME => SYSDATE-30); END;‘,
start_date => sysdate,
repeat_interval => ‘FREQ=HOURLY;INTERVAL=24‘,
enabled => TRUE,
comments => ‘set last archive timestamp‘
);
END;
/
7、定义自动清理job
BEGIN
DBMS_AUDIT_MGMT.CREATE_PURGE_JOB(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
audit_trail_purge_interval => 24 / hours /,
audit_trail_purge_name => ‘AUDIT_CLEANUP_JOB‘,
use_last_arch_timestamp => TRUE);
END;
/
8、查看清理job执行情况,delete_count应该不为0
SQL> select * from dba_audit_mgmt_clean_events;

AUDIT_TRAIL RAC_INSTANCE CLEANUP_TIME DELETE_COUNT WAS


STANDARD AUDIT TRAIL 0 16-MAY-19 07.18.59.937786 AM +00:00 460 NO

以上是关于Oracle 审计表AUD$迁移表空间及创建清理job的主要内容,如果未能解决你的问题,请参考以下文章

SQLPLUS使用及Oracle表空间设定自动扩展

[Oracle]Audit--清理Audit数据

Oracle审计--AUD$占用空间较大处理方案

Oracle审计--AUD$占用空间较大处理方案

Oracle审计表AUD$处理方法

Audit--清理Audit数据