跳转到主内容
跳转到主内容

system.replicas

描述

包含本地服务器上所有复制表的相关信息和状态。 此表可用于监控。表中每个使用 Replicated* 引擎的表对应一行记录。

  • database (String) — 数据库名。
  • table (String) — 表名称。
  • uuid (UUID) — 表的 UUID。
  • engine (String) — 表引擎名称。
  • is_leader (UInt8) — 副本是否为领导者。多个副本可以同时担任领导者。可以使用 merge_tree 设置 replicated_can_become_leader 来阻止副本成为领导者。领导者负责调度后台合并。请注意,无论某个副本是否为领导者,只要该副本可用且在 ZK 中存在会话,就可以向其写入。
  • can_become_leader (UInt8) — 该副本是否可成为领导者。
  • 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) — 等待执行的 mutation 数量。
  • 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) — 要从其他副本拉取的 part 名称,取自复制队列中最早的 GET_PARTS 条目。
  • oldest_part_to_merge_to (String) — 从复制队列中最早的 MERGE_PARTS 条目获取的要合并到的结果 parts 名称。
  • oldest_part_to_mutate_to (String) — 从复制队列中最早的 MUTATE_PARTS 条目获取的目标结果 part 名称。
  • 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}