├── .gitignore
├── README-CN.md
├── README.md
├── ch-conf
├── metrika_ch01.xml
├── metrika_ch02.xml
└── metrika_ch03.xml
├── ch-conf_1zk-3shard-1replica
├── metrika_ch01.xml
├── metrika_ch02.xml
└── metrika_ch03.xml
├── ch-conf_1zk-3shard-3replica
├── metrika_ch01.xml
├── metrika_ch02.xml
└── metrika_ch03.xml
├── ch-conf_3zk-3shard-1replica
├── metrika_ch01.xml
├── metrika_ch02.xml
└── metrika_ch03.xml
├── ch-conf_3zk-3shard-3replica
├── metrika_ch01.xml
├── metrika_ch02.xml
└── metrika_ch03.xml
├── clickhouse_1zk-3shard-1replica.yml
├── clickhouse_1zk-3shard-3replica.yml
├── clickhouse_3zk-3shard-1replica.yml
├── clickhouse_3zk-3shard-3replica.yml
└── docker-compose.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### JetBrains template
3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5 |
6 | # User-specific stuff
7 | .idea/**/workspace.xml
8 | .idea/**/tasks.xml
9 | .idea/**/usage.statistics.xml
10 | .idea/**/dictionaries
11 | .idea/**/shelf
12 |
13 | # Generated files
14 | .idea/**/contentModel.xml
15 |
16 | # Sensitive or high-churn files
17 | .idea/**/dataSources/
18 | .idea/**/dataSources.ids
19 | .idea/**/dataSources.local.xml
20 | .idea/**/sqlDataSources.xml
21 | .idea/**/dynamic.xml
22 | .idea/**/uiDesigner.xml
23 | .idea/**/dbnavigator.xml
24 |
25 | # Gradle
26 | .idea/**/gradle.xml
27 | .idea/**/libraries
28 |
29 | # Gradle and Maven with auto-import
30 | # When using Gradle or Maven with auto-import, you should exclude module files,
31 | # since they will be recreated, and may cause churn. Uncomment if using
32 | # auto-import.
33 | # .idea/artifacts
34 | # .idea/compiler.xml
35 | # .idea/jarRepositories.xml
36 | # .idea/modules.xml
37 | # .idea/*.iml
38 | # .idea/modules
39 | # *.iml
40 | # *.ipr
41 |
42 | # CMake
43 | cmake-build-*/
44 |
45 | # Mongo Explorer plugin
46 | .idea/**/mongoSettings.xml
47 |
48 | # File-based project format
49 | *.iws
50 |
51 | # IntelliJ
52 | out/
53 |
54 | # mpeltonen/sbt-idea plugin
55 | .idea_modules/
56 |
57 | # JIRA plugin
58 | atlassian-ide-plugin.xml
59 |
60 | # Cursive Clojure plugin
61 | .idea/replstate.xml
62 |
63 | # Crashlytics plugin (for Android Studio and IntelliJ)
64 | com_crashlytics_export_strings.xml
65 | crashlytics.properties
66 | crashlytics-build.properties
67 | fabric.properties
68 |
69 | # Editor-based Rest Client
70 | .idea/httpRequests
71 |
72 | # Android studio 3.1+ serialized cache file
73 | .idea/caches/build_file_checksums.ser
74 |
75 | ### macOS template
76 | # General
77 | .DS_Store
78 | .AppleDouble
79 | .LSOverride
80 |
81 | # Icon must end with two \r
82 | Icon
83 |
84 | # Thumbnails
85 | ._*
86 |
87 | # Files that might appear in the root of a volume
88 | .DocumentRevisions-V100
89 | .fseventsd
90 | .Spotlight-V100
91 | .TemporaryItems
92 | .Trashes
93 | .VolumeIcon.icns
94 | .com.apple.timemachine.donotpresent
95 |
96 | # Directories potentially created on remote AFP share
97 | .AppleDB
98 | .AppleDesktop
99 | Network Trash Folder
100 | Temporary Items
101 | .apdisk
102 |
103 | /.idea/
104 |
--------------------------------------------------------------------------------
/README-CN.md:
--------------------------------------------------------------------------------
1 | # ClickHouse Cluster Docker Compose
2 |
3 | 
4 |
5 | **[English](README.md)** | [**中文**](README-CN.md)
6 |
7 |
8 |
9 | 用于快速构建 ClickHouse Server 集群环境的 docker-compose 脚本,基于 [clickhouse/clickHouse-server](clickhouse/clickHouse-server) 官方镜像,支持自定义 clickhosue-server 版本,默认组件版本如下:
10 |
11 | * zookeeper:3.6;
12 | * clickHouse-server:20.11 ;
13 |
14 | ### 快速开始
15 |
16 | ```shell
17 | git clone https://github.com/Al-assad/clickhouse-cluster-docker.git
18 | docker-compose up
19 | ```
20 |
21 | 默认创建的集群节点为 1 个 zookeeper 节点,3 个 clickhosue-server 节点(3 分片、1 副本):
22 |
23 | 
24 |
25 | ### 宿主机连接 ClickHosue 集群
26 |
27 | 1. 通过宿主机 ip 访问:
28 |
29 | ```shell
30 | clickhouse-server-ch01 127.0.0.1:8124
31 | clickhouse-server-ch02 127.0.0.1:8125
32 | clickhouse-server-ch03 127.0.0.1:8126
33 | ```
34 |
35 | 2. 通过 docker 子网 ip 访问:
36 |
37 | 如果宿主机为 MacOS,可以通过 [mac-docker-connector](https://github.com/wenjunxiao/mac-docker-connector) 项目直接访问是 docker 子网络:
38 |
39 | ```shell
40 | clickhouse-server-ch01 172.18.1.5:8123
41 | clickhouse-server-ch02 172.18.1.6:8123
42 | clickhouse-server-ch03 172.18.1.7:8123
43 | ```
44 |
45 | 可以通过 DBeaver 或者 clickhosue-client 连接访问 clickhosue-server 集群。
46 |
47 | ### 其他集群模式
48 |
49 | ```shell
50 | # zookeeper 单节点,clickhosue 3 分片 1 副本
51 | docker-compose -f clickhosue_1zk-3shard-1replica up
52 |
53 | # zookeeper 单节点,clickhosue 3 分片 3 副本
54 | docker-compose -f clickhosue_1zk-3shard-3replica up
55 |
56 | # zookeeper 3 节点,clickhosue 3 分片 1 副本
57 | docker-compose -f clickhosue_3zk-3shard-1replica up
58 |
59 | # zookeeper 3 节点,clickhosue 3 分片 3 副本
60 | docker-compose -f clickhosue_3zk-3shard-3replica up
61 | ```
62 |
63 | 此外可以通过直接修改 `ch-conf/metrika_ch01.xml`、`ch-conf/metrika_ch02.xml`、`ch-conf/metrika_ch03.xml` 来修改 3 个 ch 节点的 metrika 配置。
64 |
65 | ### 其他 ClickHouse 版本
66 |
67 | 可以通过修改 `CLICKHOUSE_VERSION` 环境变量来自定义 CH 镜像版本,注意需要使用 clickhouse/clickhosue-server 的对应镜像版本。
68 |
69 | ```shell
70 | # 使用 clickhouse-server 23.8.4 版本
71 | export CLICKHOUSE_VERSION=23.8.4 && docker-compose config
72 | ```
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ClickHouse Cluster Docker Compose
2 |
3 | 
4 |
5 | **[English](README.md)** | [**中文**](README-CN.md)
6 |
7 |
8 |
9 | Docker-compose script for quickly building a ClickHouse cluster environment, based on the official [clickhouse/clickhouse-server](https://hub.docker.com/r/clickhouse/clickhouse-server) image, supports custom clickhosue-server versions.
10 |
11 | The default component version is as follows :
12 |
13 | * **zookeeper**:3.6;
14 | * **clickHouse-server**:20.11 ;
15 |
16 | ### Quick Start
17 |
18 | ```shell
19 | git clone https://github.com/Al-assad/clickhouse-cluster-docker.git
20 | docker-compose up
21 | ```
22 |
23 | The default created cluster nodes includes 1 zookeeper node, 3 clickhosue-server nodes (3 shards, 1 replica each node).
24 |
25 | 
26 |
27 | ### Connect ClickHouse Cluster from Host Machine
28 |
29 | 1. Access via host machine ip:
30 |
31 | ```shell
32 | clickhouse-server-ch01 127.0.0.1:8124
33 | clickhouse-server-ch02 127.0.0.1:8125
34 | clickhouse-server-ch03 127.0.0.1:8126
35 | ```
36 |
37 | 2. Access via docker subnetwork ip:
38 |
39 | If your docker host machine is MacOS, you can access the docker subnetwork directly through the project [wenjunxiao/mac-docker-connector](https://github.com/wenjunxiao/mac-docker-connector).
40 |
41 | ```shell
42 | clickhouse-server-ch01 172.18.1.5:8123
43 | clickhouse-server-ch02 172.18.1.6:8123
44 | clickhouse-server-ch03 172.18.1.7:8123
45 | ```
46 |
47 | Then you can connect the clickhouse-server cluster through DBeaver GUI Tool or clickhosue-client command-line tool. Enjoy it : )
48 |
49 | ### Other Cluster Mode
50 |
51 | ```shell
52 | # single zookeeper node,clickhosue 3 shards and 1 replica
53 | docker-compose -f clickhosue_1zk-3shard-1replica up
54 |
55 | # single zookeeper node,clickhosue 3 shards and 3 replicas
56 | docker-compose -f clickhosue_1zk-3shard-3replica up
57 |
58 | # 3 zookeeper 3 nodes,clickhosue 3 shards and 1 replica
59 | docker-compose -f clickhosue_3zk-3shard-1replica up
60 |
61 | # 3 zookeeper 3 nodes,clickhosue 3 shards and 3 replicas
62 | docker-compose -f clickhosue_3zk-3shard-3replica up
63 | ```
64 |
65 | In addition, you can also modify the metrika configuration for the three CH nodes by directly modifying ```ch-conf/metrika_ch01.xml```, ```ch-conf/metrika_ch02.xml```, ```and ch-conf/metrika_ch03.xml```.
66 |
67 | ### Other ClickHouse Image Version
68 |
69 | Of course, You can customize the CH image version by modifying the environment variable ```CLICKHOUSE_VERSION```.
70 |
71 | ```shell
72 | # use clickhouse-server v23.8.4
73 | export CLICKHOUSE_VERSION=23.8.4 && docker-compose config
74 | ```
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/ch-conf/metrika_ch01.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 |
31 | 01
32 | ch01
33 |
34 |
--------------------------------------------------------------------------------
/ch-conf/metrika_ch02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 |
31 | 02
32 | ch02
33 |
34 |
--------------------------------------------------------------------------------
/ch-conf/metrika_ch03.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 |
31 | 03
32 | ch03
33 |
34 |
--------------------------------------------------------------------------------
/ch-conf_1zk-3shard-1replica/metrika_ch01.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 |
31 | 01
32 | ch01
33 |
34 |
--------------------------------------------------------------------------------
/ch-conf_1zk-3shard-1replica/metrika_ch02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 |
31 | 02
32 | ch02
33 |
34 |
--------------------------------------------------------------------------------
/ch-conf_1zk-3shard-1replica/metrika_ch03.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 |
31 | 03
32 | ch03
33 |
34 |
--------------------------------------------------------------------------------
/ch-conf_1zk-3shard-3replica/metrika_ch01.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 | ch02
11 | 9000
12 |
13 |
14 | ch03
15 | 9000
16 |
17 |
18 |
19 |
20 | ch01
21 | 9000
22 |
23 |
24 | ch02
25 | 9000
26 |
27 |
28 | ch03
29 | 9000
30 |
31 |
32 |
33 |
34 | ch01
35 | 9000
36 |
37 |
38 | ch02
39 | 9000
40 |
41 |
42 | ch03
43 | 9000
44 |
45 |
46 |
47 |
48 |
49 |
50 | zk1
51 | 2181
52 |
53 |
54 |
55 | 01
56 | ch01
57 |
58 |
59 |
--------------------------------------------------------------------------------
/ch-conf_1zk-3shard-3replica/metrika_ch02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 | ch02
11 | 9000
12 |
13 |
14 | ch03
15 | 9000
16 |
17 |
18 |
19 |
20 | ch01
21 | 9000
22 |
23 |
24 | ch02
25 | 9000
26 |
27 |
28 | ch03
29 | 9000
30 |
31 |
32 |
33 |
34 | ch01
35 | 9000
36 |
37 |
38 | ch02
39 | 9000
40 |
41 |
42 | ch03
43 | 9000
44 |
45 |
46 |
47 |
48 |
49 |
50 | zk1
51 | 2181
52 |
53 |
54 |
55 | 02
56 | ch02
57 |
58 |
59 |
--------------------------------------------------------------------------------
/ch-conf_1zk-3shard-3replica/metrika_ch03.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 | ch02
11 | 9000
12 |
13 |
14 | ch03
15 | 9000
16 |
17 |
18 |
19 |
20 | ch01
21 | 9000
22 |
23 |
24 | ch02
25 | 9000
26 |
27 |
28 | ch03
29 | 9000
30 |
31 |
32 |
33 |
34 | ch01
35 | 9000
36 |
37 |
38 | ch02
39 | 9000
40 |
41 |
42 | ch03
43 | 9000
44 |
45 |
46 |
47 |
48 |
49 |
50 | zk1
51 | 2181
52 |
53 |
54 |
55 | 03
56 | ch03
57 |
58 |
59 |
--------------------------------------------------------------------------------
/ch-conf_3zk-3shard-1replica/metrika_ch01.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 | zk2
31 | 2181
32 |
33 |
34 | zk3
35 | 2181
36 |
37 |
38 |
39 | 01
40 | ch01
41 |
42 |
43 |
--------------------------------------------------------------------------------
/ch-conf_3zk-3shard-1replica/metrika_ch02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 | zk2
31 | 2181
32 |
33 |
34 | zk3
35 | 2181
36 |
37 |
38 |
39 | 02
40 | ch02
41 |
42 |
43 |
--------------------------------------------------------------------------------
/ch-conf_3zk-3shard-1replica/metrika_ch03.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 |
11 |
12 | ch02
13 | 9000
14 |
15 |
16 |
17 |
18 | ch03
19 | 9000
20 |
21 |
22 |
23 |
24 |
25 |
26 | zk1
27 | 2181
28 |
29 |
30 | zk2
31 | 2181
32 |
33 |
34 | zk3
35 | 2181
36 |
37 |
38 |
39 | 03
40 | ch03
41 |
42 |
43 |
--------------------------------------------------------------------------------
/ch-conf_3zk-3shard-3replica/metrika_ch01.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 | ch02
11 | 9000
12 |
13 |
14 | ch03
15 | 9000
16 |
17 |
18 |
19 |
20 | ch01
21 | 9000
22 |
23 |
24 | ch02
25 | 9000
26 |
27 |
28 | ch03
29 | 9000
30 |
31 |
32 |
33 |
34 | ch01
35 | 9000
36 |
37 |
38 | ch02
39 | 9000
40 |
41 |
42 | ch03
43 | 9000
44 |
45 |
46 |
47 |
48 |
49 |
50 | zk1
51 | 2181
52 |
53 |
54 | zk2
55 | 2181
56 |
57 |
58 | zk3
59 | 2181
60 |
61 |
62 |
63 | 01
64 | ch01
65 |
66 |
67 |
--------------------------------------------------------------------------------
/ch-conf_3zk-3shard-3replica/metrika_ch02.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 | ch02
11 | 9000
12 |
13 |
14 | ch03
15 | 9000
16 |
17 |
18 |
19 |
20 | ch01
21 | 9000
22 |
23 |
24 | ch02
25 | 9000
26 |
27 |
28 | ch03
29 | 9000
30 |
31 |
32 |
33 |
34 | ch01
35 | 9000
36 |
37 |
38 | ch02
39 | 9000
40 |
41 |
42 | ch03
43 | 9000
44 |
45 |
46 |
47 |
48 |
49 |
50 | zk1
51 | 2181
52 |
53 |
54 | zk2
55 | 2181
56 |
57 |
58 | zk3
59 | 2181
60 |
61 |
62 |
63 | 02
64 | ch02
65 |
66 |
67 |
--------------------------------------------------------------------------------
/ch-conf_3zk-3shard-3replica/metrika_ch03.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ch01
7 | 9000
8 |
9 |
10 | ch02
11 | 9000
12 |
13 |
14 | ch03
15 | 9000
16 |
17 |
18 |
19 |
20 | ch01
21 | 9000
22 |
23 |
24 | ch02
25 | 9000
26 |
27 |
28 | ch03
29 | 9000
30 |
31 |
32 |
33 |
34 | ch01
35 | 9000
36 |
37 |
38 | ch02
39 | 9000
40 |
41 |
42 | ch03
43 | 9000
44 |
45 |
46 |
47 |
48 |
49 |
50 | zk1
51 | 2181
52 |
53 |
54 | zk2
55 | 2181
56 |
57 |
58 | zk3
59 | 2181
60 |
61 |
62 |
63 | 03
64 | ch03
65 |
66 |
67 |
--------------------------------------------------------------------------------
/clickhouse_1zk-3shard-1replica.yml:
--------------------------------------------------------------------------------
1 | # Author: Al-assad
2 | # Email: yulinying_1994@outlook.com
3 | # Date: 2020-11-27
4 | # Description: docker compose for clickhouse cluster with 3 shards and 1 replica, 1 zookeeper node
5 |
6 | version: '2.1'
7 |
8 | services:
9 |
10 | zookeeper:
11 | image: zookeeper:3.6
12 | hostname: zk1
13 | container_name: clickhouse-zookeeper
14 | ports:
15 | - "2181:2181"
16 | networks:
17 | clickhouse-cluster:
18 | ipv4_address: 172.18.1.2
19 |
20 | clickhouse1:
21 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
22 | ports:
23 | - "8124:8123"
24 | hostname: ch01
25 | container_name: clickhouse-server-ch01
26 | ulimits:
27 | nofile:
28 | soft: 262144
29 | hard: 262144
30 | networks:
31 | clickhouse-cluster:
32 | ipv4_address: 172.18.1.5
33 | extra_hosts:
34 | - "zk1:172.18.1.2"
35 | - "ch02:172.18.1.6"
36 | - "ch03:172.18.1.7"
37 | volumes:
38 | - ./ch-conf_1zk-3shard-1replica/metrika_ch01.xml:/etc/metrika.xml
39 | depends_on:
40 | - "zookeeper"
41 |
42 | clickhouse2:
43 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
44 | ports:
45 | - "8125:8123"
46 | hostname: ch02
47 | container_name: clickhouse-server-ch02
48 | ulimits:
49 | nofile:
50 | soft: 262144
51 | hard: 262144
52 | networks:
53 | clickhouse-cluster:
54 | ipv4_address: 172.18.1.6
55 | extra_hosts:
56 | - "zk1:172.18.1.2"
57 | - "ch01:172.18.1.5"
58 | - "ch03:172.18.1.7"
59 | volumes:
60 | - ./ch-conf_1zk-3shard-1replica/metrika_ch02.xml:/etc/metrika.xml
61 | depends_on:
62 | - "zookeeper"
63 |
64 | clickhouse3:
65 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
66 | ports:
67 | - "8126:8123"
68 | hostname: ch03
69 | container_name: clickhouse-server-ch03
70 | ulimits:
71 | nofile:
72 | soft: 262144
73 | hard: 262144
74 | networks:
75 | clickhouse-cluster:
76 | ipv4_address: 172.18.1.7
77 | extra_hosts:
78 | - "zk1:172.18.1.2"
79 | - "ch01:172.18.1.5"
80 | - "ch02:172.18.1.6"
81 | volumes:
82 | - ./ch-conf_1zk-3shard-1replica/metrika_ch03.xml:/etc/metrika.xml
83 | depends_on:
84 | - "zookeeper"
85 |
86 | networks:
87 | clickhouse-cluster:
88 | driver: bridge
89 | ipam:
90 | driver: default
91 | config:
92 | - subnet: 172.18.1.0/16
93 |
--------------------------------------------------------------------------------
/clickhouse_1zk-3shard-3replica.yml:
--------------------------------------------------------------------------------
1 | # Author: Al-assad
2 | # Email: yulinying_1994@outlook.com
3 | # Date: 2020-11-27
4 | # Description: docker compose for clickhouse cluster with 3 shards and 1 replica, 1 zookeeper node
5 |
6 | version: '2.1'
7 |
8 | services:
9 |
10 | zookeeper:
11 | image: zookeeper:3.6
12 | hostname: zk1
13 | container_name: clickhouse-zookeeper
14 | ports:
15 | - "2181:2181"
16 | networks:
17 | clickhouse-cluster:
18 | ipv4_address: 172.18.1.2
19 |
20 | clickhouse1:
21 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
22 | ports:
23 | - "8124:8123"
24 | hostname: ch01
25 | container_name: clickhouse-server-ch01
26 | ulimits:
27 | nofile:
28 | soft: 262144
29 | hard: 262144
30 | networks:
31 | clickhouse-cluster:
32 | ipv4_address: 172.18.1.5
33 | extra_hosts:
34 | - "zk1:172.18.1.2"
35 | - "ch02:172.18.1.6"
36 | - "ch03:172.18.1.7"
37 | volumes:
38 | - ./ch-conf_1zk-3shard-3replica/metrika_ch01.xml:/etc/metrika.xml
39 | depends_on:
40 | - "zookeeper"
41 |
42 | clickhouse2:
43 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
44 | ports:
45 | - "8125:8123"
46 | hostname: ch02
47 | container_name: clickhouse-server-ch02
48 | ulimits:
49 | nofile:
50 | soft: 262144
51 | hard: 262144
52 | networks:
53 | clickhouse-cluster:
54 | ipv4_address: 172.18.1.6
55 | extra_hosts:
56 | - "zk1:172.18.1.2"
57 | - "ch01:172.18.1.5"
58 | - "ch03:172.18.1.7"
59 | volumes:
60 | - ./ch-conf_1zk-3shard-3replica/metrika_ch02.xml:/etc/metrika.xml
61 | depends_on:
62 | - "zookeeper"
63 |
64 | clickhouse3:
65 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
66 | ports:
67 | - "8126:8123"
68 | hostname: ch03
69 | container_name: clickhouse-server-ch03
70 | ulimits:
71 | nofile:
72 | soft: 262144
73 | hard: 262144
74 | networks:
75 | clickhouse-cluster:
76 | ipv4_address: 172.18.1.7
77 | extra_hosts:
78 | - "zk1:172.18.1.2"
79 | - "ch01:172.18.1.5"
80 | - "ch02:172.18.1.6"
81 | volumes:
82 | - ./ch-conf_1zk-3shard-3replica/metrika_ch03.xml:/etc/metrika.xml
83 | depends_on:
84 | - "zookeeper"
85 |
86 | networks:
87 | clickhouse-cluster:
88 | driver: bridge
89 | ipam:
90 | driver: default
91 | config:
92 | - subnet: 172.18.1.0/16
93 |
--------------------------------------------------------------------------------
/clickhouse_3zk-3shard-1replica.yml:
--------------------------------------------------------------------------------
1 | # Author: Al-assad
2 | # Email: yulinying_1994@outlook.com
3 | # Date: 2020-11-27
4 | # Description: docker compose for clickhouse cluster with 3 shards and 1 replica, 3 zookeeper node
5 |
6 | version: '2.1'
7 |
8 | services:
9 |
10 | zk1:
11 | image: zookeeper:3.6
12 | hostname: zk1
13 | container_name: clickhouse-zookeeper-zk1
14 | networks:
15 | clickhouse-cluster:
16 | ipv4_address: 172.18.1.2
17 | environment:
18 | ZOO_MY_ID: 1
19 | ZOO_PORT: 2181
20 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
21 |
22 | zk2:
23 | image: zookeeper:3.6
24 | hostname: zk2
25 | container_name: clickhouse-zookeeper-zk2
26 | networks:
27 | clickhouse-cluster:
28 | ipv4_address: 172.18.1.3
29 | environment:
30 | ZOO_MY_ID: 2
31 | ZOO_PORT: 2181
32 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
33 |
34 | zk3:
35 | image: zookeeper:3.6
36 | hostname: zk3
37 | container_name: clickhouse-zookeeper-zk3
38 | networks:
39 | clickhouse-cluster:
40 | ipv4_address: 172.18.1.4
41 | environment:
42 | ZOO_MY_ID: 3
43 | ZOO_PORT: 2181
44 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
45 |
46 | clickhouse1:
47 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
48 | ports:
49 | - "8124:8123"
50 | hostname: ch01
51 | container_name: clickhouse-server-ch01
52 | ulimits:
53 | nofile:
54 | soft: 262144
55 | hard: 262144
56 | networks:
57 | clickhouse-cluster:
58 | ipv4_address: 172.18.1.5
59 | extra_hosts:
60 | - "zk1:172.18.1.2"
61 | - "zk2:172.18.1.3"
62 | - "zk3:172.18.1.4"
63 | - "ch02:172.18.1.6"
64 | - "ch03:172.18.1.7"
65 | volumes:
66 | - ./ch-conf_3zk-3shard-1replica/metrika_ch01.xml:/etc/metrika.xml
67 | depends_on:
68 | - "zk1"
69 | - "zk2"
70 | - "zk3"
71 |
72 | clickhouse2:
73 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
74 | ports:
75 | - "8125:8123"
76 | hostname: ch02
77 | container_name: clickhouse-server-ch02
78 | ulimits:
79 | nofile:
80 | soft: 262144
81 | hard: 262144
82 | networks:
83 | clickhouse-cluster:
84 | ipv4_address: 172.18.1.6
85 | extra_hosts:
86 | - "zk1:172.18.1.2"
87 | - "zk2:172.18.1.3"
88 | - "zk3:172.18.1.4"
89 | - "ch01:172.18.1.5"
90 | - "ch03:172.18.1.7"
91 | volumes:
92 | - ./ch-conf_3zk-3shard-1replica/metrika_ch02.xml:/etc/metrika.xml
93 | depends_on:
94 | - "zk1"
95 | - "zk2"
96 | - "zk3"
97 |
98 | clickhouse3:
99 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
100 | ports:
101 | - "8126:8123"
102 | hostname: ch03
103 | container_name: clickhouse-server-ch03
104 | ulimits:
105 | nofile:
106 | soft: 262144
107 | hard: 262144
108 | networks:
109 | clickhouse-cluster:
110 | ipv4_address: 172.18.1.7
111 | extra_hosts:
112 | - "zk1:172.18.1.2"
113 | - "zk2:172.18.1.3"
114 | - "zk3:172.18.1.4"
115 | - "ch01:172.18.1.5"
116 | - "ch02:172.18.1.6"
117 | volumes:
118 | - ./ch-conf_3zk-3shard-1replica/metrika_ch03.xml:/etc/metrika.xml
119 | depends_on:
120 | - "zk1"
121 | - "zk2"
122 | - "zk3"
123 |
124 | networks:
125 | clickhouse-cluster:
126 | driver: bridge
127 | ipam:
128 | driver: default
129 | config:
130 | - subnet: 172.18.1.0/16
131 |
--------------------------------------------------------------------------------
/clickhouse_3zk-3shard-3replica.yml:
--------------------------------------------------------------------------------
1 | # Author: Al-assad
2 | # Email: yulinying_1994@outlook.com
3 | # Date: 2020-11-27
4 | # Description: docker compose for clickhouse cluster with 3 shards and 1 replica, 3 zookeeper node
5 |
6 | version: '2.1'
7 |
8 | services:
9 |
10 | zk1:
11 | image: zookeeper:3.6
12 | hostname: zk1
13 | container_name: clickhouse-zookeeper-zk1
14 | networks:
15 | clickhouse-cluster:
16 | ipv4_address: 172.18.1.2
17 | environment:
18 | ZOO_MY_ID: 1
19 | ZOO_PORT: 2181
20 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
21 |
22 | zk2:
23 | image: zookeeper:3.6
24 | hostname: zk2
25 | container_name: clickhouse-zookeeper-zk2
26 | networks:
27 | clickhouse-cluster:
28 | ipv4_address: 172.18.1.3
29 | environment:
30 | ZOO_MY_ID: 2
31 | ZOO_PORT: 2181
32 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
33 |
34 | zk3:
35 | image: zookeeper:3.6
36 | hostname: zk3
37 | container_name: clickhouse-zookeeper-zk3
38 | networks:
39 | clickhouse-cluster:
40 | ipv4_address: 172.18.1.4
41 | environment:
42 | ZOO_MY_ID: 3
43 | ZOO_PORT: 2181
44 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
45 |
46 | clickhouse1:
47 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
48 | ports:
49 | - "8124:8123"
50 | hostname: ch01
51 | container_name: clickhouse-server-ch01
52 | ulimits:
53 | nofile:
54 | soft: 262144
55 | hard: 262144
56 | networks:
57 | clickhouse-cluster:
58 | ipv4_address: 172.18.1.5
59 | extra_hosts:
60 | - "zk1:172.18.1.2"
61 | - "zk2:172.18.1.3"
62 | - "zk3:172.18.1.4"
63 | - "ch02:172.18.1.6"
64 | - "ch03:172.18.1.7"
65 | volumes:
66 | - ./ch-conf_3zk-3shard-3replica/metrika_ch01.xml:/etc/metrika.xml
67 | depends_on:
68 | - "zk1"
69 | - "zk2"
70 | - "zk3"
71 |
72 | clickhouse2:
73 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
74 | ports:
75 | - "8125:8123"
76 | hostname: ch02
77 | container_name: clickhouse-server-ch02
78 | ulimits:
79 | nofile:
80 | soft: 262144
81 | hard: 262144
82 | networks:
83 | clickhouse-cluster:
84 | ipv4_address: 172.18.1.6
85 | extra_hosts:
86 | - "zk1:172.18.1.2"
87 | - "zk2:172.18.1.3"
88 | - "zk3:172.18.1.4"
89 | - "ch01:172.18.1.5"
90 | - "ch03:172.18.1.7"
91 | volumes:
92 | - ./ch-conf_3zk-3shard-3replica/metrika_ch02.xml:/etc/metrika.xml
93 | depends_on:
94 | - "zk1"
95 | - "zk2"
96 | - "zk3"
97 |
98 | clickhouse3:
99 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
100 | ports:
101 | - "8126:8123"
102 | hostname: ch03
103 | container_name: clickhouse-server-ch03
104 | ulimits:
105 | nofile:
106 | soft: 262144
107 | hard: 262144
108 | networks:
109 | clickhouse-cluster:
110 | ipv4_address: 172.18.1.7
111 | extra_hosts:
112 | - "zk1:172.18.1.2"
113 | - "zk2:172.18.1.3"
114 | - "zk3:172.18.1.4"
115 | - "ch01:172.18.1.5"
116 | - "ch02:172.18.1.6"
117 | volumes:
118 | - ./ch-conf_3zk-3shard-3replica/metrika_ch03.xml:/etc/metrika.xml
119 | depends_on:
120 | - "zk1"
121 | - "zk2"
122 | - "zk3"
123 |
124 | networks:
125 | clickhouse-cluster:
126 | driver: bridge
127 | ipam:
128 | driver: default
129 | config:
130 | - subnet: 172.18.1.0/16
131 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | # Author: Al-assad
2 | # Email: yulinying_1994@outlook.com
3 | # Date: 2020-11-27
4 | # Description: docker compose for clickhouse cluster with 3 shards and 1 relica, 1 zookeeper node
5 |
6 | version: '2.1'
7 |
8 | services:
9 |
10 | zookeeper:
11 | image: zookeeper:3.6
12 | hostname: zk1
13 | container_name: clickhouse-zookeeper
14 | ports:
15 | - "2181:2181"
16 | networks:
17 | clickhouse-cluster:
18 | ipv4_address: 172.18.1.2
19 |
20 | clickhouse1:
21 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
22 | ports:
23 | - "8124:8123"
24 | hostname: ch01
25 | container_name: clickhouse-server-ch01
26 | ulimits:
27 | nofile:
28 | soft: 262144
29 | hard: 262144
30 | networks:
31 | clickhouse-cluster:
32 | ipv4_address: 172.18.1.5
33 | extra_hosts:
34 | - "zk1:172.18.1.2"
35 | - "ch02:172.18.1.6"
36 | - "ch03:172.18.1.7"
37 | volumes:
38 | - ./ch-conf/metrika_ch01.xml:/etc/metrika.xml
39 | depends_on:
40 | - "zookeeper"
41 |
42 | clickhouse2:
43 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
44 | ports:
45 | - "8125:8123"
46 | hostname: ch02
47 | container_name: clickhouse-server-ch02
48 | ulimits:
49 | nofile:
50 | soft: 262144
51 | hard: 262144
52 | networks:
53 | clickhouse-cluster:
54 | ipv4_address: 172.18.1.6
55 | extra_hosts:
56 | - "zk1:172.18.1.2"
57 | - "ch01:172.18.1.5"
58 | - "ch03:172.18.1.7"
59 | volumes:
60 | - ./ch-conf/metrika_ch02.xml:/etc/metrika.xml
61 | depends_on:
62 | - "zookeeper"
63 |
64 | clickhouse3:
65 | image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-20.11}
66 | ports:
67 | - "8126:8123"
68 | hostname: ch03
69 | container_name: clickhouse-server-ch03
70 | ulimits:
71 | nofile:
72 | soft: 262144
73 | hard: 262144
74 | networks:
75 | clickhouse-cluster:
76 | ipv4_address: 172.18.1.7
77 | extra_hosts:
78 | - "zk1:172.18.1.2"
79 | - "ch01:172.18.1.5"
80 | - "ch02:172.18.1.6"
81 | volumes:
82 | - ./ch-conf/metrika_ch03.xml:/etc/metrika.xml
83 | depends_on:
84 | - "zookeeper"
85 |
86 | networks:
87 | clickhouse-cluster:
88 | driver: bridge
89 | ipam:
90 | driver: default
91 | config:
92 | - subnet: 172.18.1.0/16
93 |
--------------------------------------------------------------------------------