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
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341