This is a simple example of how to run a clickhouse cluster with docker-compose.
- Install docker-compose (https://docs.docker.com/compose/install/)
- Create a
clickhouse-net
network viadocker network create clickhouse-net
- Run
make start
to start the cluster - Run
make connect
to connect to the cluster - Run
make stop
to stop the cluster - Run
make clean
to clean up the cluster - Run
make clean-containers
to clean up the docker containers
Additionally, you can run make attach-r1
to attach to the first replica
container or make attach-r2
to attach to the second replica container.
This can be useful for looking at the logs in real time.
The cluster is composed of 3 shards (s1, s2, s3) with 2 replicas (r1, r2) per shard. Each replica is a separate docker container. First replica of each shard is used to also serve clickhouse-keeper.
The cluster can be configured to use the ch-server
docker image, which is a
customized version of the official clickhouse image. To build ch-server
:
- Put
clickhouse
binary in./docker/server/
directory - Run
make build-server