130521建立AWR及AWR管理

1.創建snapshot

連接到:                    
OracleDatabase 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
 
SQL>select dbms_workload_repository.create_snapshot() as "snap_id" fromdual;
 
   snap_id
----------
       197

到em中查找該snapshot



點擊進去發現錯誤,懷疑是節點剛剛起來的原因:


重建新的snapshot:

 

SQL>select dbms_workload_repository.create_snapshot() as "snap_id" fromdual;
 
   snap_id
----------
       198

 



2.      通過存儲過程刪除snapshot

 

SQL>begin
  2 dbms_workload_repository.drop_snapshot_range(low_snap_id=>197,high_snap_id=>197);
  3  end;
  4  /


 

PL/SQL 過程已成功完成。

 

回到em中,已經不存在197的snapshot

 

此時點擊198,依然報錯:

 


 

證明snapshot是必須存在2個,相互對比看;

 

3.      報告中的elapsed time 報告逝去時間比較關鍵,通常情況下,需要看1個小時內的系統情況;

 

需要通過dbms_workload_repository包中的函數進行修改,經過查詢包中有modify_snapshot_settings函數

 

查詢文檔

 

Modifying Snapshot Settings

You can adjust the interval and retention of snapshot generation for aspecified database Id, but note that this can affect the precision of theOracle diagnostic tools.

The INTERVAL setting affects how often in minutesthat snapshots are automatically generated. The RETENTION setting affects how long in minutes that snapshots are stored in theworkload repository. To adjust the settings, use the MODIFY_SNAPSHOT_SETTINGS procedure. For example:

BEGIN

 DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention =>43200,

                 interval => 30, dbid =>3310949047);

END;

/

 

In this example, the retention period is specified as 43200 minutes (30days) and the interval between each snapshot is specified as 30 minutes. IfNULL is specified, the existing value is preserved. The optional databaseidentifier is 3310949047. If you do not specify a value for dbid, the local database identifier is used as the default value. You cancheck the current settings for your database instance with the DBA_HIST_WR_CONTROL view.

此處對elapse 理解有誤,之前以爲是報告執行消耗的時間,實際爲兩個snapshot之間的間隔時間duration;

 

The snapshotdetails

This is normallyshown at the beginning of the report.

1

2

3

4

5

6

        Snap Id      Snap Time   Sessions Curs/Sess

      --------- -------------- --------   -----

Begin Snap:4413 17-May-12 09:22:34   28   3.0

  End Snap:4414 17-May-12 09:43:35   29   3.3

   Elapsed:          21.02 (mins)

   DB Time:          21.78 (mins)

Note that unlikethe hourly usual sample, this sampling took 21 minutes to complete. Thesnapshots in this case were taken immediately before and after running thePL/SQL block.

Elapsed (time) isjust the interval of time between the start and end snapshots. Anotherimportant quantity is database DB Time which is the sum ofworking sessions’ time.  So DB Time =  sumof database CPU time + waits. In systems with multiple concurrentactive sessions DB Time can be larger than the elapsed time.This is because DB Time is a sum over all active sessionsthat are using CPU(s) or waiting for an event. Note that Backgroundprocesses are not included in that.

 

 

正常情況下系統每一個小時生成一次AWR報告,如果需要修改通過dbms_workload_repository.modify_snapshot_settings函數進行修改

 

之後查看系統每隔一小時自動生成的報告,可以看出elapse time=1小時,前後運行時間相隔一小時

 

 

4.       通過腳本預估AWR對sysaux表空間的數據空間佔用;utlsyxsz.sql -Utility script for SYSAUX Size

SQL> @D:\app\calvin\product\11.2.0\test\RDBMS\ADMIN\utlsyxsz.sql
 
 
This script estimates the space required for the SYSAUX tablespace.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Specify the Report File Name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is utlsyxsz.txt.  To use this name,
press <return> to continue, otherwise enter an alternative.
 
輸入 report_name 的值:  1
 
Using the report name 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SYSAUX Size Estimation Report
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Estimated at
11:38:25 on 5月  22, 2013 ( 星期三 ) in Timezone+08:00
 
 
DB_NAME     HOST_PLATFORM                             INSTSTARTUP_TIME      PA
----------- ---------------------------------------- ---------------------- --
* TEST      HOMEPC - MicrosoftWindows x86 64-bit        1 10:41:32(05/22)  NO
 
~~~~~~~~~~~~~~~~~~~~
Current SYSAUX usage
~~~~~~~~~~~~~~~~~~~~
| Total SYSAUX size:                         615.6 MB
|
| Total size of SM/AWR                        73.6 MB (  12.0% of SYSAUX )
| Total size of SM/OPTSTAT                    49.5 MB (   8.0% of SYSAUX )
| Total size of XDB                          128.1 MB (  20.8% of SYSAUX )
| Total size of EM                            95.9 MB (  15.6% of SYSAUX )
| Total size of SDO                           53.1 MB (   8.6% of SYSAUX )
| Total size of AO                            42.0 MB (   6.8% of SYSAUX )
| Total size of XSOQHIST                     42.0 MB (   6.8% of SYSAUX )
| Total size of SM/ADVISOR                    18.9 MB (   3.1% of SYSAUX )
| Total size of ORDIM/ORDDATA                 12.8 MB (   2.1% of SYSAUX )
| Total size of LOGMNR                         7.9 MB (   1.3% of SYSAUX )
| Total size of SM/OTHER                       7.5 MB (   1.2% of SYSAUX )
| Total size of XSAMD                          4.4 MB (   0.7% of SYSAUX )
| Total size of EXPRESSION_FILTER              3.6 MB (   0.6% of SYSAUX )
| Total size of TEXT                           3.5 MB (   0.6% of SYSAUX )
| Total size of SMON_SCN_TIME                  3.3 MB (   0.5% of SYSAUX )
| Total size of WM                             3.1 MB (   0.5% of SYSAUX )
| Total size of SQL_MANAGEMENT_BASE            1.7 MB (   0.3% of SYSAUX )
| Total size of PL/SCOPE                       1.6 MB (   0.3% of SYSAUX )
| Total size of LOGSTDBY                       1.4 MB (   0.2% of SYSAUX )
| Total size of EM_MONITORING_USER             1.4 MB (   0.2% of SYSAUX )
| Total size of STREAMS                        1.0 MB (   0.2% of SYSAUX )
| Total size of JOB_SCHEDULER                  0.7 MB (   0.1% of SYSAUX )
| Total size of ORDIM                          0.4 MB (   0.1% of SYSAUX )
| Total size of AUTO_TASK                      0.3 MB (   0.1% of SYSAUX )
| Total size of Others                        58.3 MB (   9.5% of SYSAUX )
|
 
~~~~~~~~~~~~~~~~~~~~
AWR Space Estimation
~~~~~~~~~~~~~~~~~~~~
 
| To estimate the size of the Automatic Workload Repository (AWR)
| in SYSAUX, we need the following values:
|
|     - Interval Setting(minutes)
|     - Retention Setting (days)
|     - Number of Instances
|     - Average Number of ActiveSessions
|     - Number of Datafiles
 
|
| For 'Interval Setting',
|   Press <return> to usethe current value:     60.0 minutes
|   otherwise enter analternative
|
輸入 interval 的值:  60
 
**   Value for 'IntervalSetting': 60
 
|
| For 'Retention Setting',
|   Press <return> to usethe current value:   8.00 days
|   otherwise enter analternative
|
輸入 retention 的值:  7
 
**   Value for 'RetentionSetting': 7
 
|
| For 'Number of Instances',
|   Press <return> to usethe current value:   1.00
|   otherwise enter analternative
|
輸入 num_instances 的值:  1
 
**   Value for 'Number of Instances':1
 
|
| For 'Average Number of Active Sessions',
|   Press <return> to usethe current value:   0.03
|   otherwise enter analternative
|
輸入 active_sessions 的值:  10
 
**   Value for 'Average Number ofActive Sessions': 10
 
| ***************************************************
| Estimated size of AWR:                     230.2 MB
|
|   The AWR estimate was computedusing
|   the following values:
|
|            Interval -        60 minutes
|           Retention -      7.00 days
|       Num Instances -         1
|     Active Sessions -     10.00
|           Datafiles -         7
| ***************************************************
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Optimizer Stat History Space Estimation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
| To estimate the size of the Optimizer Statistics History
| we need the following values:
|
|     - Number of Tables in theDatabase
|     - Number of Partitions inthe Database
|     - Statistics RetentionPeriod (days)
|     - DML Activity in theDatabase (level)
 
|
| For 'Number of Tables',
|   Press <return> to usethe current value:    143.0
|   otherwise enter analternative <a positive integer>
|
輸入 number_of_tables 的值:
 
**   Value for 'Number ofTables': 143
 
|
| For 'Number of Partitions',
|   Press <return> to usethe current value:   0.00
|   otherwise enter analternative <a positive integer>
|
輸入 number_of_partitions 的值:
 
**   Value for 'Number ofPartitions': 0
 
|
| For 'Statistics Retention',
|   Press <return> to use thecurrent value:     31.0 days
|   otherwise enter analternative <a positive integer>
|
輸入 stats_retention 的值:
 
**   Value for 'StatisticsRetention': 31
 
|
| For 'DML Activity',
|   Press <return> to usethe current value:        2<medium>
|   otherwise enter analternative <1=low, 2=medium, 3=high>
|
輸入 dml_activity 的值:
 
**   Value for 'DML Activity': 2
 
| ***************************************************
| Estimated size of Stats history             42.1 MB
|
|   The space for OptimizerStatistics history was
|   estimated using the followingvalues:
|
|                         Tables-     143
|                        Indexes-     355
|                        Columns-   1,182
|                     Partitions-       0
|          Indexes on Partitions-       0
|          Columns in Partitions-       0
|        Stats Retention in Days-      31
|          Level of DML Activity-  Medium
| ***************************************************
 
~~~~~~~~~~~~~~~~~~~~~~
Estimated SYSAUX usage
~~~~~~~~~~~~~~~~~~~~~~
 
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Estimated size of AWR:                     230.2 MB
|
|   The AWR estimate was computedusing
|   the following values:
|
|            Interval -        60 minutes
|           Retention -      7.00 days
|       Num Instances -         1
|     Active Sessions -     10.00
|           Datafiles -         7
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Estimated size of Stats history             42.1 MB
|
|   The space for OptimizerStatistics history was
|   estimated using the followingvalues:
|
|                         Tables-     143
|                        Indexes-     355
|                        Columns-   1,182
|                     Partitions-       0
|          Indexes on Partitions -       0
|          Columns in Partitions-       0
|        Stats Retention in Days-      31
|          Level of DML Activity-  Medium
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|   For all the other components,the estimate
|   is equal to the current spaceusage of
|   the component.
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| ***************************************************
| Summary of SYSAUX Space Estimation
| ***************************************************
 
| Est size of XDB                            128.1 MB
| Est size of EM                              95.9 MB
| Est size of SDO                             53.1 MB
| Est size of AO                              42.0 MB
| Est size of XSOQHIST                        42.0 MB
| Est size of SM/ADVISOR                      18.9 MB
| Est size of ORDIM/ORDDATA                   12.8 MB
| Est size of LOGMNR                           7.9 MB
| Est size of SM/OTHER                         7.5 MB
| Est size of XSAMD                            4.4 MB
| Est size of EXPRESSION_FILTER                3.6 MB
| Est size of TEXT                             3.5 MB
| Est size of SMON_SCN_TIME                    3.3 MB
| Est size of WM                               3.1 MB
| Est size of SQL_MANAGEMENT_BASE              1.7 MB
| Est size of PL/SCOPE                         1.6 MB
| Est size of LOGSTDBY                         1.4 MB
| Est size of EM_MONITORING_USER               1.4 MB
| Est size of STREAMS                          1.0 MB
| Est size of JOB_SCHEDULER                    0.7 MB
| Est size of ORDIM                            0.4 MB
| Est size of AUTO_TASK                        0.3 MB
| Est size of Others                          58.3 MB
 
| Est size of SM/AWR                         230.2 MB
| Est size of SM/OPTSTAT                      42.1 MB
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Total Estimated SYSAUX size:               764.8 MB
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ***************************************************
 
End of Report


 

5.       快照集baseline:將快照納入到快照集,則該快照就不會被MMON進程自動刪除,快照集是我們保留重要時間段的快照數據的一種方法,通過制定兩個快照的snap_id,從而將兩個快照id之間的所有快照數據定義成一個快照集。

快照集通常用於保存重要的快照數據,用於性能比較的,或者作爲基線的快照,因爲快照集中的快照數據可以一直保存,直到快照集被刪除。所創建的快照集可以通過dba_hist_baseline試圖中顯示出來,通過執行命令dbms_workload_repository.create_baseline存儲過程來創建快照集:如下

 系統中201和202是兩個連續的快照集

 SQL> begin

  2 dbms_workload_repository.create_baseline(
  3 start_snap_id=>201,
  4 end_snap_id=>202,
  5 baseline_name=>'my1');
  6  end;
  7  /


 查詢表



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章