oracle 清理trace 、alert 、aud 、listener 等⽇志⽂件
⽂章⽬录
0、注意事项
数据库产⽣的运⾏⽇志不是随便可以清理的,特别是有故障或者长期分析⼀个妖孽的问题时,清理⽇志之前⼀定要做好备份⼯作。
1、数据库各项⽇志⽂件路径
查看oracle各类⽇志的⽅法:如果是rac,asm实例下查询⽅法⼀样
1)查看诊断⽇志:
11g以及以上版本全新的诊断信息架构,查看v$diag_info信息,展⽰⽇志⽬录:
11g以下查看⽅式:
2)查看审计⽇志:show parameter diag;lect * from v$diag_info 输出例⼦如下: 1 ADR Ba /u01/app/oracle 1 ADR Home /u01/app/oracle/diag/rdbms/orcl11g/orcl11g 1 Diag Trace /u01/
app/oracle/diag/rdbms/orcl11g/orcl11g/trace 1 Diag Alert /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/alert 1 Diag Incident /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/incident 1 Diag Cdump /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/cdump 1 Health Monitor /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/hm 1 Default Trace File /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace/orcl11g_
1
2
3
4
5
6
7埃及少女
8
9
10
11
12
13
14
15
belial16
17
吉林新东方官网18
19sqlplus / as sysdba SYS@orcl1 > show parameter dump_dest;NAME TYPE VALUE background_dump_dest string /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace core_dump_dest string /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/cdump ur_dump_dest string /u01/app/oracle/diag/rdbms/orcl11g/orcl11g/trace 说明:background_dump_dest /* 存放数据库后台进程调试信息,与记录影响实例、数据库的trace ⽂件和alert ⽇志⽂件,11gR1之后,缺省忽略此参数设置,根据dia
diagnostic_dest /* 11gR1之后,引⼊,后台进程与alert 告警⽇志会根据ADR ba ⽬录存放ur_dump_dest /* 存放⽤户进程调试trace ⽂件,11gR1之后,引⼊新的诊断架构这个参数将被忽略,由diagnostic_dest 控制trace ⽂件⽣成⽬录core_dump_dest /* 存放Oracle 核⼼转储⽂件1
2
3
4
5
6
7
8
9
10
11
12
university of pennsylvania3)查看监听⽇志位置:
2、⼿⼯⽅式清理⽇志⽂件
情况1:清理单个较⼤⽇志⽂件,alert_sid.log、listener.log等
情况2:清理上万个⼩的⽇志⽂件,trc⽇志、aud审计⽇志等
如果开启了数据库审计⽇志,那需要在数据库中清理aud$审计表
3、使⽤oracle ⾃带⼯具清理
使⽤adrci清理trace和acident⽇志
也可以在adrci中设置trace⽂件保留的策略:SYS@orcl1 > show parameter audit_file_dest;NAME TYPE VALUE ------------------------------------ ----------- ------------------------------audit_file_dest string /u01/app/oracle/admin/orcl/adump audit_file_dest 路径下存放的是数据库审计信息⽂件,如果设置audit_trail 为NONE ,则默认此⽬录只存放SYSDBA ⾝份登陆审计信息。注意,asm 实例下⾯看到的路径可能不⼀样,⽐如:audit_file_dest string /u01/app/12.2.0/grid/rdbms/audit
1
2
3
atk4
5
6
7
8
9
10[oracle@onetest ~]$ lsnrctl status Listener Parameter File /u01/app/oracle/product/19.0.0/db_1/network/a Listener Log File /u01/app/oracle/diag/tnslsnr/onetest/listener/l 注意,除了监听xml ⽇志,还有listener.log ⽇志位于/u01/app/oracle/diag/tnslsnr/onetest/listener/trace ⽬录下
1
2
3
4
5SQL> lect * from v$diag_info where name='Diag Trace';/u01/app/oracle/diag/rdbms/orcl/orcl/trace [oracle@orclr01 trace]$cd /u01/app/oracle/diag/rdbms/orcl/orcl1/trace [oracle@orclr01 trace]$ ls -lrt alert*[oracle@orclr01 trace]$cp alert_orcl1.log /data/backlog/oralog/alert_orcl1.log -`date +"%Y%m%d"`[oracle@orclr01 trace]$echo 0 > alert_orcl1.log CPU 空闲时操作:cd /data/backlog/oralog gzip 刚才备份的alert ⽇志⽂件说明:通过echo 的⽅式清理,可以保持⽂件的属性,不影响zabbix 监控alert ⽇志。
12
3
4
5
6
7
8
9
68届金球奖
10
11
12asm 实例下:show parameter audit_file_dest cd /u01/app/11.2.0/grid/rdbms/audit 清理前可选择备份:find . -mtime +30 -name \*.aud -exec mv {} /oralog_bak \;或者直接删除:find . -name "*.aud" -mtime +30 -type f | xargs rm -rf 其它类型的⽇志⽂件类似,替换为*.trc 即可
1
2
3
4
5
6
7
8$ adrci adrci> show home adrci> t homepath diag/rdbms/orcl/orcl1adrci> help purge # 可根据清理多少分钟前的数据,也可以show problem 查看⽇志中错误信息adrci> purge -age 14400 -type incident #14400的单位是分钟adrci> purge -age 14400 -type trace
1
2
3
4
5
6
12c以及以上版本部署purgeLogs⼯具 可能是oracle⾃⼰也知道从9i ~ 19c版本,⽇志位置不断变化,
⽇志也越来越多,翻不了了,官⽅出了专门清理⽇志的⼯具。
MOS⽂档:purgeLogs: Cleanup traces, logs in one command (Doc ID 2081655.1)
⼯具使⽤参考:adrci> show control #查看可以设置的策略adrci> help t control t control (SHORTP_POLICY = 720) #720的单位是⼩时
1
2
3Usage: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,oak 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 OAK/DCS logs and trace older then # days (Default 30 days) -extra '<folder>':<days> Purge only files in ur specified folders (Default 30 days) -aud Purge Audit logs bad on '-orcl <da
ys>' 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 ca 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:201
2
3
4
5
6
7
8
9
10
11
成都出国留学
12
13
14
15
16
17
18
19
20
21
22
23
迈克学摇滚24
25
26
27
28
29
30
boyhood
31mbp