1.首先需要安装docker最新版,docker 目前自带swarm容器编排工具
2.选中一台机器作为master,执行命令sudo docker swarm init [options]
3,再需要加入集群的集群上执行此命令
4.可以使用sudo docker node ls此命令来查询节点数
5编写docker-compose.yaml文件,目前我使用的是version 3版本,version2和3有区别,具体看官网介绍
贴一份完整的docker-compose.yaml供大家参考
version: ‘3‘ services: zookeeper: image: zookeeper ports: - "2181:2181" - "2182:2182" volumes: - "/data/clickhouse/zk/data:/data" - "/data/clickhouse/zk/log:/datalog" deploy: placement: constraints: - node.hostname == SHA11DMPHAMP01 # networks: # - clickhouse clickhouse203: image: yandex/clickhouse-server container_name: clickhouse203 expose: - "9000" - "8123" user: root privileged: true deploy: placement: constraints: - node.hostname == SHA11DMPHDOP01 ports: - "111.250.128.203:9000:9000" - "111.250.128.203:8123:8123" volumes: - "/data/clickhouse/etc:/etc/clickhouse-server" - "/data/clickhouse/data:/var/lib/clickhouse" - "/data/clickhouse/log:/var/log/clickhouse-server" ulimits: nofile: soft: 262144 hard: 262144 depends_on: - "zookeeper" # networks: # - clickhouse_network clickhouse204: image: yandex/clickhouse-server container_name: clickhouse204 expose: - "9000" - "8123" user: root privileged: true deploy: placement: constraints: - node.hostname == SHA11DMPHDOP02 ports: - "111.250.128.204:9001:9000" - "111.250.128.204:8124:8123" volumes: - "/data/clickhouse/etc:/etc/clickhouse-server" - "/data/clickhouse/data:/var/lib/clickhouse" - "/data/clickhouse/log:/var/log/clickhouse-server" ulimits: nofile: soft: 262144 hard: 262144 depends_on: - "zookeeper" # networks: # - clickhouse clickhouse205: image: yandex/clickhouse-server container_name: clickhouse205 expose: - "9000" - "8123" user: root privileged: true deploy: placement: constraints: - node.hostname == SHA11DMPHDOP03 ports: - "111.250.128.205:9002:9000" - "111.250.128.205:8125:8123" volumes: - "/data/clickhouse/etc:/etc/clickhouse-server" - "/data/clickhouse/data:/var/lib/clickhouse" - "/data/clickhouse/log:/var/log/clickhouse-server" ulimits: nofile: soft: 262144 hard: 262144 depends_on: - "zookeeper" # networks: # - clickhouse clickhouse206: image: yandex/clickhouse-server container_name: clickhouse206 expose: - "9000" - "8123" user: root privileged: true deploy: placement: constraints: - node.hostname == SHA11DMPHDOP04 ports: - "111.250.128.206:9003:9000" - "111.250.128.206:8126:8123" volumes: - "/data/clickhouse/etc:/etc/clickhouse-server" - "/data/clickhouse/data:/var/lib/clickhouse" - "/data/clickhouse/log:/var/log/clickhouse-server" ulimits: nofile: soft: 262144 hard: 262144 depends_on: - "zookeeper" # networks: # - clickhouse #networds: # clickhouse_network:
docker-compose.yaml
clickhouse的具体配置我就不介绍了,配置方面可以看我上一篇博客
希望大家尊重作者版权, 未经允许不得转载,违者必究!!
原文地址:https://www.cnblogs.com/zqr99/p/10039811.html
时间: 2024-10-07 09:01:28