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

本文涉及的产品
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
简介: 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的具体配置我就不介绍了,配置方面可以看我上一篇博客

 

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

 

相关文章
|
7天前
|
时序数据库 Docker 容器
Docker安装InfluxDB
Docker安装InfluxDB
10 0
|
7天前
|
关系型数据库 MySQL 数据库
Docker安装MySQL
Docker安装MySQL
14 1
|
8天前
|
Ubuntu Python
python3安装clickhouse_sqlalchemy(greenlet) 失败
如果上述方法仍然无法解决问题,建议查阅相关错误信息和官方文档,以获取更详细的帮助。确保你的Python环境和依赖库都在最新版本,有时问题可能会因为版本不兼容而导致安装失败。
14 0
|
9天前
|
关系型数据库 MySQL 数据库
docker自定义安装mysql 5.7
docker自定义安装mysql 5.7
19 0
|
9天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
17 0
|
13天前
|
Ubuntu 网络安全 数据安全/隐私保护
ubuntu篇-配置FTP服务,本机和docker安装
通过以上步骤,你可以在Ubuntu上配置FTP服务,无论是本机安装还是Docker内安装,都可以提供FTP文件传输服务。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
20 1
|
20天前
|
Linux Shell 开发工具
CentOS8中Docker安装及部署
CentOS8中Docker安装及部署
67 0
|
21天前
|
数据安全/隐私保护 Docker 容器
AWVS13破解docker一键安装
AWVS13破解docker一键安装
30 0
|
3月前
|
数据安全/隐私保护 虚拟化 Docker
Docker Swarm 集群搭建
Docker Swarm 集群搭建
|
3月前
|
Kubernetes 应用服务中间件 nginx
Docker六脉神剑 (五) Docker Swarm集群搭建及基础服务部署
Docker六脉神剑 (五) Docker Swarm集群搭建及基础服务部署
45 1