生成AWR报告
性能调优·AWR报告
AWR (Automatic Workload Repository) 是自动负载信息库的英文缩写,AWR报告是Oracle 10g以后版本提供的一种性能收集和分析工具,能提供一个时间段内整个数据库资源使用情况的报告,通过报告可以了解数据库的整个运行情况,生成的报告包括多个部分。
AWR每小时进行采样一次,并将信息保存到磁盘中,并且保留7天,7天后旧的记录才会被覆盖。这些采样信息被保存在wrh$_active_session_history视图中。而这个采样频率(1小时)和保留时间(7天)是可以根据实际情况进行调整的。
1.切换到想要存放AWR报告的目录,进入数据库
[[email protected] ~]$ sqlplus / as sysdba
2.手动生成一个快照
快照系统每隔一个小时会自动生成一个,但是为了更加灵活,生成AWR报告时,可以手动生成一个快照
[email protected] orcl>execdbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
3.根据快照生成awr报表
[email protected] orcl>@?/rdbms/admin/awrrpt.sql
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
1467532482 ORCL 1 orcl
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
Enter value for report_type:enter 生成脚本类型
TypeSpecified: html
Instances in thisWorkload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
-------------------- ------------ ------------ ------------
* 1467532482 1ORCL orcl cuug
Using 1467532482for database Id
Using 1for instance number
Specify the numberof days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering thenumber of days (n) will result in the most recent
(n) days ofsnapshots being listed. Pressing <return>without
specifying anumber lists all completed snapshots.
Enter value fornum_days: enter 时间
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 357 确定起始时间填入snap_id,回车
Begin Snapshot Id specified: 357
Enter value for end_snap: 358 确定终止时间填入snap_id,回车
End Snapshot Idspecified: 358
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_357_358.html. To use this name,
press <return> to continue, otherwise enter analternative.
Enter value for report_name: enter 回车,代表名字默认为上边显示的格式,也可以按照自己喜欢的方式命名
静候一会之后,屏幕开始刷屏,开始生成AWR报告
4.将生成的AWR报告传到本地,用浏览器打开。