集群运维命令

展示集群配置

当前 IoTDB 支持使用如下 SQL 展示集群的关键参数:

  1. SHOW VARIABLES

示例:

  1. IoTDB> show variables
  2. +----------------------------------+-----------------------------------------------------------------+
  3. | Variable| Value|
  4. +----------------------------------+-----------------------------------------------------------------+
  5. | ClusterName| defaultCluster|
  6. | DataReplicationFactor| 1|
  7. | SchemaReplicationFactor| 1|
  8. | DataRegionConsensusProtocolClass| org.apache.iotdb.consensus.iot.IoTConsensus|
  9. |SchemaRegionConsensusProtocolClass| org.apache.iotdb.consensus.ratis.RatisConsensus|
  10. | ConfigNodeConsensusProtocolClass| org.apache.iotdb.consensus.ratis.RatisConsensus|
  11. | TimePartitionInterval| 604800000|
  12. | DefaultTTL(ms)| 9223372036854775807|
  13. | ReadConsistencyLevel| strong|
  14. | SchemaRegionPerDataNode| 1.0|
  15. | DataRegionPerProcessor| 1.0|
  16. | LeastDataRegionGroupNum| 5|
  17. | SeriesSlotNum| 10000|
  18. | SeriesSlotExecutorClass|org.apache.iotdb.commons.partition.executor.hash.BKDRHashExecutor|
  19. | DiskSpaceWarningThreshold| 0.05|
  20. +----------------------------------+-----------------------------------------------------------------+
  21. Total line number = 15
  22. It costs 0.225s

注意: 必须保证该 SQL 展示的所有配置参数在同一集群各个节点完全一致

展示 ConfigNode 信息

当前 IoTDB 支持使用如下 SQL 展示 ConfigNode 的信息:

  1. SHOW CONFIGNODES

示例:

  1. IoTDB> show confignodes
  2. +------+-------+---------------+------------+--------+
  3. |NodeID| Status|InternalAddress|InternalPort| Role|
  4. +------+-------+---------------+------------+--------+
  5. | 0|Running| 127.0.0.1| 10710| Leader|
  6. | 1|Running| 127.0.0.1| 10711|Follower|
  7. | 2|Running| 127.0.0.1| 10712|Follower|
  8. +------+-------+---------------+------------+--------+
  9. Total line number = 3
  10. It costs 0.030s

ConfigNode 状态定义

对 ConfigNode 各状态定义如下:

  • Running: ConfigNode 正常运行
  • Unknown: ConfigNode 未正常上报心跳

展示 DataNode 信息

当前 IoTDB 支持使用如下 SQL 展示 DataNode 的信息:

  1. SHOW DATANODES

示例:

  1. IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
  2. Msg: The statement is executed successfully.
  3. IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
  4. Msg: The statement is executed successfully.
  5. IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
  6. Msg: The statement is executed successfully.
  7. IoTDB> show datanodes
  8. +------+-------+----------+-------+-------------+---------------+
  9. |NodeID| Status|RpcAddress|RpcPort|DataRegionNum|SchemaRegionNum|
  10. +------+-------+----------+-------+-------------+---------------+
  11. | 1|Running| 127.0.0.1| 6667| 0| 1|
  12. | 2|Running| 127.0.0.1| 6668| 0| 1|
  13. +------+-------+----------+-------+-------------+---------------+
  14. Total line number = 2
  15. It costs 0.007s
  16. IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
  17. Msg: The statement is executed successfully.
  18. IoTDB> show datanodes
  19. +------+-------+----------+-------+-------------+---------------+
  20. |NodeID| Status|RpcAddress|RpcPort|DataRegionNum|SchemaRegionNum|
  21. +------+-------+----------+-------+-------------+---------------+
  22. | 1|Running| 127.0.0.1| 6667| 1| 1|
  23. | 2|Running| 127.0.0.1| 6668| 0| 1|
  24. +------+-------+----------+-------+-------------+---------------+
  25. Total line number = 2
  26. It costs 0.006s

DataNode 状态定义

DataNode 的状态机如下图所示: 分布式运维命令 - 图1

对 DataNode 各状态定义如下:

  • Running: DataNode 正常运行,可读可写
  • Unknown: DataNode 未正常上报心跳,ConfigNode 认为该 DataNode 不可读写
  • Removing: DataNode 正在移出集群,不可读写
  • ReadOnly: DataNode 磁盘剩余空间低于 disk_warning_threshold(默认 5%),DataNode 可读但不能写入,不能同步数据

展示全部节点信息

当前 IoTDB 支持使用如下 SQL 展示全部节点的信息:

  1. SHOW CLUSTER

示例:

  1. IoTDB> show cluster
  2. +------+----------+-------+---------------+------------+
  3. |NodeID| NodeType| Status|InternalAddress|InternalPort|
  4. +------+----------+-------+---------------+------------+
  5. | 0|ConfigNode|Running| 127.0.0.1| 10710|
  6. | 1|ConfigNode|Running| 127.0.0.1| 10711|
  7. | 2|ConfigNode|Running| 127.0.0.1| 10712|
  8. | 3| DataNode|Running| 127.0.0.1| 10730|
  9. | 4| DataNode|Running| 127.0.0.1| 10731|
  10. | 5| DataNode|Running| 127.0.0.1| 10732|
  11. +------+----------+-------+---------------+------------+
  12. Total line number = 6
  13. It costs 0.011s

在节点被关停后,它的状态也会改变,如下所示:

  1. IoTDB> show cluster
  2. +------+----------+-------+---------------+------------+
  3. |NodeID| NodeType| Status|InternalAddress|InternalPort|
  4. +------+----------+-------+---------------+------------+
  5. | 0|ConfigNode|Running| 127.0.0.1| 10710|
  6. | 1|ConfigNode|Unknown| 127.0.0.1| 10711|
  7. | 2|ConfigNode|Running| 127.0.0.1| 10712|
  8. | 3| DataNode|Running| 127.0.0.1| 10730|
  9. | 4| DataNode|Running| 127.0.0.1| 10731|
  10. | 5| DataNode|Running| 127.0.0.1| 10732|
  11. +------+----------+-------+---------------+------------+
  12. Total line number = 6
  13. It costs 0.012s

展示全部节点的详细配置信息:

  1. SHOW CLUSTER DETAILS

示例:

  1. IoTDB> show cluster details
  2. +------+----------+-------+---------------+------------+-------------------+----------+-------+-------+-------------------+-----------------+
  3. |NodeID| NodeType| Status|InternalAddress|InternalPort|ConfigConsensusPort|RpcAddress|RpcPort|MppPort|SchemaConsensusPort|DataConsensusPort|
  4. +------+----------+-------+---------------+------------+-------------------+----------+-------+-------+-------------------+-----------------+
  5. | 0|ConfigNode|Running| 127.0.0.1| 10710| 10720| | | | | |
  6. | 1|ConfigNode|Running| 127.0.0.1| 10711| 10721| | | | | |
  7. | 2|ConfigNode|Running| 127.0.0.1| 10712| 10722| | | | | |
  8. | 3| DataNode|Running| 127.0.0.1| 10730| | 127.0.0.1| 6667| 10740| 10750| 10760|
  9. | 4| DataNode|Running| 127.0.0.1| 10731| | 127.0.0.1| 6668| 10741| 10751| 10761|
  10. | 5| DataNode|Running| 127.0.0.1| 10732| | 127.0.0.1| 6669| 10742| 10752| 10762|
  11. +------+----------+-------+---------------+------------+-------------------+----------+-------+-------+-------------------+-----------------+
  12. Total line number = 6
  13. It costs 0.340s

展示 Region 信息

集群中以 SchemaRegion/DataRegion 作为元数据/数据的复制和管理单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:

  • 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
  • 查看集群中各个 Region 被分配了哪些分区,是否均衡
  • 查看集群中各个 RegionGroup 的 leader 被分配到了哪些 DataNode,是否均衡

当前 IoTDB 支持使用如下 SQL 展示 Region 信息:

  • SHOW REGIONS: 展示所有 Region 分布
  • SHOW SCHEMA REGIONS: 展示所有 SchemaRegion 分布
  • SHOW DATA REGIONS: 展示所有 DataRegion 分布
  • SHOW (DATA|SCHEMA)? REGIONS OF DATABASE <sg1,sg2,...>: 展示指定数据库 <sg1,sg2,…> 对应的 Region 分布

展示所有 Region 的分布:

  1. IoTDB> show regions
  2. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  3. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  4. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  5. | 0| DataRegion|Running|root.sg1| 1| 1| 1| 127.0.0.1| 6667|Follower|
  6. | 0| DataRegion|Running|root.sg1| 1| 1| 2| 127.0.0.1| 6668| Leader|
  7. | 0| DataRegion|Running|root.sg1| 1| 1| 3| 127.0.0.1| 6669|Follower|
  8. | 1|SchemaRegion|Running|root.sg1| 1| 0| 1| 127.0.0.1| 6667|Follower|
  9. | 1|SchemaRegion|Running|root.sg1| 1| 0| 2| 127.0.0.1| 6668|Follower|
  10. | 1|SchemaRegion|Running|root.sg1| 1| 0| 3| 127.0.0.1| 6669| Leader|
  11. | 2| DataRegion|Running|root.sg2| 1| 1| 1| 127.0.0.1| 6667| Leader|
  12. | 2| DataRegion|Running|root.sg2| 1| 1| 2| 127.0.0.1| 6668|Follower|
  13. | 2| DataRegion|Running|root.sg2| 1| 1| 3| 127.0.0.1| 6669|Follower|
  14. | 3|SchemaRegion|Running|root.sg2| 1| 0| 1| 127.0.0.1| 6667|Follower|
  15. | 3|SchemaRegion|Running|root.sg2| 1| 0| 2| 127.0.0.1| 6668| Leader|
  16. | 3|SchemaRegion|Running|root.sg2| 1| 0| 3| 127.0.0.1| 6669|Follower|
  17. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  18. Total line number = 12
  19. It costs 0.165s

展示 SchemaRegion 或 DataRegion 的分布:

  1. IoTDB> show data regions
  2. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  3. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  4. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  5. | 0| DataRegion|Running|root.sg1| 1| 1| 1| 127.0.0.1| 6667|Follower|
  6. | 0| DataRegion|Running|root.sg1| 1| 1| 2| 127.0.0.1| 6668| Leader|
  7. | 0| DataRegion|Running|root.sg1| 1| 1| 3| 127.0.0.1| 6669|Follower|
  8. | 2| DataRegion|Running|root.sg2| 1| 1| 1| 127.0.0.1| 6667| Leader|
  9. | 2| DataRegion|Running|root.sg2| 1| 1| 2| 127.0.0.1| 6668|Follower|
  10. | 2| DataRegion|Running|root.sg2| 1| 1| 3| 127.0.0.1| 6669|Follower|
  11. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  12. Total line number = 6
  13. It costs 0.011s
  14. IoTDB> show schema regions
  15. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  16. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  17. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  18. | 1|SchemaRegion|Running|root.sg1| 1| 0| 1| 127.0.0.1| 6667|Follower|
  19. | 1|SchemaRegion|Running|root.sg1| 1| 0| 2| 127.0.0.1| 6668|Follower|
  20. | 1|SchemaRegion|Running|root.sg1| 1| 0| 3| 127.0.0.1| 6669| Leader|
  21. | 3|SchemaRegion|Running|root.sg2| 1| 0| 1| 127.0.0.1| 6667|Follower|
  22. | 3|SchemaRegion|Running|root.sg2| 1| 0| 2| 127.0.0.1| 6668| Leader|
  23. | 3|SchemaRegion|Running|root.sg2| 1| 0| 3| 127.0.0.1| 6669|Follower|
  24. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  25. Total line number = 6
  26. It costs 0.012s

展示指定数据库 <sg1,sg2,…> 对应的 Region 分布:

  1. IoTDB> show regions of database root.sg1
  2. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  3. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  4. +--------+------------+-------+-- -----+-----------+---------+----------+----------+-------+--------+
  5. | 0| DataRegion|Running|root.sg1| 1| 1| 1| 127.0.0.1| 6667|Follower|
  6. | 0| DataRegion|Running|root.sg1| 1| 1| 2| 127.0.0.1| 6668| Leader|
  7. | 0| DataRegion|Running|root.sg1| 1| 1| 3| 127.0.0.1| 6669|Follower|
  8. | 1|SchemaRegion|Running|root.sg1| 1| 0| 1| 127.0.0.1| 6667|Follower|
  9. | 1|SchemaRegion|Running|root.sg1| 1| 0| 2| 127.0.0.1| 6668|Follower|
  10. | 1|SchemaRegion|Running|root.sg1| 1| 0| 3| 127.0.0.1| 6669| Leader|
  11. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  12. Total line number = 6
  13. It costs 0.007s
  14. IoTDB> show regions of database root.sg1, root.sg2
  15. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  16. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  17. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  18. | 0| DataRegion|Running|root.sg1| 1| 1| 1| 127.0.0.1| 6667|Follower|
  19. | 0| DataRegion|Running|root.sg1| 1| 1| 2| 127.0.0.1| 6668| Leader|
  20. | 0| DataRegion|Running|root.sg1| 1| 1| 3| 127.0.0.1| 6669|Follower|
  21. | 1|SchemaRegion|Running|root.sg1| 1| 0| 1| 127.0.0.1| 6667|Follower|
  22. | 1|SchemaRegion|Running|root.sg1| 1| 0| 2| 127.0.0.1| 6668|Follower|
  23. | 1|SchemaRegion|Running|root.sg1| 1| 0| 3| 127.0.0.1| 6669| Leader|
  24. | 2| DataRegion|Running|root.sg2| 1| 1| 1| 127.0.0.1| 6667| Leader|
  25. | 2| DataRegion|Running|root.sg2| 1| 1| 2| 127.0.0.1| 6668|Follower|
  26. | 2| DataRegion|Running|root.sg2| 1| 1| 3| 127.0.0.1| 6669|Follower|
  27. | 3|SchemaRegion|Running|root.sg2| 1| 0| 1| 127.0.0.1| 6667|Follower|
  28. | 3|SchemaRegion|Running|root.sg2| 1| 0| 2| 127.0.0.1| 6668| Leader|
  29. | 3|SchemaRegion|Running|root.sg2| 1| 0| 3| 127.0.0.1| 6669|Follower|
  30. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  31. Total line number = 12
  32. It costs 0.009s
  33. IoTDB> show data regions of database root.sg1, root.sg2
  34. +--------+----------+-------+--------+-----------+---------+----------+----------+-------+--------+
  35. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  36. +--------+----------+-------+--------+-----------+---------+----------+----------+-------+--------+
  37. | 0|DataRegion|Running|root.sg1| 1| 1| 1| 127.0.0.1| 6667|Follower|
  38. | 0|DataRegion|Running|root.sg1| 1| 1| 2| 127.0.0.1| 6668| Leader|
  39. | 0|DataRegion|Running|root.sg1| 1| 1| 3| 127.0.0.1| 6669|Follower|
  40. | 2|DataRegion|Running|root.sg2| 1| 1| 1| 127.0.0.1| 6667| Leader|
  41. | 2|DataRegion|Running|root.sg2| 1| 1| 2| 127.0.0.1| 6668|Follower|
  42. | 2|DataRegion|Running|root.sg2| 1| 1| 3| 127.0.0.1| 6669|Follower|
  43. +--------+----------+-------+--------+-----------+---------+----------+----------+-------+--------+
  44. Total line number = 6
  45. It costs 0.007s
  46. IoTDB> show schema regions of database root.sg1, root.sg2
  47. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  48. |RegionId| Type| Status|Database|SeriesSlots|TimeSlots|DataNodeId|RpcAddress|RpcPort| Role|
  49. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  50. | 1|SchemaRegion|Running|root.sg1| 1| 0| 1| 127.0.0.1| 6667|Follower|
  51. | 1|SchemaRegion|Running|root.sg1| 1| 0| 2| 127.0.0.1| 6668|Follower|
  52. | 1|SchemaRegion|Running|root.sg1| 1| 0| 3| 127.0.0.1| 6669| Leader|
  53. | 3|SchemaRegion|Running|root.sg2| 1| 0| 1| 127.0.0.1| 6667|Follower|
  54. | 3|SchemaRegion|Running|root.sg2| 1| 0| 2| 127.0.0.1| 6668| Leader|
  55. | 3|SchemaRegion|Running|root.sg2| 1| 0| 3| 127.0.0.1| 6669|Follower|
  56. +--------+------------+-------+--------+-----------+---------+----------+----------+-------+--------+
  57. Total line number = 6
  58. It costs 0.009s

Region 状态定义

Region 继承所在 DataNode 的状态,对 Region 各状态定义如下:

  • Running: Region 所在 DataNode 正常运行,Region 可读可写
  • Unknown: Region 所在 DataNode 未正常上报心跳,ConfigNode 认为该 Region 不可读写
  • Removing: Region 所在 DataNode 正在被移出集群,Region 不可读写
  • ReadOnly: Region 所在 DataNode 的磁盘剩余空间低于 disk_warning_threshold(默认 5%),Region 可读,但不能写入,不能同步数据

展示集群槽信息

集群使用分区来管理元数据和数据,分区定义如下:

  • 元数据分区:序列槽
  • 数据分区:<序列槽,时间分区槽>

可以使用以下 SQL 来查询分区对应信息:

展示数据分区所在的 DataRegion

展示一个数据分区(或一个序列槽下的所有数据分区)所在的 DataRegion:

  • SHOW DATA REGIONID OF root.sg WHERE SERIESSLOTID=s0 (AND TIMESLOTID=t0)

示例:

  1. IoTDB> show data regionid of root.sg where seriesslotid=5286 and timeslotid=0
  2. +--------+
  3. |RegionId|
  4. +--------+
  5. | 1|
  6. +--------+
  7. Total line number = 1
  8. It costs 0.006s
  9. IoTDB> show data regionid of root.sg where seriesslotid=5286
  10. +--------+
  11. |RegionId|
  12. +--------+
  13. | 1|
  14. | 2|
  15. +--------+
  16. Total line number = 2
  17. It costs 0.006s

展示元数据分区所在的 SchemaRegion

展示一个元数据分区所在的 SchemaRegion:

  • SHOW SCHEMA REGIONID OF root.sg WHERE SERIESSLOTID=s0

示例:

  1. IoTDB> show schema regionid of root.sg where seriesslotid=5286
  2. +--------+
  3. |RegionId|
  4. +--------+
  5. | 0|
  6. +--------+
  7. Total line number = 1
  8. It costs 0.007s

展示序列槽下的时间槽

展示一个序列槽下的所有时间槽:

  • SHOW TIMESLOTID OF root.sg WHERE SERIESLOTID=s0 (AND STARTTIME=t1) (AND ENDTIME=t2)

示例:

  1. IoTDB> show timeslotid of root.sg where seriesslotid=5286
  2. +----------+
  3. |TimeSlotId|
  4. +----------+
  5. | 0|
  6. | 1000|
  7. +----------+
  8. Total line number = 1
  9. It costs 0.007s

展示数据库的序列槽

展示一个数据库内,数据,元数据或是所有的序列槽:

  • SHOW (DATA|SCHEMA)? SERIESSLOTID OF root.sg

示例:

  1. IoTDB> show data seriesslotid of root.sg
  2. +------------+
  3. |SeriesSlotId|
  4. +------------+
  5. | 5286|
  6. +------------+
  7. Total line number = 1
  8. It costs 0.007s
  9. IoTDB> show schema seriesslotid of root.sg
  10. +------------+
  11. |SeriesSlotId|
  12. +------------+
  13. | 5286|
  14. +------------+
  15. Total line number = 1
  16. It costs 0.006s
  17. IoTDB> show seriesslotid of root.sg
  18. +------------+
  19. |SeriesSlotId|
  20. +------------+
  21. | 5286|
  22. +------------+
  23. Total line number = 1
  24. It costs 0.006s