ADRCI (Automatic Diagnostic Repository Command Interpreter) :

[Introduction]
Housekeeping tasks are automatically picked up by MMON (Memory Monitor)
backround process.

SHORTP_POLICY(short term) defaults to 720 hours (30 days) => automatically clean trace & core dump files

LONGP_POLICY(long term) defaults to 8760 hours (365 days) => automatically clean Incidents and Health Monitor warnings.
SQL> sho parameter
diagnostic_dest
NAME                                 TYPE                 VALUE
------------------------------------ -------------------- ------------------------------
diagnostic_dest                      string               /oracle

[Usage ]
# adrci
ADRCI: Release 11.2.0.2.0 - Production on Tue Oct 4 15:55:58 2011

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

No ADR base is set

adrci> set base /oracle
adrci>
show base
ADR base is "/oracle"

adrci> show homes
ADR Homes:
diag/rdbms/testdb/TESTDB1
diag/rdbms/testdb2/TESTDB21
diag/rdbms/testdb3/TESTDB31

adrci> set home TESTDB


adrci> show control

ADR Home = /oracle/diag/rdbms/testdb/TESTDB1:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
45261763             720                  8760                 2011-08-18 16:19:23.458764 +08:00                                                                                          1                    2                    80                   1                    2011-08-18 16:19:23.458764 +08:00
1 rows fetched


Manually purging all trace files (.log) older than 6 days (8640 minutes) by:
adrci> purge -age 8640 -type TRACE

Manually purging all alert files (.xml) older than 6 days (8640 minutes) by:
adrci> purge -age 8640 -type ALERT



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

Without specifying purging type, all types will be purged.
adrci> purge -age 8640

Changing SHORTP_POLICY & LONGP_POLICY values (in hours) by:
adrci> set control (SHORTP_POLICY = 360 LONGP_POLICY = 1440)

adrci> show control

ADR Home = /oracle/diag/rdbms/testdb/TESTDB1:
*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY         LAST_MOD_TIME                            LAST_AUTOPRG_TIME                        LAST_MANUPRG_TIME                        ADRDIR_VERSION       ADRSCHM_VERSION      ADRSCHMV_SUMMARY     ADRALERT_VERSION     CREATE_TIME
-------------------- -------------------- -------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------- -------------------- -------------------- -------------------- ----------------------------------------
45261763             360                  1440                 2011-10-04 15:13:15.646709 +08:00        2011-10-03 00:13:43.774374 +08:00        2011-10-04 15:13:23.590306 +08:00        1                    2                    80                   1                    2011-08-31 15:10:54.197781 +08:00
1 rows fetched




** For log files such as listener tracelog & listener scan1 tracelog, the housekeeping method is different by using Linux logrotate program:

1.
Login as root
cd /etc/logrotate.d

2.
Create a file named ora_housekeeping and type the following commands:

# listener tracelog
/grid/orabase/diag/tnslsnr/RAC1/listener/trace/listener.log {
weekly
compress
rotate 4
notifempty
missingok
copytruncate
nocreate
}

# listener scan1 tracelog
/grid/grid11203/log/diag/tnslsnr/RAC1/listener_scan1/trace/listener_scan1.log {
weekly
compress
rotate 4
notifempty
missingok
copytruncate
nocreate
}

  ** For ASM RDBMS audit log & trace files housekeeping method using crontab:
EXPORT ORACLE_SID=+ASM
sqlplus / as sysasm
SQL> sho parameter audit_file_dest
NAME TYPE VALUE
--------------------- ------------ ----------------------------------------------

audit_file_dest string /grid/grid11203/rdbms/audit


crontab -e
>>
# Clear 30 days old ASM audit log files daily at 7AM
0 7 * * * find /grid/grid11203/rdbms/audit -mtime +30 -name "*.aud" -exec rm -rf {} \; > /dev/null 2>&1

0 7 * * * find /grid/grid11203/rdbms/log -mtime +30 -name "*.trc" -exec rm -rf {} \; > /dev/null 2>&1


See also Auditing Using Operating System Audit Trail:
 
http://danbrother.pixnet.net/blog/post/40366278

 


[Reference]
[1]
http://gavinsoorma.com/2010/09/purging-trace-and-dump-files-with-11g-adrci/
[2] http://www.morganslibrary.com/reference/adr.html
[3]  http://itdavid.blogspot.tw/2011/02/manage-oracle-11gr2-asm-and-rdbms-audit.html

 

arrow
arrow
    全站熱搜

    DanBrother 發表在 痞客邦 留言(0) 人氣()