Oracle19c使用adrci清理日志文件

Oracle中通常有好多日志文件,遇到异常情况会产生大量日志,造成磁盘空间紧张。
故需要清理对应文件。包括trace文件,incident文件,listener log文件等。
19c中oracle提供了一个ADRCI的命令行工具来查看ADR中的alert日志和trace信息,可以批量删除对应的日志文件。
adrci的位置在$ORACLE_HOME/bin目录下。

单机(集群)都看这里,只不过,集群是在grid用户下,而单机则是在oracle用户下。那么,怎么快速的找到它呢?

##就是这样。这里说的是 log.xml 监听日志文件
cd $ ORACLE_BASE/diag/tnslsnr/$HOSTNAME/listener/alert

下图中,显示的是监听日志文件​​log.xml​​的目录位置。
Oracle19c使用adrci清理日志文件_第1张图片
监听日志文件listener.log在这里!
Oracle19c使用adrci清理日志文件_第2张图片
如何查看监听日志文件的大小呢?
一般我们是进入监听日志文件所在目录,使用du -sh或者du -sh *或者du -sh listener.log查看其大小。但是,假如有数十上百个库,你也要一个一个进入目录,去查看吗?快捷命令来了。这样一定速度提高了效率。

cd $ ORACLE_BASE/diag/tnslsnr/$HOSTNAME/listener && du -sh *

有图有真相!我们只需要关注这两个文件夹的大小,即可决定是否需要清理。

Oracle19c使用adrci清理日志文件_第3张图片
如何清理呢?
首先,不需要停止监听服务。
其次,备份监听服务,以免带来不必要的麻烦,你懂的。
一般,我们这样操作。

监听日志文件log.xml如何清理呢?

使用adrci删除30天以前的
集群模式
[root@b19c01 ~]# su - grid
Last login: Wed Sep 14 23:23:47 CST 2022 on pts/3
[grid@b19c01:/home/grid]$ adrci
adrci> purge -age 43200 -type alert
adrci> exit

单机模式
[root@b19c01 ~]# su - oracle
Last login: Wed Sep 14 23:23:47 CST 2022 on pts/3
[oracle@b19c01:/home/oracle]$ adrci
adrci> purge -age 43200 -type alert
adrci> exit

1.删除incident文件
调用adrci

[root@prod-idm-storage incident]# adrci
ADRCI: Release 11.2.0.2.0 - Production on Tue May 7 15:19:08 2019
Copyright © 1982, 2009, Oracle and/or its affiliates. All rights reserved.
ADR base = “/app/oracle”

查看目录

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

存在多个home需要指定单个home进行操作

adrci> set homepath diag/rdbms/tyrz/tyrz

查看incident

adrci> show incident
ADR Home = /app/oracle/diag/rdbms/orcl/orcl:
INCIDENT_ID PROBLEM_KEY CREATE_TIME
243353 ORA 227 2018-08-31 09:22:40.871000 +08:00
262554 ORA 227 2018-08-31 09:34:26.395000 +08:00
339426 ORA 1578 2018-09-22 06:01:46.329000 +08:00
339370 ORA 1578 2018-09-22 10:07:49.852000 +08:00
339402 ORA 1578 2018-09-22 14:08:23.558000 +08:00
339386 ORA 1578 2018-09-22 18:08:47.587000 +08:00
339394 ORA 1578 2018-09-22 22:09:26.524000 +08:00
339410 ORA 1578 2018-09-23 06:01:17.392000 +08:00
339387 ORA 1578 2018-09-23 10:10:58.257000 +08:00
339411 ORA 1578 2018-09-23 14:11:21.786000 +08:00
339412 ORA 1578 2018-09-23 18:11:59.186000 +08:00
339413 ORA 1578 2018-09-23 22:12:19.998000 +08:00
339414 ORA 1578 2018-09-24 22:01:20.661000 +08:00
339434 ORA 1578 2018-09-25 22:01:21.496000 +08:00
339415 ORA 1578 2018-09-26 22:01:09.127000 +08:00
339442 ORA 1578 2018-09-27 22:01:26.124000 +08:00
339450 ORA 1578 2018-09-28 22:01:21.893000 +08:00
339403 ORA 1578 2018-09-29 06:01:25.350000 +08:00
339418 ORA 1578 2018-09-29 10:07:14.940000 +08:00
339388 ORA 1578 2018-09-29 14:07:53.091000 +08:00
339389 ORA 1578 2018-09-29 18:08:10.510000 +08:00
339404 ORA 1578 2018-09-29 22:08:50.151000 +08:00
339419 ORA 1578 2018-09-30 06:01:15.858000 +08:00
339390 ORA 1578 2018-09-30 10:10:21.898000 +08:00
339391 ORA 1578 2018-09-30 14:10:47.874000 +08:00
339371 ORA 1578 2018-09-30 18:11:24.833000 +08:00
339405 ORA 1578 2018-09-30 22:11:47.994000 +08:00
339372 ORA 1578 2018-10-01 22:01:17.620000 +08:00
339435 ORA 1578 2018-10-02 22:01:30.078000 +08:00
339451 ORA 1578 2018-10-03 22:01:23.725000 +08:00
339420 ORA 1578 2018-10-04 22:01:21.404000 +08:00
339416 ORA 1578 2018-10-05 22:01:15.775000 +08:00
339421 ORA 1578 2018-10-06 06:01:29.564000 +08:00
339417 ORA 1578 2018-10-06 10:08:21.342000 +08:00
339422 ORA 1578 2018-10-06 14:08:52.711000 +08:00
345607 ORA 1578 2018-10-06 18:09:17.919000 +08:00
345609 ORA 1578 2018-10-06 22:09:56.154000 +08:00
339436 ORA 1578 2018-10-07 06:01:18.502000 +08:00
339406 ORA 1578 2018-10-07 10:01:23.514000 +08:00
339407 ORA 1578 2018-10-07 14:01:46.542000 +08:00
339354 ORA 1578 2018-10-07 18:02:21.533000 +08:00
339355 ORA 1578 2018-10-07 22:02:45.654000 +08:00
339498 ORA 1578 2018-10-08 22:01:23.626000 +08:00
339466 ORA 1578 2018-10-09 22:01:21.970000 +08:00
339467 ORA 1578 2018-10-10 22:01:11.649000 +08:00
339499 ORA 1578 2018-10-11 22:01:17.955000 +08:00
339443 ORA 1578 2018-10-12 22:01:24.071000 +08:00
339423 ORA 1578 2018-10-13 06:01:17.901000 +08:00
339373 ORA 1578 2018-10-13 10:06:37.319000 +08:00
339374 ORA 1578 2018-10-13 14:07:14.910000 +08:00
First 50 rows fetched (*** more available ***)

删除100天前的incident 14400=60min24100

adrci>purge -age 144000 -type incident

退出

adrci> exit

帮助

adrci> help purge
Usage: PURGE [[-i | ] |
[-age [-type ALERT|INCIDENT|TRACE|CDUMP|HM|UTSCDMP]]]:
Purpose: Purge the diagnostic data in the current ADR home. If no
option is specified, the default purging policy will be used.
Options:
[-i id1 | id1 id2]: Users can input a single incident ID, or a
range of incidents to purge.
[-age ]: Users can specify the purging policy either to all
the diagnostic data or the specified type. The data older than
ago will be purged
[-type ALERT|INCIDENT|TRACE|CDUMP|HM|UTSCDMP]: Users can specify what type of data to be purged.
Examples:
purge
purge -i 123 456
purge -age 60 -type incident

2.删除listener log

adrci> purge -age 8760 -type alert

3.删除TRACE
查看trace

adrci> show tracefile
diag/rdbms/oam/oam/trace/oam_vkrm_10487.trc
diag/rdbms/oam/oam/trace/oam_vkrm_6627.trc
diag/rdbms/oam/oam/trace/oam_j003_26131.trc
diag/rdbms/oam/oam/trace/oam_m000_404.trc
diag/rdbms/oam/oam/trace/oam_m000_20336.trc
diag/rdbms/oam/oam/trace/oam_w000_3502.trc
diag/rdbms/oam/oam/trace/oam_vkrm_31062.trc
diag/rdbms/oam/oam/trace/oam_m000_14702.trc
diag/rdbms/oam/oam/trace/oam_j000_949.trc
diag/rdbms/oam/oam/trace/oam_vkrm_28172.trc
diag/rdbms/oam/oam/trace/alert_oam.log
diag/rdbms/oam/oam/trace/oam_vkrm_12182.trc
diag/rdbms/oam/oam/trace/oam_w000_31588.trc
diag/rdbms/oam/oam/trace/oam_j000_6363.trc
diag/rdbms/oam/oam/trace/oam_w001_8741.trc
diag/rdbms/oam/oam/trace/oam_m000_15978.trc
diag/rdbms/oam/oam/trace/oam_vkrm_15883.trc
diag/rdbms/oam/oam/trace/oam_m000_5141.trc
diag/rdbms/oam/oam/trace/oam_j001_15641.trc
diag/rdbms/oam/oam/trace/oam_j000_21062.trc
diag/rdbms/oam/oam/trace/oam_m000_24268.trc
diag/rdbms/oam/oam/trace/oam_m000_21366.trc
diag/rdbms/oam/oam/trace/oam_vkrm_14072.trc

删除操作

adrci> purge -age 8760 -type trace

你可能感兴趣的:(oracle,数据库)