运维实施工具 ( hguard ) 复制槽监控信息查询失败 文章目录环境症状问题原因解决方案环境系统平台银河麒麟 鲲鹏版本4.5.8症状数据库运维实施工具版本 hguard_v2.0.1_20251217监控页面无复制槽相关数据展示highgo_exporter报错日志示例time2026-02-02T09:45:21.455Z levelERROR sourcepostgres_exporter.go:685 msgerror scraping dsn errqueryNamespaceMappings returned 2 errors dsnpostgresql://sysdba:PASSWORD_REMOVED10.247.22.16:5866/highgo?sslmodedisable数据库报错示例2026-02-02 17:45:51.431 CST,sysdba,highgo,2659519,10.247.22.16:48368,69807024.2894bf,77,SELECT,2026-02-02 17:36:36 CST,20/119294,0,ERROR,XX000,unexpected non-SELECT command in SubLink,,,,,,select * from jsonb_to_recordset((select case when pg_is_in_recovery()t then [] else (select json_agg(row_to_json(result)) from (select slot_name,plugin,slot_type,database,active,restart_lsn,pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) as lag_size,case when wal.modification is not null then round(extract(epoch from((select modification from pg_ls_waldir() where name pg_walfile_name(pg_current_wal_lsn()))- wal.modification::timestamp))) else null end as lag_time from pg_replication_slots left join pg_ls_waldir() wal on pg_walfile_name(restart_lsn) wal.name) result) end)::jsonb) as rec(slot_name varchar,plugin varchar,slot_type text,database varchar,active bool,restart_lsn pg_lsn,lag_size numeric,lag_time numeric),,,问题原因因数据库配置compatible_db兼容参数导致查询失败示例# psql highgo sysdbahighgo# show compatible_db ;compatible_db---------------mysql(1row)解决方案备份旧版queries.yaml文件cd /usr/local/exporter mv queries.yaml queries_old.yaml上传新版queries.yaml文件见附件queries.zip# cd /usr/local/exporter # ll queries.yaml -rw-r--r-- 1 root root 11135 Feb 4 08:58 queries.yaml # md5sum queries.yaml 458a23ae6d2fbb82b1e5dd6a10879f40 queries.yaml上传queries.zip后校验md5结果应为458a23ae6d2fbb82b1e5dd6a10879f40重启highgo_exporter进程pkill highgo_exporter cd /usr/local/exporter export DATA_SOURCE_NAMEpostgresql://用户名:用户密码localhost:端口号/数据库名?sslmodedisable ./highgo_exporter --web.listen-address:9187 --collector.postmaster --extend.query-pathqueries.yaml 的绝对路径 --no-collector.roles --no-collector.replication --log.levelerror highgo_exporter.log 执行 tail -f /usr/local/exporter/highgo_exporter.log查看最新输出没有levelERROR的日志输出即为正常。正常监控页面示例