Oracle 11g r1入門教程:AWR使用

來源:互聯網
上載者:User

一、 AWR使用
SQL>@?/rdbms/admin/awrrpt.sql

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'
輸入 report_type 的值:  
Type Specified:  html
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.
輸入 num_days 的值:  1
Listing the last day's Completed Snapshots
                                                        Snap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
orcl10g      ORCL10G            142 03 7月  2009 08:11     1
                                143 03 7月  2009 09:00     1
                                144 03 7月  2009 10:00     1
                                145 03 7月  2009 11:00     1
                                146 03 7月  2009 12:01     1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap 的值:  142
Begin Snapshot Id specified: 142
輸入 end_snap 的值:  146
End   Snapshot Id specified: 146
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_142_146.html.  To use this name,
press <return> to continue, otherwise enter an alternative.
輸入 report_name 的值:  /home/Oracle/awrrpt_1_142_146.html
Report written to /home/oracle/awrrpt_1_142_146.html

二、AWR管理
(1)關閉awr:
SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>0);
說明:把interval設為0則已經關閉awr功能。
驗證:
SQL> select * from dba_hist_wr_control;

      DBID    SNAP_INTERVAL        RETENTION          TOPNSQL
----------    ------------------- ------------------- ----------
 450641661    +40150 00:00:00.0   +00008 00:00:00.0   DEFAULT  


(2)開啟awr:
SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>5*24*60);

說明:收集間隔時間為30分鐘一次,並且保留5天時間(單位都是分鐘)
如果執行時報錯:
SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>5*24*60);
BEGIN dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>5*24*60); END;
*
ERROR at line 1:
ORA-13541: system moving window baseline size (691200) greater than retention (432000)
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 89
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 137
ORA-06512: at line 1

原因是系統設定的baseline size值(691200)大於此時設定的retention(432000),那麼此時有兩種方法解決:
方法1:增大retention值,也就是增大儲存天數,比如修改為:
SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>9*24*60);

PL/SQL procedure successfully completed.

驗證:
SQL> select * from dba_hist_wr_control;

      DBID    SNAP_INTERVAL        RETENTION          TOPNSQL
----------    ------------------- ------------------- ----------
450641661     +00000 00:30:00.0    +00009 00:00:00.0   DEFAULT


(3)查看快照記錄:
select * from sys.wrh$_active_session_history

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.