本文将简单介绍 IoTDB 集群的安装配置、扩容和缩容等常规操作。 遇到问题可以看: FAQ
部署集群时我们推荐优先使用hostname
来配置集群,这样可以避免一些网络问题。需要在每个节点上分别配置/etc/hosts
,windows 上为C:\Windows\System32\drivers\etc\hosts
。
我们将以最小的改动,启动一个含有3个 ConfigNode 和3个DataNode(3C3D)集群:
假设有3台物理机(下面称节点),操作系统为Linux,并且已经安装配置好了JAVA环境(具体见单机版对安装环境说明),安装目录均为/data/iotdb
。 IP地址和服务角色分配如下:
节点IP | 192.168.132.10 | 192.168.132.11 | 192.168.132.12 |
---|---|---|---|
hostname | iotdb-1 | iotdb-2 | iotdb-3 |
服务 | ConfigNode | ConfigNode | ConfigNode |
服务 | DataNode | DataNode | DataNode |
端口占用:
服务 | ConfigNode | DataNode |
---|---|---|
端口 | 10710, 10720 | 6667, 10730, 10740, 10750, 10760 |
说明:
IP地址
或者hostname(机器名/域名)
来安装配置 IoTDB 集群,本文以hostname(机器名/域名)
为例。使用hostname(机器名/域名)
,需要配置/etc/hosts
。hostname(机器名/域名)
进行配置,这样可以避免一些网络问题,也更方便迁移集群。confignode-env.sh
和 datanode-env.sh
内配置ON_HEAP_MEMORY
, 建议设置值大于等于1G。ConfigNode 1~2G就足够了,DataNode的内存配置则要取决于数据接入的数据量和查询数据量。在每个节点,将安装包下载后,解压到安装目录,这里为/data/iotdb
。 目录结构:
/data/iotdb/ ├── conf # 配置文件 ├── lib # jar library ├── sbin # 启动/停止等脚本 └── tools # 其他工具
在每个节点均配置 hosts
echo "192.168.132.10 iotdb-1" >> /etc/hosts echo "192.168.132.11 iotdb-2" >> /etc/hosts echo "192.168.132.12 iotdb-3" >> /etc/hosts
配置文件在 /data/iotdb/conf
目录下。 按照下表修改相应的配置文件:
配置 | 配置项 | IP:192.168.132.10 | IP:192.168.132.11 | IP:192.168.132.12 |
---|---|---|---|---|
iotdb-confignode.properties | cn_internal_address | iotdb-1 | iotdb-2 | iotdb-3 |
iotdb-confignode.properties | cn_seed_config_node | iotdb-1:10710 | iotdb-1:10710 | iotdb-1:10710 |
iotdb-datanode.properties | dn_rpc_address | iotdb-1 | iotdb-2 | iotdb-3 |
iotdb-datanode.properties | dn_internal_address | iotdb-1 | iotdb-2 | iotdb-3 |
iotdb-datanode.properties | dn_seed_config_node | iotdb-1:10710 | iotdb-1:10710 | iotdb-1:10710 |
注意: 我们推荐所有节点的 iotdb-system.properties 和 JVM 的内存配置是一致的。
启动集群前,需保证配置正确,保证 IoTDB 安装目录下没有数据(data
目录)。
即上面表格中cn_seed_config_node
配置的节点。 登录该节点 iotdb-1(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_seed_config_node
配置的节点。# 单独启动 ConfigNode, 后台启动 sbin/start-confignode.sh -d # 单独启动 DataNode,后台启动 sbin/start-datanode.sh -d
在节点 iotdb-2(192.168.132.11)
和 iotdb-3(192.168.132.12)
两个节点上分别执行:
cd /data/iotdb # 启动 ConfigNode 和 DataNode 服务 sbin/start-standalone.sh
如果启动失败,需要在所有节点执行清理环境后,然后从启动第一个节点开始,再重新执行一次。
在任意节点上,在 Cli 执行 show cluster
:
/data/iotdb/sbin/start-cli.sh -h iotdb-1 IoTDB>show cluster; # 示例结果如下: +------+----------+-------+---------------+------------+-------+---------+ |NodeID| NodeType| Status|InternalAddress|InternalPort|Version|BuildInfo| +------+----------+-------+---------------+------------+-------+---------+ | 0|ConfigNode|Running| iotdb-1 | 10710|1.x.x | xxxxxxx| | 1| DataNode|Running| iotdb-1 | 10730|1.x.x | xxxxxxx| | 2|ConfigNode|Running| iotdb-2 | 10710|1.x.x | xxxxxxx| | 3| DataNode|Running| iotdb-2 | 10730|1.x.x | xxxxxxx| | 4|ConfigNode|Running| iotdb-3 | 10710|1.x.x | xxxxxxx| | 5| DataNode|Running| iotdb-3 | 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_seed_config_node
和 dn_seed_config_node
的配置必须和已有集群一致。在原节点上新增一行 hosts
echo "192.168.132.13 iotdb-4" >> /etc/hosts
在节点设置 hosts
echo "192.168.132.10 iotdb-1" >> /etc/hosts echo "192.168.132.11 iotdb-2" >> /etc/hosts echo "192.168.132.12 iotdb-3" >> /etc/hosts echo "192.168.132.13 iotdb-4" >> /etc/hosts
按照下表修改相应的配置文件:
配置 | 配置项 | IP:192.168.132.13 |
---|---|---|
iotdb-confignode.properties | cn_internal_address | iotdb-4 |
iotdb-confignode.properties | cn_seed_config_node | iotdb-1:10710 |
iotdb-datanode.properties | dn_rpc_address | iotdb-4 |
iotdb-datanode.properties | dn_internal_address | iotdb-4 |
iotdb-datanode.properties | dn_seed_config_node | iotdb-1:10710 |
在新增节点iotdb-4(192.168.132.13)
上,执行:
cd /data/iotdb # 启动 ConfigNode 和 DataNode 服务 sbin/start-standalone.sh
在 Cli 执行 show cluster
,结果如下:
/data/iotdb/sbin/start-cli.sh -h iotdb-1 IoTDB>show cluster; # 示例结果如下: +------+----------+-------+---------------+------------+-------+---------+ |NodeID| NodeType| Status|InternalAddress|InternalPort|Version|BuildInfo| +------+----------+-------+---------------+------------+-------+---------+ | 0|ConfigNode|Running| iotdb-1 | 10710|1.x.x | xxxxxxx| | 1| DataNode|Running| iotdb-1 | 10730|1.x.x | xxxxxxx| | 2|ConfigNode|Running| iotdb-2 | 10710|1.x.x | xxxxxxx| | 3| DataNode|Running| iotdb-2 | 10730|1.x.x | xxxxxxx| | 4|ConfigNode|Running| iotdb-3 | 10710|1.x.x | xxxxxxx| | 5| DataNode|Running| iotdb-3 | 10730|1.x.x | xxxxxxx| | 6|ConfigNode|Running| iotdb-4 | 10710|1.x.x | xxxxxxx| | 7| DataNode|Running| iotdb-4 | 10730|1.x.x | xxxxxxx| +------+----------+-------+---------------+------------+-------+---------+
注意:
cd /data/iotdb # 方式一:使用 ip:port 移除 sbin/remove-confignode.sh iotdb-4:10710 # 方式二:使用节点编号移除, `show cluster`中的 NodeID sbin/remove-confignode.sh 6
cd /data/iotdb # 方式一:使用 ip:port 移除 sbin/remove-datanode.sh iotdb-4:6667 # 方式二:使用节点编号移除, `show cluster`中的 NodeID sbin/remove-datanode.sh 7
在 Cli 执行 show cluster
,结果如下:
+------+----------+-------+---------------+------------+-------+---------+ |NodeID| NodeType| Status|InternalAddress|InternalPort|Version|BuildInfo| +------+----------+-------+---------------+------------+-------+---------+ | 0|ConfigNode|Running| iotdb-1 | 10710|1.x.x | xxxxxxx| | 1| DataNode|Running| iotdb-1 | 10730|1.x.x | xxxxxxx| | 2|ConfigNode|Running| iotdb-2 | 10710|1.x.x | xxxxxxx| | 3| DataNode|Running| iotdb-2 | 10730|1.x.x | xxxxxxx| | 4|ConfigNode|Running| iotdb-3 | 10710|1.x.x | xxxxxxx| | 5| DataNode|Running| iotdb-3 | 10730|1.x.x | xxxxxxx| +------+----------+-------+---------------+------------+-------+---------+