CLUSTER_INFO

CLUSTER_INFO 表提供了集群的节点拓扑信息。

  1. USE INFORMATION_SCHEMA;
  2. DESC TABLE CLUSTER_INFO;

输出如下:

  1. +-------------+----------------------+------+------+---------+---------------+
  2. | Column | Type | Key | Null | Default | Semantic Type |
  3. +-------------+----------------------+------+------+---------+---------------+
  4. | peer_id | Int64 | | NO | | FIELD |
  5. | peer_type | String | | NO | | FIELD |
  6. | peer_addr | String | | YES | | FIELD |
  7. | version | String | | NO | | FIELD |
  8. | git_commit | String | | NO | | FIELD |
  9. | start_time | TimestampMillisecond | | YES | | FIELD |
  10. | uptime | String | | YES | | FIELD |
  11. | active_time | String | | YES | | FIELD |
  12. +-------------+----------------------+------+------+---------+---------------+

每个列的含义:

  • peer_id: 节点的服务器 ID。对于 standalone 来讲,该字段总是为 0,对于集群模式下的 frontend 该字段总为 -1。因为在这两种情况下,该字段没有实际含义。
  • peer_type: 节点类型, 分布式集群里可能是 METASRVFRONTEND 或者 DATANODE。单机模式显示为 STANDALONE
  • peer_addr: 节点的 gRPC 服务地址。对于单机部署,该字段总为空。
  • version: 节点的版本号,形如 0.7.2 的字符串。
  • start_time: 节点的启动时间。
  • uptime: 节点的持续运行时间,形如 24h 10m 59s 150ms 的字符串。
  • active_time: 距离节点上一次活跃(也就是发送心跳请求)过去的时间,形如 24h 10m 59s 150ms 的字符串。单机模式下该字段总为空。

尝试查询下这张表:

  1. SELECT * FROM CLUSTER_INFO;

一个单机模式的样例输出:

  1. +---------+------------+-----------+---------+------------+-------------------------+--------+-------------+
  2. | peer_id | peer_type | peer_addr | version | git_commit | start_time | uptime | active_time |
  3. +---------+------------+-----------+---------+------------+-------------------------+--------+-------------+
  4. | 0 | STANDALONE | | 0.7.2 | 86ab3d9 | 2024-04-30T06:40:02.074 | 18ms | |
  5. +---------+------------+-----------+---------+------------+-------------------------+--------+-------------+

另一个输出来自一个分布式集群,它有三个 Datanode、一个 Frontend 和一个 Metasrv:

  1. +---------+-----------+----------------+---------+------------+-------------------------+----------+-------------+
  2. | peer_id | peer_type | peer_addr | version | git_commit | start_time | uptime | active_time |
  3. +---------+-----------+----------------+---------+------------+-------------------------+----------+-------------+
  4. | 1 | DATANODE | 127.0.0.1:4101 | 0.7.2 | 86ab3d9 | 2024-04-30T06:40:04.791 | 4s 478ms | 1s 467ms |
  5. | 2 | DATANODE | 127.0.0.1:4102 | 0.7.2 | 86ab3d9 | 2024-04-30T06:40:06.098 | 3s 171ms | 162ms |
  6. | 3 | DATANODE | 127.0.0.1:4103 | 0.7.2 | 86ab3d9 | 2024-04-30T06:40:07.425 | 1s 844ms | 1s 839ms |
  7. | -1 | FRONTEND | 127.0.0.1:4001 | 0.7.2 | 86ab3d9 | 2024-04-30T06:40:08.815 | 454ms | 47ms |
  8. | 0 | METASRV | 127.0.0.1:3002 | unknown | unknown | | | |
  9. +---------+-----------+----------------+---------+------------+-------------------------+----------+-------------+