oracle10g提供了awr工具,貌似优于statspack。
查看awr采集参数
select * from dba_hist_wr_control;
DBID | SNAP_INTERVAL | RETENTION | TOPNSQL | |
---|---|---|---|---|
1 | 1299123719 | +00000 01:00:00.0 | +00007 00:00:00.0 | DEFAULT |
使用:
脚本位于D:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\awrrpt.sql.用来生成报告.
dba权限下执行脚本,提示选择报告格式,直接回车,默认html格式.
选择报告天数,会列出最近的几次快照,如果中间有空行的话说明数据库关闭过.
在生成报告时不能跨越这些关闭的时间段,否则报错.
输入文件名,即能生成报告文件.
修改参数
execute dbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>5*24*60);
间隔改为30分钟,保留5天. 间隔设为0则关闭自动捕捉快照.
手动生成快照
execute dbms_workload_repository.create_snapshot();
查看快照
select * from sys.wrh$_active_session_history
删除快照
execute dbms_workload_repository.drop_snapshot_range(low_snap_id=>1, high_snap_id=>20,dbid=>123);
创建基线
exec dbms_workload_repository.create_baseline(start_snap_id => 1003, end_snap_id => 1013, 'apply_interest_1');
删除基线
exec DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(baseline_name => 'apply_interest_1', cascade => FALSE);
将AWR数据导出并迁移到其它数据库以便于以后分析
SQL> execDBMS_SWRF_INTERNAL.AWR_EXTRACT(dmpfile => 'awr_data.dmp', mpdir =>'DIR_BDUMP', bid => 1003, eid => 1013);
2.9 迁移AWR数据文件到其他数据库
SQL> execDBMS_SWRF_INTERNAL.AWR_LOAD(SCHNAME => 'AWR_TEST', dmpfile =>'awr_data.dmp', dmpdir => 'DIR_BDUMP');
把AWR数据转移到SYS模式中:
SQL> exec DBMS_SWRF_INTERNAL.MOVE_TO_AWR(SCHNAME => 'TEST');
参考:http://wenku.baidu.com/view/0eae576eb84ae45c3b358cbe.html