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

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 表示'副本在线',0 表示'副本离线',NULL 表示'未知'。
  • unsynced_after_recovery (Nullable(UInt8)) — 指示 Replicated 数据库副本在创建或恢复后,其复制延迟是否超过 max_replication_lag_to_enqueue。
  • replication_lag (Nullable(UInt32)) — Replicated 数据库副本的复制延迟 (适用于属于 Replicated 数据库的集群) 。
  • recovery_time (Nullable(UInt64)) — Replicated 数据库副本的恢复时间 (适用于属于 Replicated 数据库的集群) ,单位为毫秒。

别名:

  • namecluster 的别名。

示例

查询:

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

Row 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

另请参阅