天天看點

Oracle 12C R2-新特性-ADG備庫支援AWR1 說明2 管理ADG備庫的AWR主要步驟

1 說明

Starting with Oracle Database 12c Release 2 (12.2), Automatic Workload Repository (AWR) data can be captured for Active Data Guard (ADG) standby databases. This feature enables analyzing any performance-related issues for ADG standby databases. 

從12.2開始,ADG備庫支援AWR。那麼就可以分析備庫的性能問題了。ADG備庫的快照叫遠端快照,一個目标庫用于存儲ADG備庫的快照資料。目标庫可以是ADG的主庫也可以是非ADG的資料庫,如果目标庫是ADG的主庫,即源庫,那麼主庫的快照則叫本地快照。

更多資訊,請檢視官方文檔:

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgdba/gathering-database-statistics.html#GUID-309C107F-DC42-4119-9904-9504E9748B84

目标庫是通過unique name或source name來識别源庫的。源庫需要配置兩個dblink,一個是目标庫指向源庫,一個是源庫指向目标庫。

可以根據計劃的時間間隔或手動擷取遠端快照。遠端快照通常由目标節點啟動。在目标庫建立快照之後,源庫通過dblink将快照資料推送到目标庫。

目标庫管理以下任務:

1 Registering sources

2 Assigning unique identifier for each source

33 Creating database links between destination and sources

4 Scheduling and initiating automatic snapshots for sources

5 Managing destination workload by coordinating snapshots among sources

6 Managing snapshot settings for each source

7 Assigning identifiers to newly generated snapshots

8 Partitioning the AWR tables

9 Storing the performance data in the local AWR

10 Purging the AWR data of destination and sources

源庫管理以下任務:

1 Storing its performance data in the local AWR

2 Sending its AWR data to the destination

3 Responding to service requests from the destination

4 Extracting the AWR data from the destination

2 管理ADG備庫的AWR主要步驟

2.1  配置RMF(Remote Management Framework)

Remote Management Framework(RMF)是用于為Oracle捕獲性能統計資料(AWR資料)。在12.2中RMF隻能用于ADG備庫和單執行個體環境的資料庫。

The RMF topology is a centralized architecture that consists of all the participating database nodes along with their metadata and connection information. The RMF topology has one database node, called destination, which is responsible for storing and managing performance data (AWR data) that is collected from the database nodes, called sources. A candidate destination is a source that can be configured in such way that it can replace the original destination, when the original destination is unavailable or is downgraded. A topology can have only one destination, and one or more candidate destinations. 

2.1.1 向RMF中添加資料庫節點

在本示例中有三個資料庫節點T,S0和S1。節點T是目标庫(ADG備庫),節點S0和S1是源庫(S1是備用源庫,當S0不可用時,S1将升為新的存儲AWR資料節點)

建立以下DBLINK

1 DBLINK_T_to_S0: T節點指向S0節點.

2 DBLINK_T_to_S1: T節點指向S1節點.

3 DBLINK_S0_to_T: S0節點指向T節點.

4 DBLINK_S0_to_S1: S0節點指向S1節點.

5 DBLINK_S1_to_T: S1節點指向T節點.

6 DBLINK_S1_to_S0: S1節點指向S0節點.  

/* Configure the nodes T, S0, and S1 by executing these procedures on the respective nodes */

 

   /* Execute this procedure on node T */

   SQL> exec DBMS_UMF.configure_node ('T');

 

   /* Execute this procedure on node S0 */

   SQL> exec DBMS_UMF.configure_node ('S0', 'DBLINK_S0_to_T');

 

   /* Execute this procedure on node S1 */

   SQL> exec DBMS_UMF.configure_node ('S1', 'DBLINK_S1_to_T');

 

   /* Execute all the following procedures on the destination node T */

 

   /* Create the topology 'Topology_1' */

   SQL> exec DBMS_UMF.create_topology ('Topology_1');

 

   /* Register the node S0 with the topology 'Topology_1' */

   SQL> exec DBMS_UMF.register_node ('Topology_1',

                                     'S0',

                                     'DBLINK_T_to_S0',

                                     'DBLINK_S0_to_T',

                                     'TRUE'  /* Set it as a source */,

                                     'FALSE' /* Set it as not a candidate destination */);

 

   /* Register the node S1 with the topology 'Topology_1' */

   SQL> exec DBMS_UMF.register_node ('Topology_1',

                                     'S1',

                                     'DBLINK_T_to_S1',

                                     'DBLINK_S1_to_T', 

                                     'TRUE'  /* Set it as a source */,

                                     'TRUE'  /* Set it as a candidate destination */);

 

   /* Register the database links between the nodes S0 and S1 in the topology 'Topology_1'. 

    * When destination T is unavailable at the time of failover, the source S0 can connect to

    * the candidate destination S1 using this database link.

    */

   SQL> exec DBMS_UMF.create_link ('Topology_1',

                                   'S0',

                                   'S1',

                                   'DBLINK_S0_to_S1',

                                   'DBLINK_S1_to_S0');

 

   /* Enable the AWR service on the node S0 in the topology 'Topology_1' */

   SQL> exec DBMS_WORKLOAD_REPOSITORY.register_remote_database(node_name=>'S0');

 

   /* Enable the AWR service on the node S1 in the topology 'Topology_1' */

   SQL> exec DBMS_WORKLOAD_REPOSITORY.register_remote_database(node_name=>'S1');           

注:禁用AWR服務

SQL> exec DBMS_WORKLOAD_REPOSITORY.unregister_remote_database(node_name)           

2.1.2 管理ADG角色轉換

在ADG主庫故障或者發生switchover情況時,會觸發ADG角色轉換。Oracle推薦在修改角色前做以下配置:

2.1.2.1 在源庫和備用源庫之間建立dblink,在所有源庫上執行

SQL> EXEC DBMS_UMF.CREATE_LINK (topology name, 
                                source name, --源庫
                                candidate destination name, --備用源庫
                                source to candidate destination database link,
                                candidate destination to source database link);           

2.1.2.2 建立AWR快照

為了在角色轉換後能夠為候選源庫生成AWR報告,在角色轉換之前至少為候選源庫建立一個快照點。

2.1.2.3 重新開機候選源庫以及所有源庫

2.1.2.4 執行角色轉換

SQL> EXEC DBMS_UMF.SWITCH_DESTINATION(topology name, force_switch=>FALSE);           

2.2  管理ADG備庫的快照

2.2.1 建立,修改,删除Remote Snapshots

#建立快照-本地

BEGIN
  DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/           

#建立快照-remote

BEGIN
  DBMS_WORKLOAD_REPOSITORY.CREATE_REMOTE_SNAPSHOT ();
END;
/           

#删除快照

BEGIN
  DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id  => 22, 
                                                high_snap_id => 32, 
                                                dbid         => 3310949047);
END;
/           

#修改快照設定

BEGIN
  DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 43200, 
                                                     interval  => 30, 
                                                     topnsql   => 100, 
                                                     dbid      => 3310949047);
END;
/           

2.2.2 檢視快照配置

SQL> select snap_interval, retention from DBA_HIST_WR_CONTROL; 

SNAP_INTERVAL               RETENTION 
--------------------------------------- 
+00000 01:00:00.0        +00008 00:00:00.0            

2.2.3 導出導入Remote快照

導出腳本:awrextr.sql

導入腳本:awrload.sql

具體示例,參考官方文檔:

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgdba/gathering-database-statistics.html#GUID-CC6A87BD-BFEA-4A1B-9FD1-3445DC11BE72

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgdba/gathering-database-statistics.html#GUID-C916E80F-B819-4452-ABFC-18CA70D8A501

2.3  檢視ADG備庫的AWR資料

2.3.1 通過AWR視圖來檢視AWR資料

以DBA_HIST開頭相關的視圖來檢視AWR資料。如下:

DBA_HIST View Description
DBA_HIST_ACTIVE_SESS_HISTORY Displays the history of the contents of the in-memory active session history for recent system activity.
DBA_HIST_BASELINE  Displays information about the baselines captured on the system, such as the time range of each baseline and the baseline type.
DBA_HIST_BASELINE_DETAILS Displays details about a specific baseline.
DBA_HIST_BASELINE_TEMPLATE  Displays information about the baseline templates used by the system to generate baselines.
DBA_HIST_CON_SYS_TIME_MODEL Displays historical system time model statistics, including OLAP timed statistics.
DBA_HIST_CON_SYSMETRIC_HIST Displays the historical information about the system metric values.
DBA_HIST_CON_SYSMETRIC_SUMM Displays history of the statistical summary of all the metric values in the system metrics for the long duration (60 seconds) group.
DBA_HIST_CON_SYSSTAT Displays historical system statistics, including OLAP kernel statistics.
DBA_HIST_CON_SYSTEM_EVENT Displays historical information about the total waits for an event.
DBA_HIST_DATABASE_INSTANCE Displays information about the database environment.
DBA_HIST_DB_CACHE_ADVICE  Displays historical predictions of the number of physical reads for the cache size corresponding to each row.
DBA_HIST_DISPATCHER Displays historical information for each dispatcher process at the time of the snapshot.
DBA_HIST_DYN_REMASTER_STATS  Displays statistical information about the dynamic remastering process.
DBA_HIST_IOSTAT_DETAIL  Displays historical I/O statistics aggregated by file type and function.
DBA_HIST_RSRC_PDB_METRIC Displays historical information about the Resource Manager metrics for pluggable databases (PDBs) for the past one hour.
DBA_HIST_RSRC_METRIC  Displays historical information about the Resource Manager metrics for consumer groups for the past one hour.
DBA_HIST_SHARED_SERVER_SUMMARY Displays historical information for shared servers, such as shared server activity, common queues and dispatcher queues.
DBA_HIST_SNAPSHOT  Displays information on snapshots in the system.
DBA_HIST_SQL_PLAN Displays the SQL execution plans.
DBA_HIST_WR_CONTROL Displays the settings for controlling AWR.
DBA_HIST_WR_SETTINGS Displays the settings and metadata of the AWR.

2.3.2 通過AWR報告來檢視AWR資料

關于AWR相關腳本說明:

Task SQL Script Description
Generating an AWR Report for the Local Database awrrpt.sql Generates an AWR report in HTML or text format that displays statistics from a range of snapshot IDs in the local database instance.
Generating an AWR Report for a Specific Database awrrpti.sql  Generates an AWR report in HTML or text format that displays statistics from a range of snapshot IDs in a specific database instance.
Generating an AWR Report for the Local Database in Oracle RAC awrgrpt.sql Generates an AWR report in HTML or text format that displays statistics from a range of snapshot IDs in the local database instance in an Oracle RAC environment.
Generating an AWR Report for a Specific Database in Oracle RAC awrgrpti.sql Generates an AWR report in HTML or text format that displays statistics from a range of snapshot IDs in a specific database instance in an Oracle RAC environment.
Generating an AWR Report for a SQL Statement on the Local Database awrsqrpt.sql Generates an AWR report in HTML or text format that displays statistics for a particular SQL statement from a range of snapshot IDs in the local database instance.
Generating an AWR Report for a SQL Statement on a Specific Database awrsqrpi.sql Generates an AWR report in HTML or text format that displays statistics for a particular SQL statement from a range of snapshot IDs in a specific database instance.

具體例子:

參考官方文檔:

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgdba/gathering-database-statistics.html#GUID-EB7B34CD-6F4B-4010-9A8A-E1C7B8F2F851

繼續閱讀