In my last post, I’ve showed how to purge Audit Trail files from OS. Usually Audit Trail directories are places which you see lots of space used due to unmanaged audit files from Oracle. However, there are places you may want to take a look when you see a filesystem related to Oracle is getting full — Automatic Diagnostic Repository (ADR).
For a RAC environment, you need to check both grid and database levels. And we can use a handy tool ADRCI to purge files manually. Within ADRCI, first “set home” to individual ADR home (that’s because ADRCI doesn’t support purge multiple homes), then run the “purge” command. For example:
[oracle@joeoda002 ~]$ adrci
ADRCI: Release 12.1.0.2.0 - Production on Mon May 11 13:49:11 2020
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
ADR base = "/u01/app/oracle"
adrci> show homes
ADR Homes:
diag/asm/user_root/host_2086402248_82
diag/clients/user_oracle/host_2086402248_82
diag/asmtool/user_root/host_2086402248_82
diag/rdbms/joedb/JOEDB2
adrci> set home diag/rdbms/joedb/JOEDB2
adrci> help purge
Usage: PURGE [[-i <id1> | <id1> <id2>] |
[-age <mins> [-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 <mins>]: Users can specify the purging policy either to all
the diagnostic data or the specified type. The data older than <mins>
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
adrci> purge -age 600
Note:
- When using “-age” option, the unit of value follows is minute.
- You need to repeat “purge” command for multiple ADR homes since the purge command only works for a single ADR home. Maybe write a small script to ease your life or use the purgeLogs tool from Oracle.
- Think about to change purge policy within the ADR framework by changing the following 2 parameters (using “show control” to see current values):
- SHORTP_POLICY: Which is used for automatically purging short-lived files, i.e. core dump files and traces, expressed in hours and defaults to 720 hours (30 days).
- LONGP_POLICY: Which is used for automatically purging long-lived files, i.e. incidents and health monitor warnings, expressed in hours and defaults to 8760 hours (1 year).
Things look straightforward at this point. However, there is a limitation when ADRCI handles a single large trace file which doesn’t rotate. For example, the flat text listener log file. It just doesn’t do anything about it.
[grid@joeoda002 ~]$ lsnrctl
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-MAY-2020 13:57:49
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> set current_listener ASMNET1LSNR_ASM
Current Listener is ASMNET1LSNR_ASM
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=ASMNET1LSNR_ASM)))
STATUS of the LISTENER
------------------------
Alias ASMNET1LSNR_ASM
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 27-SEP-2018 13:41:22
Uptime 94 days 21 hr. 48 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/12.2.0.1/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/joeoda002/asmnet1lsnr_asm/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=ASMNET1LSNR_ASM)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.16.25)(PORT=1526)))
Services Summary...
Service "+ASM" has 2 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Instance "+ASM2", status READY, has 2 handler(s) for this service...
Service "+ASM_DATA" has 2 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Instance "+ASM2", status READY, has 2 handler(s) for this service...
Service "+ASM_RECO" has 2 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Instance "+ASM2", status READY, has 2 handler(s) for this service...
Service "+ASM_REDO" has 2 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Instance "+ASM2", status READY, has 2 handler(s) for this service...
The command completed successfully
In the example above, you can see the ASM listener has the listener log file: /u01/app/grid/diag/tnslsnr/joeoda002/asmnet1lsnr_asm/alert/log.xml. Trace Level is off. When running the “purge” command for this listener ADR home, any rotated files in XML format older than specified age will be deleted from OS. Great! That is what you expect to do with “purge”! However, if you look closely at the OS level, you may notice there is one big single file which is under /u01/app/grid/diag/tnslsnr/joeoda002/asmnet1lsnr_asm/trace. It’s a counterpart of XML log files in plain text and in a single file. Over time, it could be growing to a couple of gigbytes or even more until you notice it.
Currently from what I am aware of, as long as a listener log is enabled, Oracle will create both XML and plain text versions. So how to trim this file without stopping the listener? Well, you can just trim it at the OS level e.g. using “>”. Yes, that’s it since the file is not locked.
Or do it gracefully — first turn off listener logging, then trim the file at the OS level, then turn on listener logging again. See the following example:
[grid@joeoda002 ~]$ du -sh /u01/app/grid/diag/tnslsnr/joeoda002/asmnet1lsnr_asm/trace/asmnet1lsnr_asm.log
395M /u01/app/grid/diag/tnslsnr/joeoda002/asmnet1lsnr_asm/trace/asmnet1lsnr_asm.log
[grid@joeoda002 ~]$ lsnrctl
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-MAY-2020 14:15:07
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> set current_listener ASMNET1LSNR_ASM
Current Listener is ASMNET1LSNR_ASM
LSNRCTL> show log_status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=ASMNET1LSNR_ASM)))
ASMNET1LSNR_ASM parameter "log_status" set to ON
The command completed successfully
LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=ASMNET1LSNR_ASM)))
ASMNET1LSNR_ASM parameter "log_status" set to OFF
The command completed successfully
Empty the log file with “>” and enable logging again:
[grid@joeoda002 ~]$ >/u01/app/grid/diag/tnslsnr/joeoda002/asmnet1lsnr_asm/trace/asmnet1lsnr_asm.log
[grid@joeoda002 ~]$ lsnrctl
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 11-MAY-2020 14:18:28
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> set current_listener ASMNET1LSNR_ASM
Current Listener is ASMNET1LSNR_ASM
LSNRCTL> set log_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=ASMNET1LSNR_ASM)))
ASMNET1LSNR_ASM parameter "log_status" set to ON
The command completed successfully
LSNRCTL> exit
If you want to keep some lines, you can do something as showed below which preserves last 5000 lines.
echo "$(tail -n 5000 listener_scan1.log)" > listener_scan1.log
Reference:
- WINDOWS: Listener Hangs & Lsnrctl Commands Are Slow or Hang (Doc ID 1319797.1)
- How To Change the Listener Log Filename Without Stopping the Listener (Doc ID 135063.1)
- purgeLogs: Cleanup traces, logs in one command (Doc ID 2081655.1)
One thought on “Purging flat (non-XML) text listener log file for ASM, SCAN etc.”