Clickhouse supports distribution and replication of data, but the documentation around it is confusing and setting up a cluster is not straight forward.
I will use VMware Workstations servers(click1, click2 and click3). Operating System is Ubuntu 20.04.4 LTS (Focal Fossa) for all 3 servers(click1, click2 and click3) and Clickhouse version is 22.10.1.1160 for 2 servers (click2, click3).
Here is the Clickhouse Cluster Structure.
To build our cluster, we’re going to follow these main steps:
- Install and Configure Zookeeper
- Install and Configure Clickhouse for 2 nodes (click2, click3)
- Test the Clickhouse Cluster
- Create a sample Replicated table for Cluster
Install and Configure Zookeeper
ZooKeeper version 3.4.5 and greater is required for ClickHouse clusters. In this case, we’ll be installing the most current version from the Ubuntu repository, using the following command. Not: Just install Zookeeper for 1 node (click1)