跳转到主要内容

cluster:repmgr 集群拓扑与同步模式

默认连接 esrep 库核对 repmgr 节点拓扑、本节点角色一致性、repmgr.conf 同步配置及最近事件。

默认连接 esrep 库读取外部 repmgr 元数据,对照数据库真实恢复角色识别当前节点,检查本机 repmgr.conf 同步策略,并展示最近事件。只读检查:不提升主库、不重连节点,也不跨机访问。

用法

kbdiag cluster
kbdiag cluster --events-limit 0
kbdiag cluster --json

常用参数

参数说明
-d <db>指定读取 repmgr 元数据的库名(默认优先选择 esrep)
--events-limit <n>限制文本输出的事件条数(默认 5,0 显示全部已采集事件)
--json输出结构化 JSON(cluster.nodes、cluster.sync、cluster.events、inst.downstreams)

判定与输出解读

  • WARN(exit=1):cluster.primaries(repmgr 记录多个活跃主库)、cluster.role_mismatch(repmgr 角色与内核恢复状态冲突)、cluster.inactive(存在非活跃节点)、cluster.detached(repmgr 显示活跃备库但主库无对应流复制连接),或 cluster.sync_degraded(repmgr.conf 配置同步模式但 synchronous_standby_names 为空)。
  • UNKNOWN(exit=3):无法匹配本节点、权限不足(如 kbdiag_ro)、无法读取本机 repmgr.conf(包括远程 TCP 连接跳过本机文件读取)或主库下游复制采集失败;窄终端下 [NODES] 与 [EVENTS] 自动切换紧凑卡片。
  • OK(exit=0):repmgr 拓扑、内核主备角色与同步模式一致,或当前库未安装 repmgr 元数据 schema(计为 not_applicable)。

实测示例(KES V9 主库节选,80 列)

cluster  OK  (primary, system@local, endpoint=/tmp/.s.KINGBASE.54321, db=esrep,
    2026-12-03T03:48:08Z)
[IDENTIFICATION]
  local identification: recovery role=primary matched the single active primary
    in repmgr.nodes (fallback; no repmgrd ID/primary_slot_name match)
[NODES]
  2  (repmgr metadata in database esrep)
  id  name   type     upstream  active  priority  location  slot
  1   node1  primary  -         yes     100       default   repmgr_slot_1
  2   node2  standby  node1     yes     100       default   repmgr_slot_2
  this node is node1: repmgr says primary, the database is a primary
  attached here: node2
[SYNCHRONOUS]
  repmgr.conf                async  (/data/kingbase/app/Server/bin/../etc/repmgr
    .conf)
  synchronous_standby_names  (empty: asynchronous)
[EVENTS]
  showing 3 of 20 collected (latest first; --events-limit 0 shows all collected)
  2026-11-28T00:04:35Z  node1  child_node_reconnect  ok=yes
    standby node "node2" (ID: 2) has reconnected after 1384 seconds
  ...

关联命令

  • kbdiag repl — 查看内核流复制连接与回放延迟
  • kbdiag slots — 检查承载集群备库的物理/逻辑复制槽
  • kbdiag wal — 查看 WAL 保留与归档状态