使用容器编排工具docker swarm安装clickhouse多机集群-阿里云开发者社区

开发者社区> 云原生> 正文

使用容器编排工具docker swarm安装clickhouse多机集群

简介: 1.首先需要安装docker最新版,docker 目前自带swarm容器编排工具 2.选中一台机器作为master,执行命令sudo docker  swarm init [options] 3,再需要加入集群的集群上执行此命令   4.

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的具体配置我就不介绍了,配置方面可以看我上一篇博客

 

希望大家尊重作者版权, 未经允许不得转载,违者必究!!

 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
云原生
使用钉钉扫一扫加入圈子
+ 订阅

云原生时代,是开发者最好的时代

其他文章