DanRoscigno / clickhouse-keeper-example

Setup ClickHouse cluster with replication using `clickhouse-keeper`

Home Page:https://mrkaran.dev/posts/clickhouse-replication/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ClickHouse Keeper Example

An example of running a local ClickHouse cluster using clickhouse-keeper for replication.

Config examples accompanying the blog post.

Generate Config

make gen-clickhouse-config

Run Containers

make up

Setup Cluster Schema

docker-compose exec clickhouse-blue-1 clickhouse-client  

Run all the commands present inside schema.sql.

Query all shards/replicas

SELECT * FROM
(
    SELECT hostName(), *
    FROM remote('172.20.0.2', 'app', 'events_local')
    UNION ALL
    SELECT hostName(), *
    FROM remote('172.20.0.3', 'app', 'events_local')
    UNION ALL
    SELECT hostName(), *
    FROM remote('172.20.0.4', 'app', 'events_local')
    UNION ALL
    SELECT hostName(), *
    FROM remote('172.20.0.5', 'app', 'events_local')
    UNION ALL
    SELECT hostName(), *
    FROM remote('172.20.0.6', 'app', 'events_local')
    UNION ALL
    SELECT hostName(), *
    FROM remote('172.20.0.7', 'app', 'events_local')
);

Replace the private IPs with the host_address you find inside your cluster:

SELECT
    host_name,
    host_address
FROM system.clusters

About

Setup ClickHouse cluster with replication using `clickhouse-keeper`

https://mrkaran.dev/posts/clickhouse-replication/

License:MIT License


Languages

Language:Makefile 100.0%