跳转到主要内容

repl:流复制与同步状态诊断

检查同步备库配置、下游复制延迟及备库接收/回放进度。

读取 sys_stat_replication、同步配置(synchronous_standby_names / synchronous_commit)及备库接收/回放状态(sys_stat_wal_receiver、sys_is_wal_replay_paused());只读查询,绝不修改参数或启停回放。检查 repmgr 集群拓扑请用 kbdiag cluster。

延迟字节与消息时间仅反映采样状态;当主库长期无写事务时,备库 last replayed transaction 年龄也会持续增长而字节差为 0。

用法

kbdiag repl
kbdiag repl --json

常用参数

参数说明
--json输出结构化 JSON(repl.sync、inst.upstream、repl.replay、repl.downstreams)

判定与输出解读

  • WARN(exit=1):
    • inst.upstream:备库缺少 walreceiver 进程或断联超过 wal_receiver_timeout。
    • repl.replay_paused:备库处于 sys_wal_replay_pause() 暂停回放状态。
    • repl.sync_short:synchronous_commit 启用同步等待,但当前 sync / quorum 候选数少于配置要求。
  • UNKNOWN(exit=3):探针失败/跳过、同步名配置无法解析,或列状态被权限脱敏([REDACTED])。

实测示例(KES V9 备库,80 列)

repl  WARN  (standby, system@local, endpoint=/tmp/.s.KINGBASE.54321,
    2026-12-02T16:18:25Z)
[FINDINGS]
  WARN inst.upstream: the standby has no WAL receiver and is not receiving WAL
    from the primary: if the primary fails now, no standby can take over
[UPSTREAM]
  status    (no walreceiver process)
[REPLAY]
  received                   10/3F4D2A00
  replayed                   10/3F4D2A00  (caught up with what was received)
  last replayed transaction  2d 9h ago
  paused                     no
[DOWNSTREAMS]
  0
  No downstream replicas observed
[NEXT]
  verify: kbdiag slots  # run on the primary: is this standby's slot inactive?

关联命令

  • kbdiag cluster — repmgr 集群角色、单主识别与事件记录
  • kbdiag slots — 排查非活跃复制槽拉住 WAL 与 xmin
  • kbdiag wal — 排查 WAL 位点、sys_wal 体积与归档阻塞