1.WDR 说明
WDR(Workload Diagnosis Report:负载诊断报告)是openGauss的工作负载诊断报告,常用于判断openGauss长期性能问题。
1.1 WDR 数据来源
在启动WDR Snapshot功能后,会在用户表空间”pg_default”,数据库”postgres”下新建schema “snapshot”,用于持久化WDR快照数据。默认初始化用户或monadmin用户可以访问Snapshot Schema。
openGauss=# select relname from pg_class where relname like '%snap_%';
relname
----------------------------------------------
tables_snap_timestamp
snapshot
snapshot_pkey
snap_seq
snap_global_os_runtime
snap_global_os_runtime_idx
snap_global_os_threads
snap_global_os_threads_idx
snap_global_instance_time
snap_global_instance_time_idx
snap_summary_workload_sql_count
snap_summary_workload_sql_count_idx
……
snap_class_vital_info
snap_class_vital_info_idx
snap_global_record_reset_time
snap_global_record_reset_time_idx
snapshot_name
snapshot_sequence
gs_txn_snapshot
gs_txn_snapshot_time_csn_index
gs_txn_snapshot_csn_xmin_index
gs_txn_snapshot_xmin_index
snapshot
snapshot_pkey
snapshot_id_key
(129 rows)
WDR Snapshot 原信息表:
- SNAPSHOT.SNAPSHOT:该表记录当前系统中存储的WDR快照数据的索引信息、开始时间和结束时间。只能在系统库中查询到结果,在用户库中无法查询。
- SNAPSHOT.TABLES_SNAP_TIMESTAMP:该表记录所有存储的WDR snapshot中数据库、表对象、以及数据采集的开始和结束时间。
WDR Snapshot 数据表:
- WDR Snapshot数据表命名原则:snap_{源数据表}。
- WDR Snapshot数据表来源为DBE_PERF Schema下的视图。
DBE_PERF Schema内视图主要用来诊断性能问题。数据库安装后,默认只有初始用户具有模式dbe_perf的权限。若是由旧版本升级而来,为保持权限的前向兼容,模式dbe_perf的权限与旧版本保持一致。
DBE_PERF模式的视图命名规范如下:
- GLOBAL_开头的视图,代表从数据库节点请求数据,并将数据追加对外返回,不会处理数据。
- SUMMARY_开头的视图,代表是将openGauss内的数据概述,多数情况下是返回数据库节点(有时只有数据库主节点的)的数据,会对数据进行加工和汇聚。
- 非这两者开头的视图,一般代表本地视图,不会向其它数据库节点请求数据。
[dave@www.cndba.cn ~]$ gsql -d postgres -p 15500 -r
gsql ((openGauss 5.0.0 build a07d57c3) compiled at 2023-03-29 03:07:56 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=#
openGauss=# show search_path;
search_path
----------------
"$user",public
(1 row)
openGauss=# alter session set search_path='dbe_perf';
SET
openGauss=# show search_path;
search_path
-------------
dbe_perf
(1 row)
openGauss=# /d+
List of relations
Schema | Name | Type | Owner | Size | Storage | Description
----------+----------------------------------------+------+-------+---------+---------+-------------
dbe_perf | bgwriter_stat | view | omm | 0 bytes | |
dbe_perf | class_vital_info | view | omm | 0 bytes | |
dbe_perf | config_settings | view | omm | 0 bytes | |
dbe_perf | file_iostat | view | omm | 0 bytes | |
dbe_perf | file_redo_iostat | view | omm | 0 bytes | |
dbe_perf | global_bgwriter_stat | view | omm | 0 bytes | |
dbe_perf | global_candidate_status | view | omm | 0 bytes | |
……
dbe_perf | summary_statio_user_sequences | view | omm | 0 bytes | |
dbe_perf | summary_statio_user_tables | view | omm | 0 bytes | |
dbe_perf | summary_transactions_prepared_xacts | view | omm | 0 bytes | |
dbe_perf | summary_transactions_running_xacts | view | omm | 0 bytes | |
dbe_perf | summary_user_login | view | omm | 0 bytes | |
dbe_perf | summary_workload_sql_count | view | omm | 0 bytes | |
dbe_perf | summary_workload_sql_elapse_time | view | omm | 0 bytes | |
dbe_perf | summary_workload_transaction | view | omm | 0 bytes | |
dbe_perf | thread_wait_status | view | omm | 0 bytes | |
dbe_perf | transactions_prepared_xacts | view | omm | 0 bytes | |
dbe_perf | transactions_running_xacts | view | omm | 0 bytes | |
dbe_perf | user_login | view | omm | 0 bytes | |
dbe_perf | user_transaction | view | omm | 0 bytes | |
dbe_perf | wait_events | view | omm | 0 bytes | |
dbe_perf | wlm_user_resource_config | view | omm | 0 bytes | |
dbe_perf | wlm_user_resource_runtime | view | omm | 0 bytes | |
dbe_perf | workload_sql_count | view | omm | 0 bytes | |
dbe_perf | workload_sql_elapse_time | view | omm | 0 bytes | |
dbe_perf | workload_transaction | view | omm | 0 bytes | |
(176 rows)
openGauss=#
1.2 WDR 参数
WDR 有四个配置参数:
openGauss=# select name,setting,unit,source,short_desc from pg_settings WHERE NAME like '%wdr%';
name | setting | unit | source | short_desc
-----------------------------+---------+------+---------+---------------------------------------------------------------
enable_wdr_snapshot | off | | default | Enable wdr snapshot
wdr_snapshot_interval | 60 | min | default | Sets the interval for wdr snapshot in snapshot thread, in min
wdr_snapshot_query_timeout | 100 | s | default | Sets the timeout for wdr snapshot query, in seconds
wdr_snapshot_retention_days | 8 | | default | Sets the max time span for wdr snapshot, in seconds
(4 rows)
1.2.1 enable_wdr_snapshot 参数
控制是否开启数据库监控快照功能。可以配置为如下值:
- on:打开数据库监控快照功能(默认值)。
- off:关闭数据库监控快照功能。
注意:这里官方手册说默认值是on,但从实际查询看,是off。
1.2.2 wdr_snapshot_retention_days 参数
该参数用来控制快照数据的保留天数。当数据库运行过程期间所生成的快照量数超过保留天数内允许生成的快照数量的最大值(保留天数的分钟值 / 自动生成时间间隔的分钟值)时,系统将每隔wdr_snapshot_interval时间间隔,清理snapshot_id最小的快照数据。
取值范围:1~8。默认值:8
1.2.3 wdr_snapshot_query_timeout 参数
设置快照操作相关的sql语句的执行超时时间。如果语句超过设置的时间没有执行完并返回结果,则本次快照操作失败。
取值范围:100~INT_MAX(秒)。默认值:100s
1.2.4 wdr_snapshot_interval 参数
控制后台线程Snapshot自动对数据库监控数据执行快照操作的时间间隔。
取值范围:10~60(分钟)。默认60。
2. 启用并创建WDR
虽然openGauss 5.0.0 的官方手册里说默认启用了WDR,但实际查询看并没有启用,所有我们这里先启用WDR,然后创建快照。
设置参数:
[dave@www.cndba.cn ~]$ gs_guc reload -N all -I all -c "enable_wdr_snapshot=on"
The gs_guc run with the following arguments: [gs_guc -N all -I all -c enable_wdr_snapshot=on reload ].
Begin to perform the total nodes: 3.
Popen count is 3, Popen success count is 3, Popen failure count is 0.
Begin to perform gs_guc for datanodes.
Command count is 3, Command success count is 3, Command failure count is 0.
Total instances: 3. Failed instances: 0.
ALL: Success to perform gs_guc!
[dave@www.cndba.cn ~]$
查询快照:在启用WDR时会自动创建一个快照:
openGauss=# select * from snapshot.snapshot;
snapshot_id | start_ts | end_ts
-------------+-------------------------------+-------------------------------
1 | 2023-04-10 21:27:44.762183+08 | 2023-04-10 21:27:46.910949+08
(1 row)
默认1小时创建一个快照,我们这里先手工创建一个快照:
openGauss=# select create_wdr_snapshot();
create_wdr_snapshot
-----------------------------------------
WDR snapshot request has been submitted
(1 row)
openGauss=# select * from snapshot.snapshot;
snapshot_id | start_ts | end_ts
-------------+-------------------------------+-------------------------------
1 | 2023-04-10 21:27:44.762183+08 | 2023-04-10 21:27:46.910949+08
2 | 2023-04-10 21:28:48.693369+08 | 2023-04-10 21:28:50.80456+08
(2 rows)
openGauss=#
查询节点信息:
openGauss=# select * from pg_node_env;
node_name | host | process | port | installpath | datapat
h | log_directory
-------------------+----------------------------------------------------------------+---------+-------+-----------------------------+-------------------
--------------+---------------------------------
dn_6001_6002_6003 | localhost,192.168.56.105,172.31.101.17,10.1.192.89,10.1.200.30 | 9406 | 15500 | /data/openGauss/install/app | /data/openGauss/in
stall/data/dn | /var/log/omm/omm/pg_log/dn_6001
(1 row)
openGauss=#
格式化输出:/a: 不显示表行列符号, /t: 不显示列名 ,/o: 指定输出文件。
openGauss=# /a /t /o WDR_20220410.html
Output format is unaligned.
Showing only tuples.
创建WDR:
openGauss=# select generate_wdr_report(1,2,'all','cluster','dn_6001_6002_6003');
openGauss=# select generate_wdr_report(1,2,'all','node','dn_6001_6002_6003');
关闭格式化输出,也可以直接退出会话:
openGauss=# /o /a /t
Output format is aligned.
Tuples only is off.
openGauss=#
语法说明:
select generate_wdr_report(begin_snap_id bigint, end_snap_id bigint, report_type cstring, report_scope cstring, node_name cstring);
begin_snap_id:查询时间段开始的snapshot的id(表snapshot.snaoshot中的snapshot_id)
end_snap_id: 查询时间段结束snapshot的id。默认end_snap_id大于begin_snap_id(表snapshot.snaoshot中的snapshot_id)
report_type: 指定生成report的类型。例如,summary/detail/all,其中:summary[汇总数据]/detail[明细数据]/all[包含summary和detail]
report_scope: 指定生成report的范围,可以为cluster或者node,其中:cluster是数据库级别的信息,node是节点级别的信息。
node_name: 当report_scope指定为node时,需要把该参数指定为对应节点的名称。当report_scope为cluster时,该值可以省略或者指定为空或NULL。node[节点名称]、cluster[省略/空/NULL]
3.查看WDR 报告
WDR 里面内容比较多,主要包含如下分类:
- Database Stat 数据库维度性能统计信息:事务,读写,行活动,写冲突,死锁等。数据库范围报表,仅cluster模式下可查看此报表。
- Load Profile 数据库维度的性能统计信息:CPU时间,DB时间,逻辑读/物理读,IO性能,登入登出,负载强度,负载性能表现等。数据库范围报表,仅cluster模式下可查看此报表。
- Instance Efficiency Percentages 数据库级或者节点缓冲命中率。数据库、节点范围报表,cluster模式和node模式下均可查看此报表。
- Top 10 Events by Total Wait Time 最消耗时间的事件。节点范围报表,仅node模式下可查看此报表。
- Wait Classes by Total Wait Time 最消耗时间的等待时间分类。节点范围报表,仅node模式下可查看此报表。
- Host CPU 主机CPU消耗。节点范围报表,仅node模式下可查看此报表。
- IO Profile 数据库或者节点维度的IO的使用情况。数据库、节点范围报表,cluster模式和node模式下均可查看此报表。
- Memory Statistics 内核内存使用分布。节点范围报表,仅node模式下可查看此报表。
- Time Model 节点范围的语句的时间分布信息。节点范围报表,仅node模式下可查看此报表。
- SQL Statistics SQL语句各个维度性能统计,按以下维度排序展示:总时间、平均时间、CPU耗时、返回的行数、扫描的行数、执行次数、逻辑读、物理读。数据库、节点范围报表,cluster模式和node模式下均可查看此报表。
- Wait Events 节点级别的等待事件的统计信息。节点范围报表,仅node模式下可查看此报表。
- Cache IO Stats 用户的表、索引的IO的统计信息。数据库、节点范围报表,cluster模式和node模式下均可查看此报表。
- Utility status 复制槽和后台checkpoint的状态信息。节点范围报表,仅node模式下可查看此报表。
- Object stats 表、索引维度的性能统计信息。数据库、节点范围报表,cluster模式和node模式下均可查看此报表。
- Configuration settings 节点配置。节点范围报表,仅node模式下可查看此报表。
- SQL Detail SQL语句文本详情。数据库、节点范围报表,cluster模式和node模式下均可查看此报表。
官网对每个列都得含义有详细说明,可以直接查看:
https://docs.opengauss.org/zh/docs/5.0.0/docs/SQLReference/%E6%9F%A5%E7%9C%8BWDR%E6%8A%A5%E5%91%8A.html
版权声明:本文为博主原创文章,未经博主允许不得转载。