ClickHouse - High Availability
Enabling High Availability on a ClickHouse cluster does not make your data replicate on its own. Replication depends on the table engine you choose, which surprises most people the first time.
What happens when High Availability is enabled on a ClickHouse cluster?
The service automatically creates additional replicas for each shard. Replication itself only takes effect on tables you create with a replicated table engine.
Replication supports the MergeTree family only:
- ReplicatedMergeTree
- ReplicatedSummingMergeTree
- ReplicatedReplacingMergeTree
- ReplicatedAggregatingMergeTree
- ReplicatedCollapsingMergeTree
- ReplicatedVersionedCollapsingMergeTree
- ReplicatedGraphiteMergeTree
See Replicated table engines in the ClickHouse documentation.
Does replication work at the server level or the table level?
At the table level. Replicated and non-replicated tables can sit on the same server, so one unreplicated table does not affect the rest.
Does replication depend on sharding?
No. Replication is independent of sharding, and each shard replicates on its own.
This is where clusters most often lose data unexpectedly. A table created as MergeTree rather than ReplicatedMergeTree is never replicated, even with HA enabled on the cluster. Its data lives only on the node that received the write.
Enabling HA does not protect a MergeTree table. Check the engine on every table you rely on, not just the cluster setting.