如何使用ADDM报告
原文链接:https://blog.csdn.net/qq_43012298/article/details/139457828
使用ADDM(Automatic Database Diagnostic Monitor)报告可以帮助数据库管理员(DBA)分析和优化数据库性能。以下是详细的步骤和代码,指导你如何生成和使用ADDM报告。
生成ADDM报告
连接到数据库
使用SQL*Plus或其他Oracle客户端工具连接到数据库。
sqlplus / as sysdba
1
运行ADDM报告脚本
Oracle提供了一个脚本addmrpt.sql,可以用来生成ADDM报告。该脚本通常位于$ORACLE_HOME/rdbms/admin目录下。
@?/rdbms/admin/addmrpt.sql
1
输入报告参数
运行脚本后,系统会提示输入报告的参数。以下是一个示例运行过程:
SQL> @?/rdbms/admin/addmrpt.sql
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
123456789 MYDB 1 mydb
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
The default report type is 'text'.
Enter 'html' for an HTML report, or 'text' for plain text
Enter value for report_type: text
Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed. Pressing <return> without
specifying a number lists all completed snapshots.
Enter value for num_days: 1
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- --------------- -----
mydb MYDB 1000 05-JUN-23 12:00 1
1001 05-JUN-23 13:00 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 1000
Enter value for end_snap: 1001
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is addmrpt_1_1000_1001.txt. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name:
使用ADDM报告
生成的ADDM报告会保存到指定的文件中,例如addmrpt_1_1000_1001.txt。以下是一个示例ADDM报告的部分内容,展示如何分析报告并采取优化措施。
示例ADDM报告内容
ADDM Report for Task 'TASK_1000_1001'
Analysis Period:
~~~~~~~~~~~~~~~~
Begin Snapshot: 1000
End Snapshot: 1001
Elapsed Time: 60 minutes
Findings:
~~~~~~~~~
1. High CPU Usage
Impact: 50% of total database time was spent on the CPU.
Recommendation:
- Investigate SQL statements with high CPU usage.
- Optimize application logic and SQL queries.
2. I/O Bottleneck
Impact: 30% of total database time was spent waiting for I/O.
Recommendation:
- Investigate I/O-intensive SQL statements.
- Consider adding more disks or using faster storage.
3. High Buffer Cache Misses
Impact: 15% of total database time was spent on buffer cache misses.
Recommendation:
- Increase the buffer cache size.
- Optimize SQL statements to reduce logical reads.
分析和优化步骤
根据ADDM报告中的建议,可以采取以下步骤进行优化:
高CPU使用率
调查高CPU使用率的SQL语句:
使用AWR报告或其他工具查找消耗CPU最多的SQL语句。
SELECT sql_id, cpu_time, elapsed_time, executions
FROM dba_hist_sqlstat
WHERE snap_id BETWEEN 1000 AND 1001
ORDER BY cpu_time DESC;
1
2
3
4
优化应用程序逻辑和SQL查询:
检查和优化这些SQL语句,减少CPU使用率。
I/O瓶颈
调查I/O密集型SQL语句:
使用AWR报告或其他工具查找I/O等待时间最长的SQL语句。
SELECT sql_id, disk_reads, elapsed_time, executions
FROM dba_hist_sqlstat
WHERE snap_id BETWEEN 1000 AND 1001
ORDER BY disk_reads DESC;
增加磁盘或使用更快的存储:
考虑增加磁盘数量或使用更快的存储设备,以减少I/O等待时间。
高缓冲区缓存未命中率
增加缓冲区缓存大小:
增加数据库缓冲区缓存的大小,以提高缓存命中率。
ALTER SYSTEM SET db_cache_size = NEW_SIZE SCOPE=BOTH;
1
优化SQL语句以减少逻辑读取:
检查和优化导致高缓冲区缓存未命中的SQL语句,减少逻辑读取次数。
总结
ADDM报告是Oracle数据库性能调优的重要工具。通过定期生成和分析ADDM报告,可以识别数据库中的性能瓶颈并采取优化措施。了解如何生成和使用ADDM报告,对于数据库管理员来说至关重要。




