本文将简单介绍 IoTDB 集群的安装配置、扩容和缩容等常规操作。 遇到问题可以看: FAQ
我们将以最小的改动,启动一个含有3个 ConfigNode 和3个DataNode(3C3D)集群:
假设有3台物理机(下面称节点),操作系统为Linux,并且已经安装配置好了JAVA环境(具体见单机版对安装环境说明),安装目录均为/data/iotdb。 IP地址和服务角色分配如下:
| 节点IP | 192.168.132.10 | 192.168.132.11 | 192.168.132.12 |
|---|---|---|---|
| 服务 | ConfigNode | ConfigNode | ConfigNode |
| 服务 | DataNode | DataNode | DataNode |
端口占用:
| 服务 | ConfigNode | DataNode |
|---|---|---|
| 端口 | 10710, 10720 | 6667, 10730, 10740, 10750, 10760 |
说明:
IP地址或者机器名/域名来安装配置 IoTDB 集群,本文以IP地址为例。如果使用机器名/域名,则需要配置/etc/hosts。confignode-env.sh 和 datanode-env.sh 内配置MAX_HEAP_SIZE, 建议设置值大于等于1G。ConfigNode 1~2G就足够了,DataNode的内存配置则要取决于数据接入的数据量和查询数据量。在每个节点,将安装包下载后,解压到安装目录,这里为/data/iotdb。 目录结构:
/data/iotdb/ ├── conf # 配置文件 ├── lib # jar library ├── sbin # 启动/停止等脚本 └── tools # 其他工具
配置文件在 /data/iotdb/conf目录下。 按照下表修改相应的配置文件:
| 配置 | 配置项 | IP:192.168.132.10 | IP:192.168.132.11 | IP:192.168.132.12 |
|---|---|---|---|---|
| iotdb-confignode.properties | cn_internal_address | 192.168.132.10 | 192.168.132.11 | 192.168.132.12 |
| cn_target_config_node_list | 192.168.132.10:10710 | 192.168.132.10:10710 | 192.168.132.10:10710 | |
| iotdb-datanode.properties | dn_rpc_address | 192.168.132.10 | 192.168.132.11 | 192.168.132.12 |
| dn_internal_address | 192.168.132.10 | 192.168.132.11 | 192.168.132.12 | |
| dn_target_config_node_list | 192.168.132.10:10710 | 192.168.132.10:10710 | 192.168.132.10:10710 |
注意: 我们推荐所有节点的 iotdb-common.properties 和 JVM 的内存配置是一致的。
启动集群前,需保证配置正确,保证 IoTDB 安装目录下没有数据(data目录)。
即上面表格中cn_target_config_node_list配置的节点。 登录该节点 192.168.132.10,执行下面命令:
cd /data/iotdb # 启动 ConfigNode 和 DataNode 服务 sbin/start-standalone.sh # 查看 DataNode 日志以确定启动成功 tail -f logs/log_datanode_all.log # 期望看见类似下方的日志 # 2023-07-21 20:26:01,881 [main] INFO o.a.i.db.service.DataNode:192 - Congratulation, IoTDB DataNode is set up successfully. Now, enjoy yourself!
如果没有看到上面所说的日志或者看到了 Exception,那么代表启动失败了。请查看 /data/iotdb/logs 目录内的log_confignode_all.log 和 log_datanode_all.log 日志文件。
注意:
cn_target_config_node_list配置的节点。# 单独启动 ConfigNode, 后台启动 sbin/start-confignode.sh -d # 单独启动 DataNode,后台启动 sbin/start-datanode.sh -d
在节点 192.168.132.11 和 192.168.132.12 两个节点上分别执行:
cd /data/iotdb # 启动 ConfigNode 和 DataNode 服务 sbin/start-standalone.sh
如果启动失败,需要在所有节点执行清理环境后,然后从启动第一个节点开始,再重新执行一次。
在任意节点上,在 Cli 执行 show cluster:
/data/iotdb/sbin/start-cli.sh -h 192.168.132.10 IoTDB>show cluster; # 示例结果如下: +------+----------+-------+---------------+------------+-------+---------+ |NodeID| NodeType| Status|InternalAddress|InternalPort|Version|BuildInfo| +------+----------+-------+---------------+------------+-------+---------+ | 0|ConfigNode|Running| 192.168.132.10| 10710|1.x.x | xxxxxxx| | 1| DataNode|Running| 192.168.132.10| 10730|1.x.x | xxxxxxx| | 2|ConfigNode|Running| 192.168.132.11| 10710|1.x.x | xxxxxxx| | 3| DataNode|Running| 192.168.132.11| 10730|1.x.x | xxxxxxx| | 4|ConfigNode|Running| 192.168.132.12| 10710|1.x.x | xxxxxxx| | 5| DataNode|Running| 192.168.132.12| 10730|1.x.x | xxxxxxx| +------+----------+-------+---------------+------------+--------------+---------+
说明: start-cli.sh -h 后指定的IP地址,可以是任意一个 DataNode 的IP地址。
在所有节点执行:
# 1. 停止 ConfigNode 和 DataNode 服务 sbin/stop-standalone.sh # 2. 检查是否还有进程残留 jps # 或者 ps -ef|grep iotdb # 3. 如果有进程残留,则手动kill kill -9 <pid> # 如果确定机器上仅有1个iotdb,可以使用下面命令清理残留进程 ps -ef|grep iotdb|grep -v grep|tr -s ' ' ' ' |cut -d ' ' -f2|xargs kill -9
cd /data/iotdb rm -rf data logs
说明:删除 data 目录是必要的,删除 logs 目录是为了纯净日志,非必需。
扩容方式与上方启动其他节点相同。也就是,在要添加的节点上,下载IoTDB的安装包,解压,修改配置,然后启动。这里要添加节点的IP为 192.168.132.13 注意:
data目录)cluster_name的配置必须和已有集群一致。cn_target_config_node_list 和 dn_target_config_node_list的配置必须和已有集群一致。按照下表修改相应的配置文件:
| 配置 | 配置项 | IP:192.168.132.13 |
|---|---|---|
| iotdb-confignode.properties | cn_internal_address | 192.168.132.13 |
| cn_target_config_node_list | 192.168.132.10:10710 | |
| iotdb-datanode.properties | dn_rpc_address | 192.168.132.13 |
| dn_internal_address | 192.168.132.13 | |
| dn_target_config_node_list | 192.168.132.10:10710 |
在新增节点192.168.132.13上,执行:
cd /data/iotdb # 启动 ConfigNode 和 DataNode 服务 sbin/start-standalone.sh
在 Cli 执行 show cluster,结果如下:
/data/iotdb/sbin/start-cli.sh -h 192.168.132.10 IoTDB>show cluster; # 示例结果如下: +------+----------+-------+---------------+------------+-------+---------+ |NodeID| NodeType| Status|InternalAddress|InternalPort|Version|BuildInfo| +------+----------+-------+---------------+------------+-------+---------+ | 0|ConfigNode|Running| 192.168.132.10| 10710|1.x.x | xxxxxxx| | 1| DataNode|Running| 192.168.132.10| 10730|1.x.x | xxxxxxx| | 2|ConfigNode|Running| 192.168.132.11| 10710|1.x.x | xxxxxxx| | 3| DataNode|Running| 192.168.132.11| 10730|1.x.x | xxxxxxx| | 4|ConfigNode|Running| 192.168.132.12| 10710|1.x.x | xxxxxxx| | 5| DataNode|Running| 192.168.132.12| 10730|1.x.x | xxxxxxx| | 6|ConfigNode|Running| 192.168.132.13| 10710|1.x.x | xxxxxxx| | 7| DataNode|Running| 192.168.132.13| 10730|1.x.x | xxxxxxx| +------+----------+-------+---------------+------------+-------+---------+
注意:
cd /data/iotdb # 方式一:使用 ip:port 移除 sbin/remove-confignode.sh 192.168.132.13:10710 # 方式二:使用节点编号移除, `show cluster`中的 NodeID sbin/remove-confignode.sh 6
cd /data/iotdb # 方式一:使用 ip:port 移除 sbin/remove-datanode.sh 192.168.132.13:6667 # 方式二:使用节点编号移除, `show cluster`中的 NodeID sbin/remove-confignode.sh 7
在 Cli 执行 show cluster,结果如下:
+------+----------+-------+---------------+------------+-------+---------+ |NodeID| NodeType| Status|InternalAddress|InternalPort|Version|BuildInfo| +------+----------+-------+---------------+------------+-------+---------+ | 0|ConfigNode|Running| 192.168.132.10| 10710|1.x.x | xxxxxxx| | 1| DataNode|Running| 192.168.132.10| 10730|1.x.x | xxxxxxx| | 2|ConfigNode|Running| 192.168.132.11| 10710|1.x.x | xxxxxxx| | 3| DataNode|Running| 192.168.132.11| 10730|1.x.x | xxxxxxx| | 4|ConfigNode|Running| 192.168.132.12| 10710|1.x.x | xxxxxxx| | 5| DataNode|Running| 192.168.132.12| 10730|1.x.x | xxxxxxx| +------+----------+-------+---------------+------------+-------+---------+