跳到主要内容
跳到主要内容

system.clusters

包含关于配置文件中已配置集群及其服务器的信息。

列:

  • cluster (String) — 集群名称。
  • shard_num (UInt32) — 集群内的分片编号,从 1 开始。
  • shard_name (String) — 集群中该分片的名称。
  • shard_weight (UInt32) — 写入数据时该分片的相对权重。
  • internal_replication (UInt8) — 标志,指示此主机是否属于可以自行完成数据复制的副本集合。
  • replica_num (UInt32) — 分片内的副本编号,从 1 开始。
  • host_name (String) — 主机名,与配置中指定的一致。
  • host_address (String) — 从 DNS 获取的主机 IP 地址。
  • port (UInt16) — 用于连接到服务器的端口。
  • is_local (UInt8) — 标志,指示该主机是否为本地主机。
  • user (String) — 用于连接到服务器的用户名。
  • default_database (String) — 默认数据库名称。
  • errors_count (UInt32) — 此主机访问副本失败的次数。
  • slowdowns_count (UInt32) — 使用对冲请求建立连接时,因变慢而导致切换副本的次数。
  • estimated_recovery_time (UInt32) — 副本错误计数清零并被视为恢复正常前预计剩余的秒数。
  • database_shard_name (String) — Replicated 数据库分片名称(适用于属于 Replicated 数据库的集群)。
  • database_replica_name (String) — Replicated 数据库副本名称(适用于属于 Replicated 数据库的集群)。
  • is_shared_catalog_cluster (UInt8) — 布尔值,指示集群是否属于共享目录。
  • is_active (Nullable(UInt8)) — Replicated 数据库副本的状态(适用于属于 Replicated 数据库的集群):1 表示 “replica is online”,0 表示 “replica is offline”,NULL 表示 “unknown”。
  • unsynced_after_recovery (Nullable(UInt8)) — 指示 Replicated 数据库副本在创建或恢复之后,其复制延迟是否超过 max_replication_lag_to_enqueue。
  • replication_lag (Nullable(UInt32)) — Replicated 数据库副本的复制延迟(适用于属于 Replicated 数据库的集群)。
  • recovery_time (Nullable(UInt64)) — Replicated 数据库副本的恢复时间(适用于属于 Replicated 数据库的集群),单位为毫秒。

示例

查询:

SELECT * FROM system.clusters LIMIT 2 FORMAT Vertical;

结果:

Row 1:
──────
cluster:                 test_cluster_two_shards
shard_num:               1
shard_name:              shard_01
shard_weight:            1
replica_num:             1
host_name:               127.0.0.1
host_address:            127.0.0.1
port:                    9000
is_local:                1
user:                    default
default_database:
errors_count:            0
slowdowns_count:         0
estimated_recovery_time: 0
database_shard_name:
database_replica_name:
is_active:               NULL

第 2 行: ────── cluster: test_cluster_two_shards shard_num: 2 shard_name: shard_02 shard_weight: 1 replica_num: 1 host_name: 127.0.0.2 host_address: 127.0.0.2 port: 9000 is_local: 0 user: default default_database: errors_count: 0 slowdowns_count: 0 estimated_recovery_time: 0 database_shard_name: database_replica_name: is_active: NULL


**另请参阅**

- [Distributed 表引擎](../../engines/table-engines/special/distributed.md)
- [distributed_replica_error_cap 设置](../../operations/settings/settings.md#distributed_replica_error_cap)
- [distributed_replica_error_half_life 设置](../../operations/settings/settings.md#distributed_replica_error_half_life)