跳转到主要内容

描述

包含本地服务器上复制表的信息和状态。 此表可用于监控。表中每个 Replicated* 表对应一行。

  • database (String) — 数据库名称。
  • table (String) — 表名称。
  • uuid (UUID) — 表 UUID。
  • engine (String) — 表引擎名称。
  • is_leader (UInt8) — 该副本是否为 leader。多个副本可以同时是 leader。可以使用 merge_tree 设置 replicated_can_become_leader 来阻止副本成为 leader。leader 负责调度后台合并。请注意,无论副本是否为 leader,只要它可用且在 ZK 中有会话,就可以向其执行写入。
  • can_become_leader (UInt8) — 该副本是否可以成为 leader。
  • is_readonly (UInt8) — 该副本是否处于只读模式。如果 config 中没有 ClickHouse Keeper 相关 section、在 ClickHouse Keeper 中重新初始化会话时发生未知错误,或者正处于 ClickHouse Keeper 会话重新初始化期间,都会启用此模式。
  • readonly_start_time (Nullable(DateTime)) — 副本进入 readonly 模式时的 timestamp。如果副本不处于 readonly 模式,则为 NULL。
  • is_session_expired (UInt8) — 与 ClickHouse Keeper 的会话是否已过期。基本上与 is_readonly 相同。
  • future_parts (UInt32) — 尚未完成的 INSERT 或合并完成后将会出现的数据分区片段数量。
  • parts_to_check (UInt32) — 队列中等待校验的数据分区片段数量。如果怀疑某个分片可能已损坏,就会将其放入校验队列。
  • zookeeper_name (String) — 存储该表 metadata 的 [Zoo]Keeper 集群名称 (可能是辅助集群)
  • zookeeper_path (String) — ClickHouse Keeper 中表数据的 path。
  • replica_name (String) — ClickHouse Keeper 中的副本名称。同一张表的不同副本名称不同。
  • replica_path (String) — ClickHouse Keeper 中副本数据的 path。等同于拼接 ‘zookeeper_path/replicas/replica_path’。
  • columns_version (Int32) — 表结构的版本号。表示执行了多少次 ALTER。如果各副本的版本不同,说明某些副本尚未完成全部 ALTER。
  • queue_size (UInt32) — 等待执行的操作队列大小。操作包括插入数据块、合并以及其他一些操作。它通常与 future_parts 一致。
  • inserts_in_queue (UInt32) — 需要执行的数据块插入数量。插入通常会很快完成复制。如果这个数字很大,则说明出现了问题。
  • merges_in_queue (UInt32) — 等待执行的合并数量。有时合并会持续较长时间,因此该值可能会长时间大于零。
  • part_mutations_in_queue (UInt32) — 等待执行的变更数量。
  • queue_oldest_time (DateTime) — 如果 queue_size 大于 0,则显示队列中最早加入的操作的时间。
  • inserts_oldest_time (DateTime) — 参见 queue_oldest_time
  • merges_oldest_time (DateTime) — 参见 queue_oldest_time
  • part_mutations_oldest_time (DateTime) — 参见 queue_oldest_time
  • oldest_part_to_get (String) — 需要从其他副本拉取的分片名称,取自复制队列中最早的 GET_PARTS 条目。
  • oldest_part_to_merge_to (String) — 从复制队列中最早的 MERGE_PARTS 条目获取的合并目标结果 part 名称。
  • oldest_part_to_mutate_to (String) — 从复制队列中最早的 MUTATE_PARTS 条目获取的变更目标结果 part 名称。
  • log_max_index (UInt64) — 常规活动日志中的最大条目编号。此列以及后面三列 (log_pointertotal_replicasactive_replicas) 仅在与 ClickHouse Keeper 存在活动 session 时才为非零值。
  • log_pointer (UInt64) — 副本已复制到其执行队列中的常规活动日志最大条目编号加一。如果 log_pointer 远小于 log_max_index,则说明存在问题。
  • last_queue_update (DateTime) — 队列上次更新的时间。
  • absolute_delay (UInt64) — 当前副本的延迟秒数。
  • total_replicas (UInt32) — 此表已知副本的总数。
  • active_replicas (UInt32) — 此表在 ClickHouse Keeper 中拥有 session 的副本数量 (即正常运行的副本数量) 。
  • lost_part_count (UInt64) — 自表创建以来,该表所有副本累计丢失的数据 parts 数量。该值持久保存在 ClickHouse Keeper 中,并且只能增加。
  • last_queue_update_exception (String) — 队列包含损坏条目时的异常信息。当 ClickHouse 在不同版本之间破坏向后兼容性,导致较新版本写入的 log entries 无法被旧版本 parse 时,这一点尤为重要。
  • zookeeper_exception (String) — 从 ClickHouse Keeper 拉取信息时如果发生 error,则记录最后一条异常消息。
  • replica_is_active (Map(String, UInt8)) — 副本名称与其是否处于活动状态之间的 Map。

示例

SELECT *
FROM system.replicas
WHERE table = 'test_table'
FORMAT Vertical
Query id: dc6dcbcb-dc28-4df9-ae27-4354f5b3b13e

Row 1:
───────
database:                    db
table:                       test_table
engine:                      ReplicatedMergeTree
is_leader:                   1
can_become_leader:           1
is_readonly:                 0
is_session_expired:          0
future_parts:                0
parts_to_check:              0
zookeeper_path:              /test/test_table
replica_name:                r1
replica_path:                /test/test_table/replicas/r1
columns_version:             -1
queue_size:                  27
inserts_in_queue:            27
merges_in_queue:             0
part_mutations_in_queue:     0
queue_oldest_time:           2021-10-12 14:48:48
inserts_oldest_time:         2021-10-12 14:48:48
merges_oldest_time:          1970-01-01 03:00:00
part_mutations_oldest_time:  1970-01-01 03:00:00
oldest_part_to_get:          1_17_17_0
oldest_part_to_merge_to:
oldest_part_to_mutate_to:
log_max_index:               206
log_pointer:                 207
last_queue_update:           2021-10-12 14:50:08
absolute_delay:              99
total_replicas:              5
active_replicas:             5
lost_part_count:             0
last_queue_update_exception:
zookeeper_exception:
replica_is_active:           {'r1':1,'r2':1}
最后修改于 2026年6月25日