oracle awr报告提取,oracle AWR报告提取分析
Oracle在10g以前的使用的是Statspack做性能故障診斷的。Oracle Database 10g提供了一個顯著改進的工具:自動工作負載信息庫(AWR)。AWR和數據庫一起安裝。數據庫裝好后,快照由一個稱為MMON的新的后臺進程及其從進程自動地每小時采集一次(snap)1.查看當前的AWR保存策略、設置:快照間隔、保存時間。
SQL> col SNAP_INTERVAL format a20
SQL> col RETENTION format a20
SQL> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL
---------- -------------------- -------------------- ----------
262089084 +00000 01:00:00.0 +00007 00:00:00.0 DEFAULT
以上結果表示,每小時產生一個SNAPSHOT,保留7天。
2.調整AWR配置,修改快照間隔和保存時間等。AWR配置都是通過dbms_workload_repository包進行配置。
2.1調整AWR產生snapshot的頻率和保留策略,如將收集間隔時間改為30分鐘一次。并且保留5天時間(單位都是分鐘):SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>5*24*60);
設置快照時間間隔為20分鐘,保留時間為兩天--您可以發出以下命令。參數以分鐘為單位。SQL>exec dbms_workload_repository.modify_snapshot_settings ( interval => 20, retention => 2*24*60 );
2.2關閉AWR,把interval設為0則關閉自動捕捉快照.SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>0);
2.3手工創建一個快照SQL> exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();
exec dbms_workload_repository.create_snapshot;
2.4查看快照SQL> select * from sys.wrh$_active_session_history;
SQL> select count(*),max(snap_id) from wrh$_active_session_history;
2.5手工刪除指定范圍的快照SQL> exec DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE(low_snap_id => 973, high_snap_id => 999, dbid => 262089084);
2.6創建baseline,保存這些數據用于將來分析和比較SQL> exec dbms_workload_repository.create_baseline(start_snap_id=> 1003, end_snap_id=> 1013, 'apply_interest_1');
2.7刪除baseline
SQL> exec DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(baseline_name=> 'apply_interest_1', cascade=> FALSE);
2.8將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');
1,登陸Oracle數據庫:
sqlplus / as sysdba
2,在sqlplus中,以sys用戶運行下面的命令,生成第一份性能數據快照:
exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (flush_level=>'ALL');
注:flush_level=>‘ALL/TYPICAL’,默認是typical,在選擇snapshot時level顯示是1,all顯示是2.
3,運行你找到的所有或很多性能較差的應用或SQL,讓系統壓力始終處于比較高的狀態(如CPU或IO的使用),并保持此狀態達到半小時到1小時
4,在sqlplus中,以sys用戶再次運行下面的命令,生成第二份性能數據快照:
exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (flush_level=>'ALL');
5,在sqlplus中,以sys用戶運行下面的命令,以產生性能報告:
@?/rdbms/admin/awrrpt.sql
根據提示,選擇上面生成的2個性能數據快照,最后會生成一個最終的AWR性能報告。
1、如果不在oracle用戶下請切換到oracle用戶su – oracle
$ cd $ORACLE_HOME/rdbms/admin
2、以sysdba權限登錄數據庫sqlplus "/as sysdba"
3、執行awrprt命令SQL> @?/rdbms/admin/awrrpt.sql
4、出現選擇awr的輸出格式界面(默認選HTML比較直觀)-----------------------------------------------
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
2566595041 samp 2 samp2
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: html
Type Specified: html
-----------------------------------------------
5、選擇采集日期間隔(下述samp1samp2是RAC節點的兩個實例)
-----------------------------------------------
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 2566595041 2 samp samp2 p650b
2566595041 1 samp samp1 p650a
Using 2566595041 for database Id
Using 2 for instance number
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?without
specifying a number lists all completed snapshots.
選擇時間范圍Enter value for num_days: 1
------------------------------------------------
6、選擇開始和結束采集點30132-30148
------------------------------------------------
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
samp2 samp 30132 13 Aug 2010 00:00 1
30133 13 Aug 2010 01:00 1
30134 13 Aug 2010 02:00 1
30135 13 Aug 2010 03:00 1
30136 13 Aug 2010 04:00 1
30137 13 Aug 2010 05:00 1
30138 13 Aug 2010 06:00 1
30139 13 Aug 2010 07:00 1
30140 13 Aug 2010 08:00 1
30141 13 Aug 2010 09:00 1
30142 13 Aug 2010 10:00 1
30143 13 Aug 2010 11:00 1
30144 13 Aug 2010 12:00 1
30145 13 Aug 2010 13:00 1
30146 13 Aug 2010 14:00 1
30147 13 Aug 2010 15:00 1
30148 13 Aug 2010 16:00 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 30132
Begin Snapshot Id specified: 30132
Enter value for end_snap: 30148
End Snapshot Id specified: 30148
------------------------------------------------
7、指定輸出地址和名稱/tmp/awrrpt_2_30132_30148.html
------------------------------------------------
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_2_30132_30148.html. To use this name,
press?to continue, otherwise enter an alternative.
Enter value for report_name:/tmp/awrrpt_2_30132_30148.html
------------------------------------------------
8、生成過程----屏幕打印一堆html代碼------------------------------------------------
Using the report name /tmp/awrrpt_2_30132_30148.html
總結
以上是生活随笔為你收集整理的oracle awr报告提取,oracle AWR报告提取分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab下三维dla模型模拟,Mat
- 下一篇: php每个月头一天与最后一天,PHP获取