1.什么是ADR
ADR是Automatic Diagnostic Repository首字母缩写,它是一个数据库外的基于文件的、并且可以通过事件编号检索和分析的存储库。
故障诊断基础设施有助于预防、检测、诊断和解决问题。 特别针对的问题是严重错误,例如由代码错误、元数据损坏和客户数据损坏引起的错误。当发生严重错误时,会为其分配一个事件编号,并且会立即捕获该错误的诊断数据(例如跟踪文件)并使用该编号进行标记。 然后将数据存储在自动诊断存储库 (ADR) 中。
2. 数据库实例的 ADR 目录结构
Oracle Client 的每个安装都包含一个 ADR,用于与任何 Oracle Client 组件中的严重故障相关的诊断数据。 ADRCI 实用程序随 Oracle Client 一起安装,以便您可以检查诊断数据并将其打包以使其能够上传到 Oracle Support。
V$DIAG_INFO 视图列出了当前 Oracle 数据库实例的所有重要 ADR 位置。
$ sqlplus / as sysdba
SQL> SET LINES 300 PAGES 999
SQL> COL NAME FOR A30
SQL> COL VALUE FOR A80
SQL> SELECT * FROM v$diag_info;INST_ID NAME VALUE CON_ID
---------- ------------------------------ -------------------------------------------------------------------------------- ----------1 Diag Enabled TRUE 01 ADR Base /home/oracle/app/oracle 01 ADR Home /home/oracle/app/oracle/diag/rdbms/study/study 01 Diag Trace /home/oracle/app/oracle/diag/rdbms/study/study/trace 01 Diag Alert /home/oracle/app/oracle/diag/rdbms/study/study/alert 01 Diag Incident /home/oracle/app/oracle/diag/rdbms/study/study/incident 01 Diag Cdump /home/oracle/app/oracle/diag/rdbms/study/study/cdump 01 Health Monitor /home/oracle/app/oracle/diag/rdbms/study/study/hm 01 Default Trace File /home/oracle/app/oracle/diag/rdbms/study/study/trace/study_ora_232788.trc 01 Active Problem Count 4 01 Active Incident Count 252 011 rows selected.
3. incident
每当一个错误发生的时候,oracle会创建一个incident,并且分配一个INCIDENT_ID号,同时在ADR HOME的INCIDENT目录中创建相应的INCIDENT目录,每个错误号一个INCIDENT目录,目录被命名为incdir_<INCIDENT_ID>。在incident 目录下含有相应的DUMP文件。
4.清理过程
4.1. 登录Oracle用户
su - oracle
4.2. 进入adrci工具界面
$ adrciADRCI: Release 12.1.0.2.0 - Production on Tue Dec 31 15:38:13 2024Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.ADR base = "/home/oracle/app/oracle"
4.3. 查看Oracle目录,并设定某个数据库实例的目录
adrci> show home
ADR Homes:
diag/rdbm/study/study
diag/rdbms/study1/study1
diag/tnslsnr/10/listener
diag/tnslsnr/TEST/listener
diag/tnslsnr/test/listeneradrci> set homepath diag/rdbms/study/study
adrci> show home
ADR Homes:
diag/rdbms/study/study
4.4. 查看incident目录
adrci> show incidentADR Home = /home/oracle/app/oracle/diag/rdbms/wind2/wind2:
*************************************************************************
INCIDENT_ID PROBLEM_KEY CREATE_TIME
-------------------- ----------------------------------------------------------- ----------------------------------------
499511 ORA 445 2024-01-02 15:11:22.763000 +08:00
743529 ORA 1578 2024-10-30 15:22:15.969000 +08:00
741977 ORA 1578 2024-10-30 15:47:10.995000 +08:00
743553 ORA 1578 2024-10-30 15:51:12.822000 +08:00
743530 ORA 1578 2024-10-30 15:53:20.601000 +08:00
743554 ORA 1578 2024-10-30 15:57:53.782000 +08:00
739409 ORA 700 [kskvmstatact: excessive swapping observed] 2024-10-30 16:30:41.025000 +08:00
740866 ORA 1578 2024-10-30 16:36:04.656000 +08:00
740497 ORA 1578 2024-10-30 16:36:04.656000 +08:00
740545 ORA 1578 2024-10-30 16:36:04.656000 +08:00
743538 ORA 1578 2024-10-30 16:36:04.664000 +08:00
740569 ORA 1578 2024-10-30 16:36:04.666000 +08:00
741762 ORA 1578 2024-10-30 23:34:26.715000 +08:00
741713 ORA 1578 2024-10-31 10:05:54.992000 +08:00
741905 ORA 1578 2024-10-31 10:05:54.992000 +08:00
741849 ORA 1578 2024-10-31 10:05:55.002000 +08:00
741897 ORA 1578 2024-10-31 13:25:12.910000 +08:00
741889 ORA 1578 2024-10-31 14:26:10.802000 +08:00
741857 ORA 1578 2024-10-31 14:26:10.802000 +08:00
741906 ORA 1578 2024-10-31 16:37:36.944000 +08:00
741907 ORA 1578 2024-10-31 19:47:29.849000 +08:00
741953 ORA 1578 2024-10-31 19:59:33.125000 +08:00
741969 ORA 1578 2024-10-31 19:59:33.125000 +08:00
741961 ORA 1578 2024-10-31 21:14:31.297000 +08:00
741898 ORA 1578 2024-10-31 21:14:31.297000 +08:00
740553 ORA 1578 2024-10-31 22:10:45.115000 +08:00
740570 ORA 1578 2024-10-31 22:23:38.598000 +08:00
740571 ORA 1578 2024-10-31 22:23:44.042000 +08:00
739649 ORA 1578 2024-10-31 22:26:17.304000 +08:00
739650 ORA 1578 2024-10-31 22:26:38.796000 +08:00
739651 ORA 1578 2024-10-31 22:29:11.709000 +08:00
741899 ORA 1578 2024-11-01 01:13:36.174000 +08:00
741890 ORA 1578 2024-11-01 04:21:29.424000 +08:00
741891 ORA 1578 2024-11-01 08:26:40.768000 +08:00
740953 ORA 1578 2024-11-01 09:00:38.717000 +08:00
740849 ORA 1578 2024-11-01 12:21:17.871000 +08:00
740625 ORA 1578 2024-11-01 14:02:47.300000 +08:00
742025 ORA 1578 2024-11-01 14:02:47.397000 +08:00
742057 ORA 1578 2024-11-01 14:05:32.379000 +08:00
740633 ORA 1578 2024-11-01 14:05:32.398000 +08:00
740842 ORA 1578 2024-11-01 22:11:18.694000 +08:00
740869 ORA 1578 2024-11-01 22:23:26.136000 +08:00
740870 ORA 1578 2024-11-01 22:23:29.618000 +08:00
741901 ORA 1578 2024-11-02 00:08:18.884000 +08:00
740617 ORA 1578 2024-11-02 06:16:14.753000 +08:00
740626 ORA 1578 2024-11-02 06:35:57.684000 +08:00
740627 ORA 1578 2024-11-02 10:01:37.216000 +08:00
740634 ORA 1578 2024-11-02 10:07:01.673000 +08:00
740889 ORA 1578 2024-11-02 14:07:30.587000 +08:00
740833 ORA 1578 2024-11-02 18:08:15.765000 +08:00
First 50 rows fetched (*** more available ***)
4.5. 清理过期的incident文件
清理7天前的incident问题文件(7天 × 24小时 × 60分钟 = 10080 分钟)
adrci> help purge
adrci> purge -age 10080 -type incident
删除需要一些时间,请耐心等待。
若想清理7天前的incident问题文件可执行如下命令:
adrci> purge -age 14400 -type trace
4.6. 在adrci中设置trace文件保留的策略
我们还可以设置trace文件的保留策略,如设置保留7天:
adrci> show control #查看可以设置的策略
adrci> help set control
set control (SHORTP_POLICY = 168) #单位是小时
4.7. 退出adrci工具
adrci> exit
参考文章:http://dba.qishuo.xin/?p=589