12C關於CDB、PDB建立AWR的方法和總結

lusklusklusk發表於2020-02-20

官方文件



總結

1、12c中CDB建立AWR報告的生成方法和之前的版本一樣,CDB的AWR會記錄PDB的資訊,比如top sql裡面就多了一列PDB Name

2、12.2.0.1開始可以為PDB單獨建立AWR

3、為PDB單獨建立AWR,可以不做任何設定,直接進入該PDB,建立AWR的過程中location of AWR Data時只能選擇AWR_ROOT,此時該PDB的AWR使用的是CDB的快照dba_hist_snapshot,生成的AWR只有該PDB的資訊

4、為PDB單獨建立AWR,可以單獨對PDB做設定,設定該PDB的引數AWR_PDB_AUTOFLUSH_ENABLED、AWR_SNAPSHOT_TIME_OFFSET並重新設定PDB的快照生成方式(cdb_hist_wr_control.SNAP_INTERVAL欄位值不再出現40150),直接進入該PDB,建立AWR的過程中location of AWR Data時選擇AWR_ROOT或AWR_PDB都行,選擇AWR_ROOT此時該PDB的AWR使用的是CDB的快照dba_hist_snapshot,生成的AWR只有該PDB的資訊,選擇AWR_PDB此時該PDB的AWR使用的是PDB自己的快照awr_pdb_snapshot,生成的AWR只有該PDB的資訊



CDB建立AWR的方法

方法1

CDB$ROOT這個容器下執行

SQL> @?/rdbms/admin/awrrpt.sql


方法2

CDB$ROOT這個容器下執行

select * from dba_hist_snapshot order by 1 desc

select * from table(dbms_workload_repository.awr_report_html(DBID, INSTANCE_NUMBER, startsnapid,endsnapid))




PDB建立AWR的方法

方法1

無需對PDB做任何設定

SQL> alter session set container=PDB_NAME;

SQL> @?/rdbms/admin/awrrpt.sql 

備註:期間會出現如下提示, 只能選擇AWR_ROOT

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:



方法2

需要先對PDB做設定

alter session set container=PDB_NAME;

alter system set awr_pdb_autoflush_enabled=true;

select * from cdb_hist_wr_control;SNAP_INTERVAL欄位值出現了40150,具體為40150 00:01:00.0 +00008

execute dbms_workload_repository.modify_snapshot_settings(interval => 30);

select * from cdb_hist_wr_control;SNAP_INTERVAL欄位值不再出現40150,具體為+00000 00:30:00.0 +00008

alter system set AWR_SNAPSHOT_TIME_OFFSET=1000000


SQL> alter session set container=PDB_NAME;

SQL> @?/rdbms/admin/awrrpt.sql

備註:期間會出現如下提示, 可以選擇AWR_ROOT或AWR_PDB

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_ROOT表示使用CDB的snapshot即dba_hist_snapshot來匯出這個PDB的awr,選擇AWR_PDB表示使用PDB的snapshot即awr_pdb_snapshot來匯出這個PDB的awr。其中選擇AWR_ROOT匯出不是這個整個CDB和所有PDB的awr,僅僅匯出這個PDB的awr,但是使用的是CDB的snapshot



方法3

需要先對PDB做設定

alter session set container=PDB_NAME;

alter system set awr_pdb_autoflush_enabled=true;

select * from cdb_hist_wr_control;SNAP_INTERVAL欄位值出現了40150,具體為40150 00:01:00.0 +00008

execute dbms_workload_repository.modify_snapshot_settings(interval => 30);

select * from cdb_hist_wr_control;SNAP_INTERVAL欄位值不再出現40150,具體為+00000 00:30:00.0 +00008

alter system set AWR_SNAPSHOT_TIME_OFFSET=1000000


SQL> alter session set container=PDB_NAME;

SQL> select * from awr_pdb_snapshot order by 1 desc

SQL> select * from table(dbms_workload_repository.awr_report_html(DBID, INSTANCE_NUMBER, startsnapid,endsnapid))





The AWR_PDB_AUTOFLUSH_ENABLED initialization parameter enables you to specify whether to enable or disable automatic snapshots for all the PDBs in a CDB or for individual PDBs in a CDB. The automatic snapshot operations are enabled by default for a CDB, but are disabled by default for a PDB. To enable automatic snapshots for a PDB, the PDB administrator must connect to that PDB, set the value for the AWR_PDB_AUTOFLUSH_ENABLED parameter to true, and set the snapshot generation interval to a value greater than 0.

使用AWR_PDB_AUTOFLUSH_ENABLED初始化引數,您可以指定為CDB中的所有PDB還是CDB中的單個PDB啟用或禁用自動快照。 自動快照操作預設情況下為CDB啟用,但預設情況下為PDB禁用。 要為PDB啟用自動快照,PDB管理員必須連線到該PDB,將AWR_PDB_AUTOFLUSH_ENABLED引數的值設定為true,並將快照生成間隔設定為大於0的值。



AWR_PDB_AUTOFLUSH_ENABLED enables you to specify whether to enable or disable automatic Automatic Workload Repository (AWR) snapshots for all the PDBs in a CDB or for individual PDBs in a CDB.

The default value of AWR_PDB_AUTOFLUSH_ENABLED is false. Thus, by default, automatic AWR snapshots are disabled for all the PDBs in a CDB.

When you change the value of AWR_PDB_AUTOFLUSH_ENABLED in the CDB root, the new value takes effect in all the PDBs in the CDB.

Therefore, if you change the value of AWR_PDB_AUTOFLUSH_ENABLED in the CDB root to true, the value of AWR_PDB_AUTOFLUSH_ENABLED is also changed to true in all of the PDBs, so that automatic AWR snapshots are enabled for all the PDBs.

You can also change the value of AWR_PDB_AUTOFLUSH_ENABLED in any of the individual PDBs in a CDB, and the value that is set for each individual PDB will be honored. This enables you to enable or disable automatic AWR snapshots for individual PDBs.

When a new PDB is created, or a PDB from a previous database release is upgraded to the current database release, automatic AWR snapshots are enabled or disabled for the PDB based on the current value of AWR_PDB_AUTOFLUSH_ENABLED in the root.

AWR_PDB_AUTOFLUSH_ENABLED使您可以指定是為CDB中的所有PDB還是CDB中的單個PDB啟用或禁用自動自動工作負載儲存庫(AWR)快照。

AWR_PDB_AUTOFLUSH_ENABLED的預設值為false。因此,預設情況下,對CDB中的所有PDB禁用自動AWR快照。

當您更改CDB根目錄中的AWR_PDB_AUTOFLUSH_ENABLED的值時,新值將在CDB中的所有PDB中生效。

因此,如果將CDB根目錄中的AWR_PDB_AUTOFLUSH_ENABLED的值更改為true,則所有PDB中的AWR_PDB_AUTOFLUSH_ENABLED的值也將更改為true,以便為所有PDB啟用自動AWR快照。

您還可以在CDB中的任何單個PDB中更改AWR_PDB_AUTOFLUSH_ENABLED的值,並且將尊重為每個單個PDB設定的值。這使您可以為單個PDB啟用或禁用自動AWR快照。

建立新的PDB或將先前資料庫版本的PDB升級到當前資料庫版本時,將根據根目錄中AWR_PDB_AUTOFLUSH_ENABLED的當前值為PDB啟用或禁用自動AWR快照。



AWR_SNAPSHOT_TIME_OFFSET specifies an offset for the Automatic Workload Repository (AWR) snapshot start time.

AWR snapshots normally start at the top of the hour (12:00, 1:00, 2:00, and so on). This parameter allows DBAs to specify an offset for the AWR snapshot start time.

This is a useful parameter to avoid CPU spikes from multiple instances all starting their AWR snapshots at the same time. If you have a large system with many instances on it (like many Exadata installations), and you are experiencing such CPU spikes, this parameter can be very useful.

The parameter is specified in seconds. Normally, you set it to a value less than 3600. If you set the special value 1000000 (1,000,000), you get an automatic mode, in which the offset is based on the database name.

The automatic mode is an effective way of getting a reasonable distribution of offset times when you have a very large number of instances running on the same node.

AWR_SNAPSHOT_TIME_OFFSET指定自動工作量儲存庫(AWR)快照開始時間的偏移量。

AWR快照通常在小時的頂部(12:00、1:00、2:00等)開始。 此引數允許DBA為AWR快照開始時間指定偏移量。

這是一個有用的引數,可避免來自多個例項的CPU尖峰同時啟動它們的AWR快照。 如果您的大型系統上有許多例項(例如許多Exadata安裝),並且遇到了此類CPU高峰,則此引數可能非常有用。

以秒為單位指定引數。 通常,將其設定為小於3600的值。如果將特殊值設定為1000000(1,000,000),則會得到一種自動模式,在該模式下,偏移量基於資料庫名稱。

當您在同一節點上執行大量例項時,自動模式是一種有效分配偏移時間的有效方法。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30126024/viewspace-2676484/,如需轉載,請註明出處,否則將追究法律責任。

相關文章