Total Pageviews

Tuesday, December 11, 2018

PURGING TRACE AND DUMP FILES WITH 11G ADRCI


In previous versions of Oracle prior to 11g, we had to use our own housekeeping scripts to purge the udump, cdump and bdump directories.
In Oracle 11g, we now have the ADR (Automatic Diagnostic Repository) which is defined by the diagnostic_dest parameter.
So how are unwanted trace and core dump files cleaned out in 11g automatically?
This is done by the MMON background process.
There are two time attributes which are used to manage the retention of information in ADR. Both attributes correspond to a number of hours after which the MMON background process purges the expired ADR data.
  1. SHORTP_POLICY:  Which is used for automatically purging short-lived files, i.e. core dump files and traces, expressed in hours and defaults to 30 days.
2.    LONGP_POLICY: Which is used for automatically purging long-lived files, i.e. incidents and health monitor warnings, expressed in hours and defaults to 1 year (365 days).
The ADRCI command show control will show us what the current purge settings are as shown below.
C:\Users\ashwanik\Desktop\MY_SCRIPT>show control
'show' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\ashwanik\Desktop\MY_SCRIPT>adrci

ADRCI: Release 11.2.0.4.0 - Production on Tue Dec 11 15:28:30 2018

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

ADR base = "c:\app\ashwanik"
adrci> show control
DIA-48448: This command does not support multiple ADR homes

adrci>  show homes
ADR Homes:
diag\clients\user_ashwani\host_2731541237_76
diag\clients\user_ashwani\host_2731541237_80
diag\clients\user_ashwani\host_2731541237_82
diag\clients\user_SYSTEM\host_2731541237_76
diag\clients\user_SYSTEM\host_2731541237_80
diag\clients\user_SYSTEM\host_2731541237_82
diag\rdbms\db11g\db11g
diag\rdbms\db11gdev\db11gdev
diag\rdbms\db11gdev\orcl
diag\rdbms\metalsdb\metalsdb
diag\rdbms\orcl\orcl
diag\rdbms\testdb\testdb
diag\rdbms\testdev\testdev
diag\tnslsnr\2242ASHWAN1525D\listener
diag\tnslsnr\2242ASHWAN1525D\listener1
diag\tnslsnr\2242ASHWAN1525D\listener12c
diag\tnslsnr\2242ASHWAN1525D\listener2
diag\tnslsnr\2242ASHWAN1525D\listener_12c
diag\tnslsnr\2242ASHWAN1525D\listener_db11gdr
diag\tnslsnr\2242ASHWAN1525D\listner1
diag\tnslsnr\2242ASHWAN1525D\services
diag\tnslsnr\2242ASHWAN1525D\status

I have multiple different path for different instance. Let’s choose the path for which instance (db11gdev) we need to remove the trace files as below:

adrci> set homepath diag\rdbms\db11gdev\db11gdev
adrci> show control

ADR Home = c:\app\ashwani\diag\rdbms\db11gdev\db11gdev:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
4201279328           720                  8760                 2017-10-23 16:17:50.212000 +05:30        2018-12-09 04:46:22.558000 +05:30        2018-12-11 15:20:21.338000 +05:30        1                    2                    80                   1                    2017-10-23 16:17:50.212000 +05:30
1 rows fetched

In this case it is set to the defaults of 720 hours (30 days) for the Short Term and 8760 hours (One year) for the long term category.

adrci> show control

ADR Home = c:\app\ashwanik\diag\rdbms\db11gdev\db11gdev:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
4201279328           720                  8760                 2017-10-23 16:17:50.212000 +05:30        2018-12-09 04:46:22.558000 +05:30        2018-12-11 15:20:21.338000 +05:30        1                    2                    80                   1                    2017-10-23 16:17:50.212000 +05:30
1 rows fetched

We can change this by using the ADRCI command ‘set control’

adrci> set control (SHORTP_POLICY =360)
adrci> show control

ADR Home = c:\app\ashwanik\diag\rdbms\db11gdev\db11gdev:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
4201279328           360                  8760                 2018-12-11 15:42:08.147000 +05:30        2018-12-09 04:46:22.558000 +05:30        2018-12-11 15:40:56.995000 +05:30        1                    2                    80                   1                    2017-10-23 16:17:50.212000 +05:30
1 rows fetched

In this example we are changing the retention to 15 days for the Short Term policy attribute (note it is defined in Hours)

In this example we are purging all trace files older than 6 days. We see that the LAST_MANUPRG_TIME column is now populated.
adrci> purge -age 8640 -type TRACE 

No comments:

Post a Comment