您好,登录后才能下订单哦!
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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。