You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ca...@apache.org on 2022/12/30 02:45:58 UTC
[iotdb] 02/02: cherry-pick 1ea16d5f6d2798a1e4a8ecaab90b8b1391b43c54
This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch beyyes/1.0.1_cherry_pick
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit f93558747e1f64f724bb8b97eaa7c4a65a2297b1
Author: changxue2022 <11...@users.noreply.github.com>
AuthorDate: Thu Dec 29 22:56:42 2022 +0800
cherry-pick 1ea16d5f6d2798a1e4a8ecaab90b8b1391b43c54
---
.../src/test/resources/iotdb-datanode.properties | 4 +-
docker/ReadMe.md | 6 +-
.../DockerCompose/docker-compose-cluster-1c2d.yml | 6 +-
.../DockerCompose/docker-compose-cluster-3c3d.yml | 16 +--
.../DockerCompose/docker-compose-host-3c3d.yml | 16 +--
docker/src/main/Dockerfile-0.12.6-cluster | 6 +-
docker/src/main/Dockerfile-0.13.0-cluster | 6 +-
docker/src/main/Dockerfile-1.0.0-confignode | 4 +-
docker/src/main/Dockerfile-1.0.0-datanode | 4 +-
docs/UserGuide/QuickStart/WayToGetIoTDB.md | 152 +++++++++++++++------
docs/zh/UserGuide/QuickStart/WayToGetIoTDB.md | 151 ++++++++++++++------
11 files changed, 253 insertions(+), 118 deletions(-)
diff --git a/cross-tests/src/test/resources/iotdb-datanode.properties b/cross-tests/src/test/resources/iotdb-datanode.properties
index 5f7c44c23f..78f84b74ef 100644
--- a/cross-tests/src/test/resources/iotdb-datanode.properties
+++ b/cross-tests/src/test/resources/iotdb-datanode.properties
@@ -26,9 +26,9 @@ services:
- "6667:6667"
environment:
- cn_internal_address=iotdb-service
- - cn_target_config_node_list=iotdb-service:10710
+ - cn_target_config_node_list=iotdb-service:22277
- dn_rpc_address=iotdb-service
- - dn_target_config_node_list=iotdb-service:10710
+ - dn_target_config_node_list=iotdb-service:22277
volumes:
- ./data:/iotdb/data
- ./logs:/iotdb/logs
diff --git a/docker/ReadMe.md b/docker/ReadMe.md
index bb5616f5ea..2754b80e42 100644
--- a/docker/ReadMe.md
+++ b/docker/ReadMe.md
@@ -54,7 +54,7 @@ docker run -d -p 6667:6667 -p 31999:31999 -p 8181:8181 -p 5555:5555 apache/iotdb
```
```shell
-docker run -d --name iotdb -p 6667:6667 -p 31999:31999 -p 8181:8181 -p 5555:5555 -p 10730:10730 -p 10760:10760 apache/iotdb:<version>
+docker run -d --name iotdb -p 6667:6667 -p 31999:31999 -p 8181:8181 -p 5555:5555 -p 9003:9003 -p 40010:40010 apache/iotdb:<version>
```
## Port description
@@ -66,8 +66,8 @@ By default, the ports that IoTDB uses are:
* 8086: InfluxDB Protocol port
* 8181: Monitor port
* 5555: Data sync port
-* 10730: internal metadata rpc port (for cluster)
-* 10760: internal data rpc port (for cluster)
+* 9003: internal metadata rpc port (for cluster)
+* 40010: internal data rpc port (for cluster)
## How to configure docker volumes
diff --git a/docker/src/main/DockerCompose/docker-compose-cluster-1c2d.yml b/docker/src/main/DockerCompose/docker-compose-cluster-1c2d.yml
index 21bce4786e..8653fcfd2e 100644
--- a/docker/src/main/DockerCompose/docker-compose-cluster-1c2d.yml
+++ b/docker/src/main/DockerCompose/docker-compose-cluster-1c2d.yml
@@ -24,7 +24,7 @@ services:
container_name: iotdb-confignode
environment:
- cn_internal_address=iotdb-confignode
- - cn_target_config_node_list=iotdb-confignode:10710
+ - cn_target_config_node_list=iotdb-confignode:22277
volumes:
- ./data/confignode:/iotdb/data
- ./logs/confignode:/iotdb/logs
@@ -41,7 +41,7 @@ services:
environment:
- dn_rpc_address=iotdb-datanode-1
- dn_internal_address=iotdb-datanode-1
- - dn_target_config_node_list=iotdb-confignode:10710
+ - dn_target_config_node_list=iotdb-confignode:22277
volumes:
- ./data/datanode1:/iotdb/data/
- ./logs/datanode1:/iotdb/logs/
@@ -56,7 +56,7 @@ services:
environment:
- dn_rpc_address=iotdb-datanode-2
- dn_internal_address=iotdb-datanode-2
- - dn_target_config_node_list=iotdb-confignode:10710
+ - dn_target_config_node_list=iotdb-confignode:22277
volumes:
- ./data/datanode2:/iotdb/data/
- ./logs/datanode2:/iotdb/logs/
diff --git a/docker/src/main/DockerCompose/docker-compose-cluster-3c3d.yml b/docker/src/main/DockerCompose/docker-compose-cluster-3c3d.yml
index 72f8183965..07a61f38b1 100644
--- a/docker/src/main/DockerCompose/docker-compose-cluster-3c3d.yml
+++ b/docker/src/main/DockerCompose/docker-compose-cluster-3c3d.yml
@@ -22,11 +22,11 @@ services:
image: apache/iotdb:1.0.0-confignode
container_name: iotdb-confignode
ports:
- - "10710:10710"
- - "10720:10720"
+ - "22277:22277"
+ - "22278:22278"
environment:
- cn_internal_address=iotdb-confignode-1
- - cn_target_config_node_list=iotdb-confignode-1:10710
+ - cn_target_config_node_list=iotdb-confignode-1:22277
volumes:
- /etc/hosts:/etc/hosts:ro
- ./data/confignode:/iotdb/data
@@ -40,14 +40,14 @@ services:
container_name: iotdb-datanode
ports:
- "6667:6667"
- - "10740:10740"
- - "10730:10730"
- - "10750:10750"
- - "10760:10760"
+ - "8777:8777"
+ - "9003:9003"
+ - "50010:50010"
+ - "40010:40010"
environment:
- dn_rpc_address=iotdb-datanode-1
- dn_internal_address=iotdb-datanode-1
- - dn_target_config_node_list=iotdb-confignode-1:10710
+ - dn_target_config_node_list=iotdb-confignode-1:22277
volumes:
- /etc/hosts:/etc/hosts:ro
- ./data/datanode1:/iotdb/data/
diff --git a/docker/src/main/DockerCompose/docker-compose-host-3c3d.yml b/docker/src/main/DockerCompose/docker-compose-host-3c3d.yml
index 7903d72813..0de9bef89f 100644
--- a/docker/src/main/DockerCompose/docker-compose-host-3c3d.yml
+++ b/docker/src/main/DockerCompose/docker-compose-host-3c3d.yml
@@ -22,11 +22,11 @@ services:
image: apache/iotdb:1.0.0-confignode
container_name: iotdb-confignode
ports:
- - "10710:10710"
- - "10720:10720"
+ - "22277:22277"
+ - "22278:22278"
environment:
- cn_internal_address=iotdb-1
- - cn_target_config_node_list=iotdb-1:10710
+ - cn_target_config_node_list=iotdb-1:22277
- schema_replication_factor=3
- schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
- config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
@@ -41,14 +41,14 @@ services:
container_name: iotdb-datanode
ports:
- "6667:6667"
- - "10740:10740"
- - "10730:10730"
- - "10750:10750"
- - "10760:10760"
+ - "8777:8777"
+ - "9003:9003"
+ - "50010:50010"
+ - "40010:40010"
environment:
- dn_rpc_address=iotdb-1
- dn_internal_address=iotdb-1
- - dn_target_config_node_list=iotdb-1:10710
+ - dn_target_config_node_list=iotdb-1:22277
- data_replication_factor=3
- data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
volumes:
diff --git a/docker/src/main/Dockerfile-0.12.6-cluster b/docker/src/main/Dockerfile-0.12.6-cluster
index 0e81b4b989..b7975dee43 100644
--- a/docker/src/main/Dockerfile-0.12.6-cluster
+++ b/docker/src/main/Dockerfile-0.12.6-cluster
@@ -32,7 +32,7 @@ RUN apt update \
&& apt purge --auto-remove -y \
&& apt clean -y \
# modify the seeds in configuration file
- && sed -i '/^seed_nodes/cseed_nodes=127.0.0.1:10730' /iotdb/conf/iotdb-cluster.properties \
+ && sed -i '/^seed_nodes/cseed_nodes=127.0.0.1:9003' /iotdb/conf/iotdb-cluster.properties \
&& sed -i '/^default_replica_num/cdefault_replica_num=1' /iotdb/conf/iotdb-cluster.properties
# rpc port
@@ -44,9 +44,9 @@ EXPOSE 5555
# monitor port
EXPOSE 8181
# internal meta port
-EXPOSE 10730
+EXPOSE 9003
# internal data port
-EXPOSE 10760
+EXPOSE 40010
VOLUME /iotdb/data
VOLUME /iotdb/logs
ENV PATH="/iotdb/sbin/:/iotdb/tools/:${PATH}"
diff --git a/docker/src/main/Dockerfile-0.13.0-cluster b/docker/src/main/Dockerfile-0.13.0-cluster
index c04323a9bd..15600260f8 100644
--- a/docker/src/main/Dockerfile-0.13.0-cluster
+++ b/docker/src/main/Dockerfile-0.13.0-cluster
@@ -32,7 +32,7 @@ RUN apt update \
&& apt purge --auto-remove -y \
&& apt clean -y \
# modify the seeds in configuration file
- && sed -i '/^seed_nodes/cseed_nodes=127.0.0.1:10730' /iotdb/conf/iotdb-cluster.properties \
+ && sed -i '/^seed_nodes/cseed_nodes=127.0.0.1:9003' /iotdb/conf/iotdb-cluster.properties \
&& sed -i '/^default_replica_num/cdefault_replica_num=1' /iotdb/conf/iotdb-cluster.properties
# rpc port
@@ -44,9 +44,9 @@ EXPOSE 5555
# monitor port
EXPOSE 8181
# internal meta port
-EXPOSE 10730
+EXPOSE 9003
# internal data port
-EXPOSE 10760
+EXPOSE 40010
VOLUME /iotdb/data
VOLUME /iotdb/logs
ENV PATH="/iotdb/sbin/:/iotdb/tools/:${PATH}"
diff --git a/docker/src/main/Dockerfile-1.0.0-confignode b/docker/src/main/Dockerfile-1.0.0-confignode
index 44a30e9869..b324dcd287 100644
--- a/docker/src/main/Dockerfile-1.0.0-confignode
+++ b/docker/src/main/Dockerfile-1.0.0-confignode
@@ -39,8 +39,8 @@ COPY DockerCompose/entrypoint.sh .
RUN chmod +x *.sh && dos2unix *.sh \
&& dos2unix ${IOTDB_HOME}/conf/*.sh
-EXPOSE 10710
-EXPOSE 10720
+EXPOSE 22277
+EXPOSE 22278
VOLUME ${IOTDB_HOME}/data
VOLUME ${IOTDB_HOME}/logs
diff --git a/docker/src/main/Dockerfile-1.0.0-datanode b/docker/src/main/Dockerfile-1.0.0-datanode
index c6ad20e7de..f94d591991 100644
--- a/docker/src/main/Dockerfile-1.0.0-datanode
+++ b/docker/src/main/Dockerfile-1.0.0-datanode
@@ -41,8 +41,8 @@ RUN chmod +x *.sh && dos2unix *.sh \
&& dos2unix ${IOTDB_HOME}/conf/*.sh
EXPOSE 6667
-EXPOSE 10740
-EXPOSE 10730
+EXPOSE 8777
+EXPOSE 9003
VOLUME $IOTDB_HOME/data
VOLUME $IOTDB_HOME/logs
diff --git a/docs/UserGuide/QuickStart/WayToGetIoTDB.md b/docs/UserGuide/QuickStart/WayToGetIoTDB.md
index ec3871ba14..3ada663a4b 100644
--- a/docs/UserGuide/QuickStart/WayToGetIoTDB.md
+++ b/docs/UserGuide/QuickStart/WayToGetIoTDB.md
@@ -105,46 +105,114 @@ Once the docker image has been built locally (the tag is iotdb:base in this exam
2. **Create docker volume for data files and logs:**
```shell
-$ docker volume create mydata
-$ docker volume create mylogs
-```
-3. **Run a docker container:**
-```shell
-$ docker run -p 6667:6667 -v mydata:/iotdb/data -v mylogs:/iotdb/logs -d iotdb:base /iotdb/bin/start-server.sh
-```
-If success, you can run `docker ps`, and get something like the following:
-```
-CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
-2a68b6944cb5 iotdb:base "/iotdb/bin/start-se…" 4 minutes ago Up 5 minutes 0.0.0.0:6667->6667/tcp laughing_meitner
-```
-You can use the above command to get the container ID:
-```shell
-$ docker container ls
-```
-suppose the ID is <C_ID>.
-
-And get the docker IP by the following, suppose the IP is <C_IP>.:
+# get IoTDB official image
+docker pull apache/iotdb:1.0.0-standalone
+# create docker bridge network
+docker network create --driver=bridge --subnet=172.18.0.0/16 --gateway=172.18.0.1 iotdb
+# create docker container
+docker run -d --name iotdb-service \
+ --hostname iotdb-service \
+ --network iotdb \
+ --ip 172.18.0.6 \
+ -p 6667:6667 \
+ -e cn_internal_address=iotdb-service \
+ -e cn_target_config_node_list=iotdb-service:22277 \
+ -e dn_rpc_address=iotdb-service \
+ -e dn_internal_address=iotdb-service \
+ -e dn_target_config_node_list=iotdb-service:22277 \
+ apache/iotdb:1.0.0-standalone
+# execute SQL
+docker exec -ti iotdb-service /iotdb/sbin/start-cli.sh -h iotdb-service
+```
+External access:
```shell
-$ docker inspect --format='{{.NetworkSettings.IPAddress}}' <C_ID>
-```
-Now IoTDB server has started succesfully.
-
-4. If you just want to have a try by using iotdb-cli, you can:
-```shell
-$ docker exec -it <C_ID> /bin/bash
-$ (now you have enter the container): /iotdb/sbin/start-cli.sh -h localhost -p 6667 -u root -pw root
-```
-
-Or, if you have an iotdb-cli locally, execute the following command:
-```shell
-$ /%IOTDB_HOME%/sbin/start-cli.sh -h localhost -p 6667 -u root -pw root
-```
-5. If you want to write codes to insert data and query data, please add the following dependencies:
-```xml
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-jdbc</artifactId>
- <version>1.0.0</version>
- </dependency>
-```
-Some examples about how to use IoTDB with IoTDB-JDBC can be found at: https://github.com/apache/iotdb/tree/master/example/jdbc/src/main/java/org/apache/iotdb
\ No newline at end of file
+# <IP Address/hostname> is the real IP or domain address rather than the one in docker network, could be 127.0.0.1 within the computer.
+$IOTDB_HOME/sbin/start-cli.sh -h <IP Address/hostname> -p 6667
+```
+Notice:The confignode service would fail when restarting this container if the IP Adress of the container has been changed.
+```yaml
+# docker-compose-1c1d.yml
+version: "3"
+services:
+ iotdb-service:
+ image: apache/iotdb:1.0.0-standalone
+ hostname: iotdb-service
+ container_name: iotdb-service
+ ports:
+ - "6667:6667"
+ environment:
+ - cn_internal_address=iotdb-service
+ - cn_target_config_node_list=iotdb-service:22277
+ - dn_rpc_address=iotdb-service
+ - dn_internal_address=iotdb-service
+ - dn_target_config_node_list=iotdb-service:22277
+ volumes:
+ - ./data:/iotdb/data
+ - ./logs:/iotdb/logs
+ networks:
+ iotdb:
+ ipv4_address: 172.18.0.6
+
+networks:
+ iotdb:
+ external: true
+```
+#### deploy cluster
+Until now, we support host and overlay networks but haven't supported bridge networks on multiple computers.
+Overlay networks see [1C2D](https://github.com/apache/iotdb/tree/master/docker/src/main/DockerCompose/docker-compose-cluster-1c2d.yml) and here are the configurations and operation steps to start an IoTDB cluster with docker using host networks。
+
+Suppose that there are three computers of iotdb-1, iotdb-2 and iotdb-3. We called them nodes.
+Here is the docker-compose file of iotdb-2, as the sample:
+```yaml
+version: "3"
+services:
+ iotdb-confignode:
+ image: apache/iotdb:1.0.0-confignode
+ container_name: iotdb-confignode
+ ports:
+ - "22277:22277"
+ - "22278:22278"
+ environment:
+ - cn_internal_address=iotdb-2
+ - cn_target_config_node_list=iotdb-1:22277
+ - schema_replication_factor=3
+ - schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ - config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ - data_replication_factor=3
+ - data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
+ volumes:
+ - /etc/hosts:/etc/hosts:ro
+ - ./data/confignode:/iotdb/data
+ - ./logs/confignode:/iotdb/logs
+ network_mode: "host"
+
+ iotdb-datanode:
+ image: apache/iotdb:1.0.0-datanode
+ container_name: iotdb-datanode
+ ports:
+ - "6667:6667"
+ - "8777:8777"
+ - "9003:9003"
+ - "50010:50010"
+ - "40010:40010"
+ environment:
+ - dn_rpc_address=iotdb-2
+ - dn_internal_address=iotdb-2
+ - dn_target_config_node_list=iotdb-1:22277
+ - data_replication_factor=3
+ - data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
+ - schema_replication_factor=3
+ - schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ - config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ volumes:
+ - /etc/hosts:/etc/hosts:ro
+ - ./data/datanode:/iotdb/data/
+ - ./logs/datanode:/iotdb/logs/
+ network_mode: "host"
+```
+Notice:
+1. The `dn_target_config_node_list` of three nodes must the same and it is the first starting node of `iotdb-1` with the cn_internal_port of 22277。
+2. In this docker-compose file,`iotdb-2` should be replace with the real IP or hostname of each node to generate docker compose files in the other nodes.
+3. The services would talk with each other, so they need map the /etc/hosts file or add the `extra_hosts` to the docker compose file.
+4. We must start the IoTDB services of `iotdb-1` first at the first time of starting.
+5. Stop and remove all the IoTDB services and clean up the `data` and `logs` directories of the 3 nodes,then start the cluster again.
diff --git a/docs/zh/UserGuide/QuickStart/WayToGetIoTDB.md b/docs/zh/UserGuide/QuickStart/WayToGetIoTDB.md
index 9123c2000b..774dc2da2a 100644
--- a/docs/zh/UserGuide/QuickStart/WayToGetIoTDB.md
+++ b/docs/zh/UserGuide/QuickStart/WayToGetIoTDB.md
@@ -115,46 +115,113 @@ $ docker volume create mylogs
3. **运行 docker 容器:**
```shell
-$ docker run -p 6667:6667 -v mydata:/iotdb/data -v mylogs:/iotdb/logs -d iotdb:base /iotdb/bin/start-server.sh
-```
-您可以使用`docker ps`来检查是否运行成功,当成功时控制台会输出下面的日志:
-```
-CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
-2a68b6944cb5 iotdb:base "/iotdb/bin/start-se…" 4 minutes ago Up 5 minutes 0.0.0.0:6667->6667/tcp laughing_meitner
-```
-您可以使用下面的命令来获取 container 的 ID:
-
-```shell
-$ docker container ls
-```
-假设这个 ID 为 <C_ID>.
-
-然后使用下面的命令获取这个 ID 对应的 IP 地址,假设获取的 IP 为 <C_IP>:
-
-```shell
-$ docker inspect --format='{{.NetworkSettings.IPAddress}}' <C_ID>
-```
-现在 IoTDB 服务器已经启动成功了。
-
-4. 如果您想尝试使用 iotdb-cli 命令行,您可以使用如下命令:
-
+# 获取镜像
+docker pull apache/iotdb:1.0.0-standalone
+# 创建 docker bridge 网络
+docker network create --driver=bridge --subnet=172.18.0.0/16 --gateway=172.18.0.1 iotdb
+# 创建 docker 容器
+# 注意:必须固定IP部署。IP改变会导致 confignode 启动失败。
+docker run -d --name iotdb-service \
+ --hostname iotdb-service \
+ --network iotdb \
+ --ip 172.18.0.6 \
+ -p 6667:6667 \
+ -e cn_internal_address=iotdb-service \
+ -e cn_target_config_node_list=iotdb-service:22277 \
+ -e dn_rpc_address=iotdb-service \
+ -e dn_internal_address=iotdb-service \
+ -e dn_target_config_node_list=iotdb-service:22277 \
+ apache/iotdb:1.0.0-standalone
+# 尝试使用命令行执行SQL
+docker exec -ti iotdb-service /iotdb/sbin/start-cli.sh -h iotdb-service
+```
+外部连接:
```shell
-$ docker exec -it <C_ID> /bin/bash
-$ (now you have enter the container): /iotdb/sbin/start-cli.sh -h localhost -p 6667 -u root -pw root
-```
-
-还可以使用本地的 iotdb-cli,执行如下命令:
-
-```shell
-$ /%IOTDB_HOME%/sbin/start-cli.sh -h localhost -p 6667 -u root -pw root
-```
-5. 如果您想写一些代码来插入或者查询数据,您可以在 pom.xml 文件中加入下面的依赖:
-
-```xml
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-jdbc</artifactId>
- <version>1.0.0</version>
- </dependency>
-```
-这里是一些使用 IoTDB-JDBC 连接 IoTDB 的示例:https://github.com/apache/iotdb/tree/master/example/jdbc/src/main/java/org/apache/iotdb
\ No newline at end of file
+# <主机IP/hostname> 是物理机的真实IP或域名。如果在同一台物理机,可以是127.0.0.1。
+$IOTDB_HOME/sbin/start-cli.sh -h <主机IP/hostname> -p 6667
+```
+```yaml
+# docker-compose-1c1d.yml
+version: "3"
+services:
+ iotdb-service:
+ image: apache/iotdb:1.0.0-standalone
+ hostname: iotdb-service
+ container_name: iotdb-service
+ ports:
+ - "6667:6667"
+ environment:
+ - cn_internal_address=iotdb-service
+ - cn_target_config_node_list=iotdb-service:22277
+ - dn_rpc_address=iotdb-service
+ - dn_internal_address=iotdb-service
+ - dn_target_config_node_list=iotdb-service:22277
+ volumes:
+ - ./data:/iotdb/data
+ - ./logs:/iotdb/logs
+ networks:
+ iotdb:
+ ipv4_address: 172.18.0.6
+
+networks:
+ iotdb:
+ external: true
+```
+#### 集群部署
+目前只支持 host 网络和 overlay 网络,不支持 bridge 网络。overlay 网络参照[1C2D](https://github.com/apache/iotdb/tree/master/docker/src/main/DockerCompose/docker-compose-cluster-1c2d.yml)的写法,host 网络如下。
+
+假如有三台物理机,它们的hostname分别是iotdb-1、iotdb-2、iotdb-3。依次启动。
+以 iotdb-2 节点的docker-compose文件为例:
+```yaml
+version: "3"
+services:
+ iotdb-confignode:
+ image: apache/iotdb:1.0.0-confignode
+ container_name: iotdb-confignode
+ ports:
+ - "22277:22277"
+ - "22278:22278"
+ environment:
+ - cn_internal_address=iotdb-2
+ - cn_target_config_node_list=iotdb-1:22277
+ - schema_replication_factor=3
+ - schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ - config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ - data_replication_factor=3
+ - data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
+ volumes:
+ - /etc/hosts:/etc/hosts:ro
+ - ./data/confignode:/iotdb/data
+ - ./logs/confignode:/iotdb/logs
+ network_mode: "host"
+
+ iotdb-datanode:
+ image: apache/iotdb:1.0.0-datanode
+ container_name: iotdb-datanode
+ ports:
+ - "6667:6667"
+ - "8777:8777"
+ - "9003:9003"
+ - "50010:50010"
+ - "40010:40010"
+ environment:
+ - dn_rpc_address=iotdb-2
+ - dn_internal_address=iotdb-2
+ - dn_target_config_node_list=iotdb-1:22277
+ - data_replication_factor=3
+ - data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
+ - schema_replication_factor=3
+ - schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ - config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
+ volumes:
+ - /etc/hosts:/etc/hosts:ro
+ - ./data/datanode:/iotdb/data/
+ - ./logs/datanode:/iotdb/logs/
+ network_mode: "host"
+```
+注意:
+1. `dn_target_config_node_list`所有节点配置一样,需要配置第一个启动的节点,这里为`iotdb-1`。
+2. 上面docker-compose文件中,`iotdb-2`需要替换为每个节点的 hostname、域名或者IP地址。
+3. 需要映射`/etc/hosts`,文件内配置了 iotdb-1、iotdb-2、iotdb-3 与IP的映射。或者可以在 docker-compose 文件中增加 `extra_hosts` 配置。
+4. 首次启动时,必须首先启动 `iotdb-1`。
+5. 如果部署失败要重新部署集群,必须将所有节点上的IoTDB服务停止并删除,然后清除`data`和`logs`文件夹后,再启动。