运维实施工具 ( hguard ) 复制槽监控信息查询失败
·
环境
系统平台:银河麒麟 (鲲鹏)
版本:4.5.8
症状
数据库运维实施工具版本: hguard_v2.0.1_20251217
监控页面无复制槽相关数据展示
highgo_exporter报错日志示例
time=2026-02-02T09:45:21.455Z level=ERROR source=postgres_exporter.go:685 msg="error scraping dsn" err="queryNamespaceMappings returned 2 errors" dsn="postgresql://sysdba:PASSWORD_REMOVED@10.247.22.16:5866/highgo?sslmode=disable"
数据库报错示例
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 sysdba
highgo=# show compatible_db ;
compatible_db
---------------
mysql
(1 row)
解决方案
- 备份旧版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_NAME=postgresql://用户名:用户密码@localhost:端口号/数据库名?sslmode=disable
./highgo_exporter --web.listen-address=":9187" --collector.postmaster --extend.query-path="queries.yaml 的绝对路径" --no-collector.roles --no-collector.replication --log.level="error" &> highgo_exporter.log &
执行 tail -f /usr/local/exporter/highgo_exporter.log查看最新输出,没有level=ERROR的日志输出即为正常。
正常监控页面示例
鲲鹏昇腾开发者社区是面向全社会开放的“联接全球计算开发者,聚合华为+生态”的社区,内容涵盖鲲鹏、昇腾资源,帮助开发者快速获取所需的知识、经验、软件、工具、算力,支撑开发者易学、好用、成功,成为核心开发者。
更多推荐

所有评论(0)