Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

system.replicas

描述

包含本地服务器上复制表的信息和状态。 此表可用于监控。表中每个 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)) — 副本进入只读模式时的时间戳。如果副本未处于只读模式,则为 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 条目所指定的、要从其他副本拉取的分片名称。
  • oldest_part_to_merge_to (String) — 从复制队列中最早的 MERGE_PARTS 条目获取的合并结果数据分区片段名称。
  • oldest_part_to_mutate_to (String) — 从复制队列中最早的 MUTATE_PARTS 条目获取的变更结果数据分区片段名称。
  • log_max_index (UInt64) — 常规活动日志中的最大条目编号。仅当与 ClickHouse Keeper 存在活动会话时,此列及后续三列 (log_pointertotal_replicasactive_replicas) 的值才非零。
  • 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)) — 副本名称与副本是否处于活动状态之间的映射。

别名:

  • readonly_durationif(isNull(readonly_start_time), NULL, now() - readonly_start_time) 的别名。

示例

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}
Navigation