主库(db_unique_name = orcl)
备库(db_unique_name = orcldg)
1) 确认备库上的打开模式和数据库角色:
SQL> select inst_id, open_mode, database_role from gv$database order by 1;
INST_ID OPEN_MODE DATABASE_ROLE
---------- -------------------- ----------------
1 READ ONLY WITH APPLY PHYSICAL STANDBY
2) 在主库上
SYS$UMF 用户是默认具有访问系统级远程管理框架(RMF)视图和表的所有权限的数据库用户。RMF 中的所有 AWR 相关操作只能由 SYS$UMF 用户执行。
SYS$UMF 用户默认处于锁定状态,在部署RMF拓扑之前必须将其解锁:
SQL> alter user sys$umf identified by sysumf account unlock;
3) 在主库和备库之间分别创建database link:
在主库上
create database link db_pridb_to_stbdb CONNECT TO sys$umf IDENTIFIED BY sysumf using 'orcldg';
create database link db_stbdb_to_pridb CONNECT TO sys$umf IDENTIFIED BY sysumf using 'orcl';
验证
SQL> select dbid,open_mode,database_role,db_unique_name from v$database@db_pridb_to_stbdb union all select dbid,open_mode,database_role,db_unique_name from v$database@db_stbdb_to_pridb;
DBID OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME
---------- -------------------- ---------------- ------------------------------
1691191647 READ ONLY WITH APPLY PHYSICAL STANDBY orcldg
1691191647 READ WRITE PRIMARY orcl
4) 我们需要配置数据库节点以添加到拓扑中。必须为拓扑中的每个数据库节点分配唯一名称(默认为DB_UNIQUE_NAME):
在主库上
alter system set "_umf_remote_enabled"=TRUE scope=BOTH;
exec dbms_umf.configure_node ('orcl');
5) 把备库远程注册到主库。我们可以通过相应的database link注册它。
在备库上
exec dbms_umf.configure_node ('orcldg','db_stbdb_to_pridb');
6) 创建RMF拓扑:
在主库上
exec DBMS_UMF.create_topology ('Topology_1');
7) 验证到目前为止所完成的步骤:
set line 132
col topology_name format a15
col node_name format a15
SQL> select * from dba_umf_topology;
TOPOLOGY_NAME TARGET_ID TOPOLOGY_VERSION TOPOLOGY
--------------- ---------- ---------------- --------
Topology_1 1000269901 1 ACTIVE
SQL> select * from dba_umf_registration;
TOPOLOGY_NAME NODE_NAME NODE_ID NODE_TYPE AS_SO AS_CA STATE
--------------- --------------- ---------- ---------- ----- ----- --------------------
Topology_1 orcl 1000269901 0 FALSE FALSE OK
8) 注册备库到拓扑。
在主库上:
exec DBMS_UMF.register_node ('Topology_1', 'orcldg', 'db_pridb_to_stbdb', 'db_stbdb_to_pridb', 'FALSE', 'FALSE');
PL/SQL procedure successfully completed.
在节点上启用 AWR 服务:
exec DBMS_WORKLOAD_REPOSITORY.register_remote_database(node_name=>'orcldg');
验证
set line 132
col topology_name format a15
col node_name format a15
SQL> select * from dba_umf_topology;
TOPOLOGY_NAME TARGET_ID TOPOLOGY_VERSION TOPOLOGY
--------------- ---------- ---------------- --------
Topology_1 1000269901 4 ACTIVE
SQL> select * from dba_umf_registration;
TOPOLOGY_NAME NODE_NAME NODE_ID NODE_TYPE AS_SO AS_CA STATE
--------------- --------------- ---------- ---------- ----- ----- --------------------
Topology_1 orcl 1000269901 0 FALSE FALSE OK
Topology_1 orcldg 3013062590 0 FALSE FALSE OK
SQL> select * from dba_umf_service;
TOPOLOGY_NAME NODE_ID SERVICE
--------------- ---------- -------
Topology_1 3013062590 AWR
9) RMF创建远程快照
在主库上
exec dbms_workload_repository.create_remote_snapshot('orcldg');
我们需要运行至少两次来获取begin_snap和end_snap。
10) 收集awr报告
SQL> @?/rdbms/admin/awrrpti.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:
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ ---------- --------- ---------- ------
3013062590 1 ORCL orcl orcldg
* 1691191647 1 ORCL orcl orcl
Enter value for dbid: 3013062590
Using 3013062590 for database Id
Enter value for inst_num: 1
Using 1 for instance number
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.
Enter value for num_days: 1
Listing the last day's Completed Snapshots
Instance DB Name Snap Id Snap Started Snap Level
------------ ------------ ---------- ------------------ ----------
orcl ORCL 1 05 Nov 2024 11:02 1
2 05 Nov 2024 11:06 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 1
Begin Snapshot Id specified: 1
Enter value for end_snap: 2
End Snapshot Id specified: 2
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_1_2.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name:
|