Docker-compose script for quickly building a ClickHouse cluster environment, based on the official clickhouse/clickhouse-server image, supports custom clickhosue-server versions.
The default component version is as follows :
- zookeeper:3.6;
- clickHouse-server:20.11 ;
git clone https://github.com/Al-assad/clickhouse-cluster-docker.git
docker-compose up
The default created cluster nodes includes 1 zookeeper node, 3 clickhosue-server nodes (3 shards, 1 replica each node).
-
Access via host machine ip:
clickhouse-server-ch01 127.0.0.1:8124 clickhouse-server-ch02 127.0.0.1:8125 clickhouse-server-ch03 127.0.0.1:8126
-
Access via docker subnetwork ip:
If your docker host machine is MacOS, you can access the docker subnetwork directly through the project wenjunxiao/mac-docker-connector.
clickhouse-server-ch01 172.18.1.5:8123 clickhouse-server-ch02 172.18.1.6:8123 clickhouse-server-ch03 172.18.1.7:8123
Then you can connect the clickhouse-server cluster through DBeaver GUI Tool or clickhosue-client command-line tool. Enjoy it : )
# single zookeeper node,clickhosue 3 shards and 1 replica
docker-compose -f clickhosue_1zk-3shard-1replica up
# single zookeeper node,clickhosue 3 shards and 3 replicas
docker-compose -f clickhosue_1zk-3shard-3replica up
# 3 zookeeper 3 nodes,clickhosue 3 shards and 1 replica
docker-compose -f clickhosue_3zk-3shard-1replica up
# 3 zookeeper 3 nodes,clickhosue 3 shards and 3 replicas
docker-compose -f clickhosue_3zk-3shard-3replica up
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
.
Of course, You can customize the CH image version by modifying the environment variable CLICKHOUSE_VERSION
.
# use clickhouse-server v23.8.4
export CLICKHOUSE_VERSION=23.8.4 && docker-compose config