{"id":7839634,"url":"https://github.com/tetafro/clickhouse-cluster","last_synced_at":"2025-10-06T16:15:39.908Z","repository":{"id":45778871,"uuid":"255107255","full_name":"tetafro/clickhouse-cluster","owner":"tetafro","description":"Simple clickhouse cluster with docker-compose","archived":false,"fork":false,"pushed_at":"2023-04-23T09:32:46.000Z","size":7,"stargazers_count":216,"open_issues_count":0,"forks_count":86,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-01T11:22:17.654Z","etag":null,"topics":["clickhouse","docker","docker-compose"],"latest_commit_sha":null,"homepage":null,"language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tetafro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-12T15:02:40.000Z","updated_at":"2025-03-29T02:24:43.000Z","dependencies_parsed_at":"2025-01-08T19:10:41.959Z","dependency_job_id":"744bdbef-f820-49ee-aebb-a81ec67f89ae","html_url":"https://github.com/tetafro/clickhouse-cluster","commit_stats":{"total_commits":17,"total_committers":4,"mean_commits":4.25,"dds":0.2941176470588235,"last_synced_commit":"513bf7324a2ac5cb88cea60baf2d8953eb27d4c4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetafro%2Fclickhouse-cluster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetafro%2Fclickhouse-cluster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetafro%2Fclickhouse-cluster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetafro%2Fclickhouse-cluster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tetafro","download_url":"https://codeload.github.com/tetafro/clickhouse-cluster/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247999864,"owners_count":21031046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clickhouse","docker","docker-compose"],"created_at":"2024-04-13T00:13:04.737Z","updated_at":"2025-10-06T16:15:34.857Z","avatar_url":"https://github.com/tetafro.png","language":"Makefile","funding_links":[],"categories":["Integrations"],"sub_categories":["Deployment and Management Tools"],"readme":"# Clickhouse Cluster\n\nClickhouse cluster with 2 shards and 2 replicas built with docker-compose.\n\nNot for production use.\n\n## Run\n\nRun single command, and it will copy configs for each node and\nrun clickhouse cluster `company_cluster` with docker-compose\n```sh\nmake config up\n```\n\nContainers will be available in docker network `172.23.0.0/24`\n\n| Container    | Address\n| ------------ | -------\n| zookeeper    | 172.23.0.10\n| clickhouse01 | 172.23.0.11\n| clickhouse02 | 172.23.0.12\n| clickhouse03 | 172.23.0.13\n| clickhouse04 | 172.23.0.14\n\n## Profiles\n\n- `default` - no password\n- `admin` - password `123`\n\n## Test it\n\nLogin to clickhouse01 console (first node's ports are mapped to localhost)\n```sh\nclickhouse-client -h localhost\n```\n\nOr open `clickhouse-client` inside any container\n```sh\ndocker exec -it clickhouse01 clickhouse-client -h localhost\n```\n\nCreate a test database and table (sharded and replicated)\n```sql\nCREATE DATABASE company_db ON CLUSTER 'company_cluster';\n\nCREATE TABLE company_db.events ON CLUSTER 'company_cluster' (\n    time DateTime,\n    uid  Int64,\n    type LowCardinality(String)\n)\nENGINE = ReplicatedMergeTree('/clickhouse/tables/{cluster}/{shard}/events', '{replica}')\nPARTITION BY toDate(time)\nORDER BY (uid);\n\nCREATE TABLE company_db.events_distr ON CLUSTER 'company_cluster' AS company_db.events\nENGINE = Distributed('company_cluster', company_db, events, uid);\n```\n\nLoad some data\n```sql\nINSERT INTO company_db.events_distr VALUES\n    ('2020-01-01 10:00:00', 100, 'view'),\n    ('2020-01-01 10:05:00', 101, 'view'),\n    ('2020-01-01 11:00:00', 100, 'contact'),\n    ('2020-01-01 12:10:00', 101, 'view'),\n    ('2020-01-02 08:10:00', 100, 'view'),\n    ('2020-01-03 13:00:00', 103, 'view');\n```\n\nCheck data from the current shard\n```sql\nSELECT * FROM company_db.events;\n```\n\nCheck data from all cluster\n```sql\nSELECT * FROM company_db.events_distr;\n```\n\n## Add more nodes\n\nIf you need more Clickhouse nodes, add them like this:\n\n1. Add replicas/shards to `config.xml` to the block `company/remote_servers/company_cluster`.\n1. Add nodes to `docker-compose.yml`.\n1. Add nodes in `Makefile` in `config` target.\n\n## Start, stop\n\nStart/stop the cluster without removing containers\n```sh\nmake start\nmake stop\n```\n\n## Teardown\n\nStop and remove containers\n```sh\nmake down\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetafro%2Fclickhouse-cluster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftetafro%2Fclickhouse-cluster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetafro%2Fclickhouse-cluster/lists"}