文章目錄
- 官方說明文檔
- 下載地址
- 服務安裝
- 節點服務分配
- 修改配置文件
- 修改堆內存
- 啟動集群
- 啟動第一個節點
- 啟動其他兩個節點的 ConfigNode 和 DataNode
- 檢驗集群狀態
- 修改集群密碼
- 【附錄】清理環境
- 集群擴容
- 修改配置
- 擴容
- 驗證擴容結果
- 集群縮容
- 縮容一個 ConfigNode
- 縮容一個 DataNode
- 驗證縮容結果
官方說明文檔
https://iotdb.apache.org/zh/UserGuide/V1.2.x/Deployment-and-Maintenance/Deployment-Recommendation.html#%E9%83%A8%E7%BD%B2%E6%A8%A1%E5%BC%8F%E9%80%89%E5%9E%8B
下載地址
https://iotdb.apache.org/Download/
這里下載的1.2.2版本
鏈接: https://pan.baidu.com/s/1B1c2DTd1k8MA84V4CxdAjw?pwd=k5c8 提取碼: k5c8
安裝包目錄結構
/data/iotdb/
├── conf # 配置文件
├── lib # jar library
├── sbin # 啟動/停止等腳本
└── tools # 其他工具
服務安裝
節點服務分配
節點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 |
修改配置文件
配置文件在 /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 |
修改堆內存
confignode-env.sh
設置 MAX_HEAP_SIZE="2G"
datanode-env.sh
設置MAX_HEAP_SIZE="16G"
- JVM堆內存配置:
confignode-env.sh
和datanode-env.sh
內配置MAX_HEAP_SIZE
, 建議設置值大于等于1G。ConfigNode 1~2G就足夠了,DataNode的內存配置則要取決于數據接入的數據量和查詢數據量。
啟動集群
啟動第一個節點
即上面表格中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
日志文件。
注意:
-
要保證第一個節點啟動成功后,再啟動其他節點。確切的說,要先保證第一個 ConfigNode 服務啟動成功,即
cn_target_config_node_list
配置的節點。 -
如果啟動失敗,需要清理環境(參考清理環境章節)后,再次啟動。
-
ConfigNode 和 DataNode 服務都可以單獨啟動:
# 單獨啟動 ConfigNode, 后臺啟動 sbin/start-confignode.sh -d # 單獨啟動 DataNode,后臺啟動 sbin/start-datanode.sh -d
啟動其他兩個節點的 ConfigNode 和 DataNode
在節點 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地址。
修改集群密碼
bash sbin/start-cli.sh -h 172.16.24.224 -p 6667 -u root -pw rootALTER USER root SET PASSWORD '123123';
【附錄】清理環境
在所有節點執行:
- 結束 ConfigNode 和 DataNode 進程。
# 1. 停止 ConfigNode 和 DataNode 服務
sbin/stop-standalone.sh# 2. 檢查是否還有進程殘留
jps
# 或者
ps -ef|gerp iotdb# 3. 如果有進程殘留,則手動kill
kill -9 <pid>
# 如果確定機器上僅有1個iotdb,可以使用下面命令清理殘留進程
ps -ef|grep iotdb|grep -v grep|tr -s ' ' ' ' |cut -d ' ' -f2|xargs kill -9
- 刪除 data 和 logs 目錄。
cd /data/iotdb
rm -rf data logs
說明:刪除 data 目錄是必要的,刪除 logs 目錄是為了純凈日志,非必需。
集群擴容
擴容方式與上方啟動其他節點相同。也就是,在要添加的節點上,下載IoTDB的安裝包,解壓,修改配置,然后啟動。這里要添加節點的IP為 192.168.132.13
注意:
- 擴容的節點必須是干凈的節點,不能有數據(也就是
data
目錄) - iotdb-common.properties中的
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|
+------+----------+-------+---------------+------------+-------+---------+
集群縮容
注意:
- 可以在任何一個集群內的節點上,執行縮容操作。
- 集群內的任意節點都可以被縮容。但是存留的 DataNode 服務不能小于副本數設置。
- 請耐心等待縮容腳本執行結束,并仔細閱讀日志說明,尤其是結束前的指南說明。
縮容一個 ConfigNode
cd /data/iotdb
# 方式一:使用 ip:port 移除
sbin/remove-confignode.sh 192.168.132.13:10710# 方式二:使用節點編號移除, `show cluster`中的 NodeID
sbin/remove-confignode.sh 6
縮容一個 DataNode
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|
+------+----------+-------+---------------+------------+-------+---------+