数据库
首页 > 数据库> > oracle清除日志

oracle清除日志

作者:互联网

近日发现oracle占用的空间很大,经查,发现是

/u01/app/oracle/diag/rdbms/orcl/orcl/alert 警告日志

/u01/app/oracle/diag/rdbms/orcl/orcl/trace 跟踪日志

这两个目录日志文件太多。占用十几个G

用adrci清除日志

先确定目录

SQL> select value from v$diag_info where name ='Diag Alert';

VALUE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/orcl/orcl/alert


SQL> select value from v$diag_info where name ='Diag Trace';

VALUE
--------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/orcl/orcl/trace

 

adrci是操作系统下的oracle命令,可以直接运行adrci

[oracle@dom169 /]$ adrci

ADRCI: Release 12.1.0.2.0 - Production on Sat Apr 16 21:17:04 2022

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

ADR base = "/u01/app/oracle"
adrci>

 

先查看homepath是不是所要处理的日志目录

adrci> show home
ADR Homes: 
diag/rdbms/orcl/orcl
adrci> 

如果不是,先设置homepath

adrci> set homepath diag/rdbms/orcl/orcl

清空警告日志,1440是按分钟算的,就是一天,这是清空一天以前的警告日志

adrci> purge -age 1440 -type alert

清空跟踪日志,1440是按分钟算的,就是一天,这是清空一天以前的跟踪日志

adrci> purge -age 1440 -type alert

 

查看日志保留策略

默认SHORTP_POLICY为720小时(即30天),LONGP_POLICY为8760小时(即365天) 

adrci> show control

ADR Home = /u01/app/oracle/diag/rdbms/orcl/orcl:
***************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         
-------------------- -------------------- -------------------- 
1335663986           720                  8760                 
1 rows fetched

 

LONGP_POLICY is used to purge information that have long life. Default value is 365 days.
This policy is used by :

ALERT
INCIDENT
SWEEP
STAGE
HM

 

SHORTP_POLICY is used to purge the information that have short life. Default value is 30 days.
This policy is used by :

TRACE
CDUMP
UTSCDMP
IPS
 

默认SHORTP_POLICY为720小时(即30天),LONGP_POLICY为8760小时(即365天)

#设置SHORTP_POLICY 15天 LONGP_POLICY 90天

adrci> set control (SHORTP_POLICY = 360) 
adrci> set control (LONGP_POLICY = 2160) 

 

标签:清除,adrci,POLICY,orcl,diag,oracle,日志
来源: https://www.cnblogs.com/bianguji/p/16154382.html