Oracle在运行期间,会产生大量的日志文件,消耗 OS 空间,需要对这些日志文件做定期清理。

监听日志

包括本地监控和SCAN监听

可以通过 lsnrctl status 来查看日志路径,手动删除已经归档的日志,目前无法在 Oracle 层面配置自动删除。

audit 日志

清除 unified audit trail 的唯一支持方法是使用包 dbms_audit_mgmt。不支持任何尝试手动操作 unified audit trail 并可能产生错误。

例子:

BEGIN
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED,
last_archive_time => TO_TIMESTAMP('26-APR-2017 13:30:00.0','DD-MON-RRRR HH24:MI:SS.FF')
END;
/

BEGIN
DBMS_AUDIT_MGMT.CLEAN_AUDIT_TRAIL(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED,
use_last_arch_timestamp => TRUE);
END;
/

如果要清除所有审计记录,我们必须调用包 DBMS_AUDIT_MGMT,并将 use_last_arch_timestamp 设置为 FALSE。

trace file

trace 日志可以手动删除,也可以通过 ADRCI 命令行删除。

Purges diagnostic data in the current ADR home, according to current purging policies. Only ADR contents that are due to be purged are purged.

Diagnostic data in the ADR has a default lifecycle. For example, information about incidents and problems is subject to purging after one year, whereas the associated dump files (dumps) are subject to purging after only 30 days.

Syntax and Description

purge [-i {id | start_id end_id} | -age mins [-type {ALERT|INCIDENT|TRACE|CDUMP|HM}]]

ADCRI purge commands like:
adrc

purge -age 60 -type ALERT
-- By 许望(RHCA、OCM、VCP)
最后修改:2020 年 07 月 17 日 05 : 44 PM
如果觉得我的文章对你有用,请随意赞赏