可以按照以下詳細步驟在PDB級別啟用和創建AWR報告。
1) 在PDB級別設置awr_pdb_autoflush_enabled=true:
alter session set container=ORA12CPDB4;
alter system set awr_pdb_autoflush_enabled=true;
2) 正確設置AWR快照
復制代碼
select * from cdb_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL CON_ID
2580889417 +40150 00:01:00.0 +00008 00:00:00.0 DEFAULT 6
##這里修改為60分鍾生成一次快照
execute dbms_workload_repository.modify_snapshot_settings(interval => 60);
select * from cdb_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL CON_ID
2580889417 +00000 01:00:00.0 +00008 00:00:00.0 DEFAULT 6
復制代碼
3) 另請將AWR_SNAPSHOT_TIME_OFFSET設置為1000000,以避免多個PDB同時創建快照時出現性能問題。
SQL> alter session set container=cdb$root;
SQL>alter system set awr_snapshot_time_offset=1000000 scope=both;
4) 等待1-2小時以自動生成快照:
select * from awr_pdb_snapshot;
或者您可以手動創建快照:
SQL> connect / as sysdba
SQL> alter session set container=ORA12CPDB4;
SQL> exec dbms_workload_repository.create_snapshot();
5.創建AWR報告:
sqlplus /nolog
SQL>connect / as sysdba
SQL>alter session set container=ORA12CPDB4
SQL>@/u01/app/oracle/product/12.2.0.1/db_1/rdbms/admin/awrrpt.sql
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
AWR reports can be generated in the following formats. Please enter the
name of the format at the prompt. Default value is 'html'.
'html' HTML format (default)
'text' Text format
'active-html' Includes Performance Hub active report
Enter value for report_type: html
old 1: select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual
new 1: select 'Type Specified: ',lower(nvl('html','html')) report_type from dual
Type Specified: html
Specify the location of AWR Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AWR_ROOT - Use AWR data from root (default)
AWR_PDB - Use AWR data from PDB
Enter value for awr_location: AWR_PDB
Location of AWR Data Specified: AWR_PDB
我這里是做pdb的awr,若是做cdb的awr那么選擇AWR_ROOT
6.兩個時段做awr比較
awrddrpt比較兩個awr報表的值
運行awrddrpt.sql腳本;
SQL>@/u01/app/oracle/product/12.2.0.1/db_1/rdbms/admin/awrddrpt.sql
-- The End --