如何在集群模式下运行Flare
打开选择加入的多节点 ClickHouse 集群而不是默认的 单节点部署 — 一旦单个 ClickHouse 无法满足需求,就会非常有用 节点的冗余或吞吐量。其实际作用及其原因 以此方式构建,请参阅 the clustering explanation;对于确切的 配置键,请参阅 the reference。
先决条件
- Docker,与独立部署相同。
- 一套新鲜的卷。集群模式不是实时迁移路径 - 不要将其指向现有单节点部署的数据。
步骤
1.从repo root开始,启动集群堆栈而不是默认的 撰写文件:
docker compose -f docker-compose.cluster.yml up -d
这会产生 4 个 ClickHouse 节点(2 个分片 × 2 个副本),一个 3 节点
Keeper 仲裁、一个用于身份存储(用户、会话、API 密钥、身份验证设置,参见
ADR-0111)的
PostgreSQL 容器、两个 Flare.Ingest 副本、Flare.Api 和
仪表板。 docker-compose.yml(单节点默认值)保持不变
并且不受影响——两者是独立的堆栈。
- 等待所有服务报告运行状况良好(
docker compose -f docker-compose.cluster.yml ps)。架构会自动应用:一次性的clickhouse-migrate服务运行一次迁移后退出,其他服务在它之后启动。 无需手动运行迁移步骤。
验证它是否有效
# Cluster topology - expect 4 rows (2 shards x 2 replicas):
docker exec <clickhouse-1 container> clickhouse-client --user default --password flare \
--query "SELECT cluster, shard_num, replica_num, host_name FROM system.clusters WHERE cluster = 'flare_cluster'"
# Table engines - every app table appears twice (Distributed + Replicated*_local):
docker exec <clickhouse-1 container> clickhouse-client --user default --password flare \
--query "SELECT name, engine FROM system.tables WHERE database = 'clickhousedb' ORDER BY name"
# Two Flare.Ingest replicas sharing one Redis Streams consumer group - expect two
# distinct, machine/process-derived consumer names, both showing recent activity:
docker exec <redis container> redis-cli -a flare --no-auth-warning \
XINFO CONSUMERS flare:logs flare-ingest
# Drain pattern-cluster keys, shared across both replicas - send logs matching the same
# template split across ingest-1/ingest-2, then confirm one bucket key holds the merged
# cluster (not two separate per-replica templates):
docker exec <redis container> redis-cli -a flare --no-auth-warning \
KEYS "flare:patterns:bucket:*"
docker exec <redis container> redis-cli -a flare --no-auth-warning \
GET "flare:patterns:bucket:<key from above>"
# Cluster-status panel's own endpoint - expect the same 4 rows as the system.clusters
# query above, plus clusterModeEnabled/sharedPatternStoreEnabled/replicationInfoAvailable
# all true, and each node's replicationQueueSize/replicationLagSeconds at or near 0 on an
# idle cluster:
curl -s http://localhost:8080/api/indexing/cluster | jq
# Replication currency, straight from system.replicas, for comparison against the
# endpoint's own replicationQueueSize/replicationLagSeconds per node:
docker exec <clickhouse-1 container> clickhouse-client --user default --password flare \
--query "SELECT hostName(), database, table, queue_size, absolute_delay FROM system.replicas"
然后打开仪表板:日志页面的模式模式应显示一个
row/PatternId 表示重复模板,而不是两个碎片行,并且
索引页面的 Cluster 面板应显示所有 4 个节点均运行正常且处于正常状态
同步。
故障排除
集群模式具有已发现并修复的设置问题的真实历史 通过反复将其与新书进行比较——参见 the operational-notes investigation 如果有些事情没有完全解决;大部分已经存在了 已修复在当前的撰写文件中,但调查记录了 万一一种变体重新出现时出现的症状。
在更改此处的任何内容之前,值得了解一个正确性约束: 如果您需要更改表的分片方式(请参阅 ADR-0003), 必须首先销毁并重新创建现有的集群卷 - 这是 与初始设置相同的“仅限新卷”规则,但故障模式 跳过它是默默地错误的查询结果,而不是错误。
2026-10-02 之前创建的集群会在基于 span 的聚合(Services、Map、External APIs)中
将每个 span 计数两次:分片未设置 internal_replication,因此每个副本都会在自己那份
插入数据上运行物化视图。db/clickhouse-cluster/config/remote-servers.xml 现已设置该项,
新数据因此正确。已写入的行仍是双倍计数,直到您重新创建集群卷。
最后更新: