mkmkme / clickhouse-cluster-docker

A simple example of ClickHouse cluster with docker-compose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clickhouse cluster with docker-compose

This is a simple example of how to run a clickhouse cluster with docker-compose.

How to run

  1. Install docker-compose (https://docs.docker.com/compose/install/)
  2. Create a clickhouse-net network via docker network create clickhouse-net
  3. Run make start to start the cluster
  4. Run make connect to connect to the cluster
  5. Run make stop to stop the cluster
  6. Run make clean to clean up the cluster
  7. 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.

How it works

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:

  1. Put clickhouse binary in ./docker/server/ directory
  2. Run make build-server

Credits

About

A simple example of ClickHouse cluster with docker-compose

License:MIT License


Languages

Language:Shell 79.9%Language:Dockerfile 15.2%Language:Makefile 4.8%