集群快速上手

以本地环境为例,演示 IoTDB 集群的启动、扩容与缩容。

注意:本文档为使用本地不同端口,进行伪分布式环境部署的教程,仅用于练习。在真实环境部署时,一般不需要修改节点端口,仅需配置节点 IPV4 地址或域名即可。

1. 准备启动环境

解压 apache-iotdb-1.0.0-all-bin.zip 至 cluster0 目录。

2. 启动最小集群

在 Linux 环境中,部署 1 个 ConfigNode 和 1 个 DataNode(1C1D)集群版,默认 1 副本:

  1. ./cluster0/sbin/start-confignode.sh
  2. ./cluster0/sbin/start-datanode.sh

3. 验证最小集群

  • 最小集群启动成功,启动 Cli 进行验证:
  1. ./cluster0/sbin/start-cli.sh
  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| DataNode|Running| 127.0.0.1| 10730| | 127.0.0.1| 6667| 10740| 10750| 10760|
  7. +------+----------+-------+---------------+------------+-------------------+----------+-------+--------+-------------------+-----------------+
  8. Total line number = 2
  9. It costs 0.242s

4. 准备扩容环境

解压 apache-iotdb-1.0.0-all-bin.zip 至 cluster1 目录和 cluster2 目录

5. 修改节点配置文件

对于 cluster1 目录:

  • 修改 ConfigNode 配置:
配置项
cn_internal_address127.0.0.1
cn_internal_port10711
cn_consensus_port10721
cn_target_config_node_list127.0.0.1:10710
  • 修改 DataNode 配置:
配置项
dn_rpc_address127.0.0.1
dn_rpc_port6668
dn_internal_address127.0.0.1
dn_internal_port10731
dn_mpp_data_exchange_port10741
dn_schema_region_consensus_port10751
dn_data_region_consensus_port10761
dn_target_config_node_list127.0.0.1:10710

对于 cluster2 目录:

  • 修改 ConfigNode 配置:
配置项
cn_internal_address127.0.0.1
cn_internal_port10712
cn_consensus_port10722
cn_target_config_node_list127.0.0.1:10710
  • 修改 DataNode 配置:
配置项
dn_rpc_address127.0.0.1
dn_rpc_port6669
dn_internal_address127.0.0.1
dn_internal_port10732
dn_mpp_data_exchange_port10742
dn_schema_region_consensus_port10752
dn_data_region_consensus_port10762
dn_target_config_node_list127.0.0.1:10710

6. 集群扩容

将集群扩容至 3 个 ConfigNode 和 3 个 DataNode(3C3D)集群版, 指令执行顺序为先启动 ConfigNode,再启动 DataNode:

  1. ./cluster1/sbin/start-confignode.sh
  2. ./cluster2/sbin/start-confignode.sh
  3. ./cluster1/sbin/start-datanode.sh
  4. ./cluster2/sbin/start-datanode.sh

7. 验证扩容结果

在 Cli 执行 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. | 2|ConfigNode|Running| 127.0.0.1| 10711| 10721| | | | | |
  7. | 3|ConfigNode|Running| 127.0.0.1| 10712| 10722| | | | | |
  8. | 1| 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.012s

8. 集群缩容

  • 缩容一个 ConfigNode:
  1. # 使用 ip:port 移除
  2. ./cluster0/sbin/remove-confignode.sh 127.0.0.1:10711
  3. # 使用节点编号移除
  4. ./cluster0/sbin/remove-confignode.sh 2
  • 缩容一个 DataNode:
  1. # 使用 ip:port 移除
  2. ./cluster0/sbin/remove-datanode.sh 127.0.0.1:6668
  3. # 使用节点编号移除
  4. ./cluster0/sbin/remove-confignode.sh 4

9. 验证缩容结果

在 Cli 执行 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. | 3|ConfigNode|Running| 127.0.0.1| 10712| 10722| | | | | |
  7. | 1| DataNode|Running| 127.0.0.1| 10730| | 127.0.0.1| 6667| 10740| 10750| 10760|
  8. | 5| DataNode|Running| 127.0.0.1| 10732| | 127.0.0.1| 6669| 10742| 10752| 10762|
  9. +------+----------+-------+---------------+------------+-------------------+----------+-------+-------+-------------------+-----------------+
  10. Total line number = 4
  11. It costs 0.005s