oracle12c刪除監聽log_n.xml文件

1、問題描述:

現場有個數據庫,log_n.xml日誌文件太多了。

2、要處理這個問題,我們需要了解下 這是什麼文件

https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=446908702867004&parent=EXTERNAL_SEARCH&sourceId=HOWTO&id=1438242.1&_afrWindowMode=0&_adf.ctrl-state=16n1ijzfnt_4

在oracle mos上有這個說明

(1) Listener log files ('xml' files) are not purged via the 'automatic' purge mechanism.

The automatic purge for the listener 'xml' files is a known issue that has been reported several times. For that, two enhancement requests have been raised:

Unpublished Bug 9576112  - AUTOMATIC PURGE OF 11G LISTENER LOGS LOG_NNN.XML
Unpublished Bug 13090278 - PURGING IS NOT HAPPENING FOR LISTENER ALERT AND TRACE FILES. The unpublished ER has been implemented in 19c.

It will not work basically due to the fact that is something not yet implemented in the net layer.

(2) Normally the log.xml file stores the most recent information and, as the log file grows, it will be archived into a log_1.xml, log_2.xml ..., with 10MB size each one.

(3) The manual purge -age <age> command actually removes the listener xml files (log_n.xml files) who's last record is at least "-age <age>" old.

But the information within a listener log file is not purged, so, if the least record in any of the existing log_n.xml files is more recent than the indicated age, all the information within the file will be kept, as shown in the last show alert command.  Even if this information is older than the indicated age.  For example, if you execute a purge -age 0 command, and trace it with strace, e.g.:

   strace -o /tmp/strace.trc -fae adrci exec="set home <listener diag home>;purge -age 0"

you will see that all the existing log_n.xml files are removed at OS level (including the log.xml file):

   11964 unlink("/<listener diag home>/alert/log.xml") = 0

Then, given that the listener is working, a new log file is automatically created, including all the information generated since the age -0 command.  The next show alert command will show you information since the purge command was executed.

Note: This behaviour applies to DB Alert log files too, but, given the autopurge works with them, it is less relevant.

Therefore in 11g & 12c releases, these log files (and trace files) will not get automatically purged and so you need to manually delete them when they are no longer required.

Starting with 19c release the feature of purging is implemented (through enhancement request 13090278). The relevant parameters for listener are the following:

LOG_FILE_NUM_listener_name:
    The LOG_FILE_NUM_listener_name is a diagnostic parameter of the listener.ora file that specifies the number of log file segments.
https://docs.oracle.com/en/database/oracle/oracle-database/19/netrf/oracle-net-listener-parameters-in-listener-ora.html#GUID-812F2A7E-A31C-4581-804F-A4AE692C960D

LOG_FILE_SIZE_listener_name:
    The LOG_FILE_SIZE_listener_name diagnostic parameter of the listener.ora file specifies the size of each log file segment.
https://docs.oracle.com/en/database/oracle/oracle-database/19/netrf/oracle-net-listener-parameters-in-listener-ora.html#GUID-FF94A234-A29C-46AA-8770-4CA1BFB5C27C

就是19c之前的版本沒有自動清理功能,可以通過

# su - oracle

$ adrci

adrci> help purge

adrci> purge -age 1440

這樣可以清理掉一天以前的日誌文件,1440的單位是分鐘。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章