跳转到主要内容

描述

包含本地服务器上复制表的信息和状态。 此表可用于监控。表中每个 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) — 副本是否处于只读模式。如果配置中没有 ClickHouse Keeper 相关部分、在 ClickHouse Keeper 中重新初始化会话时发生未知错误,或正处于 ClickHouse Keeper 中的会话重新初始化期间,则会启用此模式。
  • readonly_start_time (Nullable(DateTime)) — 副本进入 readonly 模式时的时间戳。如果副本不处于 readonly 模式,则为 NULL。
  • is_session_expired (UInt8) — 与 ClickHouse Keeper 的会话是否已失效。基本等同于 is_readonly
  • future_parts (UInt32) — 尚未执行的 INSERT 或合并操作将生成的数据分区片段数量。
  • parts_to_check (UInt32) — 队列中等待校验的数据分区片段数量。如果怀疑某个数据分区片段可能已损坏,就会将其放入校验队列。
  • zookeeper_name (String) — 用于存储表元数据的 [Zoo]Keeper 集群 (也可能是辅助集群) 的名称
  • zookeeper_path (String) — ClickHouse Keeper 中表数据的存储路径。
  • replica_name (String) — ClickHouse Keeper 中的副本名称。同一张表的不同副本名称各不相同。
  • replica_path (String) — ClickHouse Keeper 中副本数据的路径。等同于拼接 ‘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 条目确定的、需要从其他副本拉取的 part 名称。
  • 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 的活动会话时,其值才为非零。
  • log_pointer (UInt64) — 副本已复制到其执行队列中的常规活动日志中的最大条目编号,再加一。如果 log_pointer 远小于 log_max_index,则说明存在问题。
  • last_queue_update (DateTime) — 队列最后一次更新的时间。
  • absolute_delay (UInt64) — 当前副本的延迟有多大,单位为秒。
  • total_replicas (UInt32) — 此表的已知副本总数。
  • active_replicas (UInt32) — 此表在 ClickHouse Keeper 中拥有会话的副本数 (即正常工作的副本数) 。
  • lost_part_count (UInt64) — 自表创建以来,所有副本在该表中累计丢失的数据分区片段数量。该值持久保存在 ClickHouse Keeper 中,并且只能递增。
  • last_queue_update_exception (String) — 当队列中包含损坏的条目时。尤其是在 ClickHouse 不同版本之间出现向后兼容性破坏,且由较新版本写入的日志条目无法被旧版本解析时,这一点尤为重要。
  • zookeeper_exception (String) — 最后一条异常消息;如果错误是在从 ClickHouse Keeper 拉取信息时发生的,则会显示该消息。
  • replica_is_active (Map(String, UInt8)) — 副本名称与副本是否处于活动状态的映射。

示例

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月10日