Installation by Docker

Apache IoTDB’ Docker image is released on https://hub.docker.com/r/apache/iotdbDocker Install - 图1open in new window Add environments of docker to update the configurations of Apache IoTDB.

Have a try

1. # get IoTDB official image
2. docker pull apache/iotdb:1.1.0-standalone
3. # create docker bridge network
4. docker network create --driver=bridge --subnet=172.18.0.0/16 --gateway=172.18.0.1 iotdb
5. # create docker container
6. docker run -d --name iotdb-service \
7. --hostname iotdb-service \
8. --network iotdb \
9. --ip 172.18.0.6 \
10. -p 6667:6667 \
11. -e cn_internal_address=iotdb-service \
12. -e cn_target_config_node_list=iotdb-service:10710 \
13. -e cn_internal_port=10710 \
14. -e cn_consensus_port=10720 \
15. -e dn_rpc_address=iotdb-service \
16. -e dn_internal_address=iotdb-service \
17. -e dn_target_config_node_list=iotdb-service:10710 \
18. -e dn_mpp_data_exchange_port=10740 \
19. -e dn_schema_region_consensus_port=10750 \
20. -e dn_data_region_consensus_port=10760 \
21. -e dn_rpc_port=6667 \
22. apache/iotdb:1.1.0-standalone
23. # execute SQL
24. docker exec -ti iotdb-service /iotdb/sbin/start-cli.sh -h iotdb-service

External access:

1. # <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.
2. $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.

1. # docker-compose-standalone.yml
2. version: "3"
3. services:
4. iotdb-service:
5. image: apache/iotdb:1.1.0-standalone
6. hostname: iotdb-service
7. container_name: iotdb-service
8. ports:
9. - "6667:6667"
10. environment:
11. - cn_internal_address=iotdb-service
12. - cn_internal_port=10710
13. - cn_consensus_port=10720
14. - cn_target_config_node_list=iotdb-service:10710
15. - dn_rpc_address=iotdb-service
16. - dn_internal_address=iotdb-service
17. - dn_rpc_port=6667
18. - dn_mpp_data_exchange_port=10740
19. - dn_schema_region_consensus_port=10750
20. - dn_data_region_consensus_port=10760
21. - dn_target_config_node_list=iotdb-service:10710
22. volumes:
23. - ./data:/iotdb/data
24. - ./logs:/iotdb/logs
25. networks:
26. iotdb:
27. ipv4_address: 172.18.0.6

29. networks:
30. iotdb:
31. external: true

deploy cluster

Until now, we support host and overlay networks but haven’t supported bridge networks on multiple computers. Overlay networks see 1C2DDocker Install - 图2open in new window 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:

1. version: "3"
2. services:
3. iotdb-confignode:
4. image: apache/iotdb:1.1.0-confignode
5. container_name: iotdb-confignode
6. environment:
7. - cn_internal_address=iotdb-2
8. - cn_target_config_node_list=iotdb-1:10710
9. - cn_internal_port=10710
10. - cn_consensus_port=10720
11. - schema_replication_factor=3
12. - schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
13. - config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
14. - data_replication_factor=3
15. - data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
16. volumes:
17. - /etc/hosts:/etc/hosts:ro
18. - ./data/confignode:/iotdb/data
19. - ./logs/confignode:/iotdb/logs
20. network_mode: "host"

22. iotdb-datanode:
23. image: apache/iotdb:1.1.0-datanode
24. container_name: iotdb-datanode
25. environment:
26. - dn_rpc_address=iotdb-2
27. - dn_internal_address=iotdb-2
28. - dn_target_config_node_list=iotdb-1:10710
29. - data_replication_factor=3
30. - dn_rpc_port=6667
31. - dn_mpp_data_exchange_port=10740
32. - dn_schema_region_consensus_port=10750
33. - dn_data_region_consensus_port=10760
34. - data_region_consensus_protocol_class=org.apache.iotdb.consensus.iot.IoTConsensus
35. - schema_replication_factor=3
36. - schema_region_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
37. - config_node_consensus_protocol_class=org.apache.iotdb.consensus.ratis.RatisConsensus
38. volumes:
39. - /etc/hosts:/etc/hosts:ro
40. - ./data/datanode:/iotdb/data/
41. - ./logs/datanode:/iotdb/logs/
42. 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 10710。
  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.