• Oracle官方提供清理侦听器日志的4种方式


    Oracle官方提供清理侦听器日志的4种方式

    侦听器日志,例如:

    [root@dev-testdb trace]# ll /u01/app/grid/diag/tnslsnr/dev-testdb/listener/trace/listener.log 
    -rw-r----- 1 grid oinstall 1129 Jan 20 10:35 /u01/app/grid/diag/tnslsnr/dev-testdb/listener/trace/listener.log

    根据实际执行和Why Are My Listener Logs & Traces Not Purged By The ADR (文档 ID 1438242.1)可知,不会被如下命令adrci的交互式命令清除:

    purge -age <min> -type alert

    该命令只会清理xml格式的文本。

    以11g为例子,总结了官方提供的4种清除方式。

    1. ARCHIVED How to Rotate or Purge Listener Log Data to Avoid Large listener.log File (文档 ID 1457196.1)
      停止监听后删除或重命名日志,下次启动侦听器会创建新的日志
    2. ARCHIVED How to Rotate or Purge Listener Log Data to Avoid Large listener.log File (文档 ID 1457196.1)
      LSNRCTL> set current_listener <listenername>
      LSNRCTL> set log_status off
      在另一个窗口中重命名日志文件。然后返回上一个窗口
      LSNRCTL> set log_status on
      这将创建一个新的空 listener.log 文件,该文件将继续记录。  
    3. Excessive Listener XML FILES CREATED IN $GRID_HOMElogdiagtnslsnr (文档 ID 1927067.1)
      Adrci Purge Does Not Clear the Text-formatted Alert.Log located in the Trace Folder (文档 ID 751082.1)
      How To Purge Listener Log.Xml File (文档 ID 816871.1)
      这3篇官方文档指出adrci不会清理文本格式的 alert.log 文件,只修改 XML 格式的警报文件,而不是 Text 格式的警报文件。
      需要手工编辑或者删除文本基础.log的文件,例如:对文件进行拆分,或者使用 Unix 上的“vi”之类的编辑器来清空文件等...
    4. echo "" >| /u01/app/grid/diag/tnslsnr/dev-testdb/listener/trace/listener.log
      咋一看简单且暴力,一点也不优雅。
      purgeLogs Cleanup traces, logs in one command (文档 ID 2081655.1)中提供了一个脚本purgeLogs,需要使用root用户执行并且需要有/etc/init.d/init.ohasd脚本,即单机环境无法使用。
      下边详细说说这第4点。

    echo方式清空日志实际上就是purgeLogs这个脚本的处理方式。
    脚本功能比较强大,可以清理osw,tfa,rdbms等等的信息文件,不仅仅限于日志。

    [root@dev-testdb trace]# /soft/purgeLogs  -h
    Usage:
         purgeLogs [ -days <days> [ -aud ] [ -lsnr ] ] |
                   [ -orcl <days> [ -aud ] [ -lsnr ] ] |
                   [ -tfa <days> ] | 
                   [ -osw <days> ] | 
                   [ -oda <days> ] | 
                   [ -extra '<folder>':<days> | [, '<folder>':<days>] ]
                   [ -automigrate ]
                   [ -dryrun ]
    
         purgeLogs OPTIONS
          -days  <days>             Purge orcl,tfa,osw,oda components logs & traces older then # days
          -orcl  <days>             Purge only GI/RDBMS logs & traces (Default 30 days)
          -tfa   <days>             Purge only TFA repository older then # days (Default 30 days)
          -osw   <days>             Purge only OSW archives older then # days (Default 30 days)
          -oda   <days>             Purge only ODA logs and trace older then # days (Default 30 days)
          -extra '<folder>':<days>  Purge only files in user specified folders (Default 30 days)
          -aud                      Purge Audit logs based on '-orcl <days>' option
          -lsnr                     It will force the cleanup of listeners log independently by the age
          -dryrun                   It will show the purge commands w/o execute them
          -automigrate              It will run the adrci schema migrate commands in case of DIA-49803
          -h                        Display this help and exit
    
         Example:
           purgeLogs
           purgeLogs -days 20
           purgeLogs -orcl 50
           purgeLogs -orcl 50 -aud -lsnr
           purgeLogs -tfa  50
           purgeLogs -osw  20 -oda 10
           purgeLogs -orcl 20 -osw 20 -oda 10
           purgeLogs -orcl 20 -osw 20 -oda 10 -extra /tmp:10,/var/log:20

    根据帮助手册,删除GI/RDBMS日志和trace文件,同时删除侦听日志的指令:

    /soft/purgeLogs -orcl  10 -lsnr -aud -dryrun

    输出案例:

    [root@dev-testdb ~]# /soft/purgeLogs -orcl  10 -lsnr -aud -dryrun
    
    │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
     purgeLogs version: 1.65
     Copyright (c) 2015-2020 Oracle and/or its affiliates.
     -------------------------------------------------------
     Author: Ruggero Citton <ruggero.citton@oracle.com>
     RAC Pack, Cloud Innovation and Solution Engineering Team
    │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
    
    2022-01-20 11:01:04: I DRYRUN - Cleaning up Listener logs, ORACLE_BASE is '/u01/app/grid'
            echo "" >| /u01/app/grid/diag/tnslsnr/dev-testdb/listener/trace/listener.log
    2022-01-20 11:01:04: I DRYRUN - Cleaning up SCAN1 Listener logs, ORACLE_BASE is '/u01/app/grid'
    2022-01-20 11:01:04: W Path /u01/app/grid/diag/tnslsnr/dev-testdb/listener_scan1/trace does not exist, SCAN1 Listener logs cleanup skipped...
    2022-01-20 11:01:04: I DRYRUN - Cleaning up SCAN2 Listener logs, ORACLE_BASE is '/u01/app/grid'
    2022-01-20 11:01:04: W Path /u01/app/grid/diag/tnslsnr/dev-testdb/listener_scan2/trace does not exist, SCAN2 Listener logs cleanup skipped...
    2022-01-20 11:01:04: I DRYRUN - Cleaning up SCAN3 Listener logs, ORACLE_BASE is '/u01/app/grid'
    2022-01-20 11:01:04: W Path /u01/app/grid/diag/tnslsnr/dev-testdb/listener_scan3/trace does not exist, SCAN3 Listener logs cleanup skipped...
    2022-01-20 11:01:04: I DRYRUN - Cleaning up Management Listener logs, ORACLE_BASE is '/u01/app/grid'
    2022-01-20 11:01:04: W Path /u01/app/grid/diag/tnslsnr/dev-testdb/mgmtlsnr/trace does not exist, Management Listener logs cleanup skipped...
    2022-01-20 11:01:04: I DRYRUN - Cleaning up ASM Listener logs, ORACLE_BASE is '/u01/app/grid'
    2022-01-20 11:01:04: W Path /u01/app/grid/diag/tnslsnr/dev-testdb/asmnet1lsnr_asm/trace does not exist, ASM Listener logs cleanup skipped...
    2022-01-20 11:01:04: I GI Audit logs purge started
    2022-01-20 11:01:04: I DRYRUN - Purging GI Audit logs under '/u01/app/11.2.0/grid/rdbms/audit' older then 10 days
            rm /u01/app/11.2.0/grid/rdbms/audit/null_ora_26047_20210517200222237009143795.aud
            rm /u01/app/11.2.0/grid/rdbms/audit/+ASM1_ora_26076_20210517200222587121143795.aud
            rm /u01/app/11.2.0/grid/rdbms/audit/+ASM1_ora_26076_20210517200222588926143795.aud
            rm /u01/app/11.2.0/grid/rdbms/audit/+ASM1_ora_26089_20210517200222906375143795.aud
            rm /u01/app/11.2.0/grid/rdbms/audit/+ASM1_ora_26089_20210517200259048887143795.aud
            rm /u01/app/11.2.0/grid/rdbms/audit/+ASM1_ora_26201_20210517200259071998143795.aud
            ...省略部分内容...
    2022-01-20 11:01:04: I DRYRUN - Purging GI Audit logs under '/u01/app/grid/admin/_mgmtdb/adump' older then 10 days
    2022-01-20 11:01:04: W Path /u01/app/grid/admin/_mgmtdb/adump does not exist, GI Audit archive logs cleanup skipped...
    ~~~~~~~~~~~~~~~~~~~~~~adrci GI purge started~~~~~~~~~~~~~~~~~~~~~~
    2022-01-20 11:01:04: I Checking if this is an Oracle Restart environment
    2022-01-20 11:01:04: I DRYRUN - adrci GI purging diagnostic destination diag/asm/+asm/+ASM1 older than 10 days
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type ALERT "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type INCIDENT "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type TRACE "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type CDUMP "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type STAGE "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type SWEEP "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type HM "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/asm/+asm/+ASM1;purge -age 14400 -type UTSCDMP "'
    2022-01-20 11:01:04: I DRYRUN - adrci GI purging diagnostic destination diag/tnslsnr/dev-testdb/listener older than 10 days
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type ALERT "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type INCIDENT "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type TRACE "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type CDUMP "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type STAGE "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type SWEEP "'
            su grid -c 'export ORACLE_HOME=/u01/app/11.2.0/grid;/u01/app/11.2.0/grid/bin/adrci exec="set homepath diag/tnslsnr/dev-testdb/listener;purge -age 14400 -type HM "'
    ......

    可以看到脚本实际就是使用了echo来清理日志的。10[天]这个参数不生效。

  • 相关阅读:
    JAVA 遍历UFT-8所有中文
    用友U8 | 【固定资产】固定资产常见问题
    用友U8 | 【出纳管理】当前凭证不是出纳管理凭证,不能修改
    用友U8 | 【出纳管理】选中的日记账包含了已制单但没有回写凭证号的日记账,无法制单!
    用友U8 | 【生产订单】工作日历未设定或超出工作日历范围
    用友U8 | 【出纳管理】当前选择的日记账已经制单,上次制单包含其他账户的日记账,请在日记账查询中修改
    用友U8 | 【U8年结】开账结转如何操作?
    用友U8 | 【出纳管理】收支操作生单提示:集合中的143272已经加锁了,不能对集合中的数据进行加锁
    用友U8 | 【出纳管理】银行记账提示:未设置对象变量或with block 变量(91)
    MySQL经典45题(二)
  • 原文地址:https://www.cnblogs.com/PiscesCanon/p/15825693.html
Copyright © 2020-2023  润新知