Feat: Add clickhouse cluster mode setup via docker compose#1749
Feat: Add clickhouse cluster mode setup via docker compose#1749
Conversation
Long term goal is to run all the tests both in single node and multi-node cluster. Signed-off-by: Kaviraj <[email protected]>
|
|
||
| server { | ||
| listen 8123; | ||
| client_max_body_size 100M; |
There was a problem hiding this comment.
is this limitation documented? I think it may cause someone investigating "strange" issue if testing big payload.
I would put some readme and text about it. In general it would be good to have a readme about what this docker compose does and what components are present.
There was a problem hiding this comment.
If any client try to send request more than configured value, nginix will send the proper error message with the status code (413 request entity too large). Tested it on local by setting 10 bytes client_max_body_size
$ curl -X POST http://localhost:8123 -d "SELECT 1"
1
$ curl -X POST http://localhost:8123 -d "more than 10 bytes of payload"
<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.23.1</center>
</body>
</html>
$
There was a problem hiding this comment.
Pull request overview
This PR introduces a Docker Compose-based ClickHouse cluster setup for testing purposes, supporting both TCP (native) and HTTP protocols with load balancing via Nginx.
Key Changes:
- Added a new
docker-compose.cluster.ymlfile that defines a 2-node ClickHouse cluster with Nginx as a load balancer - Configured Nginx to provide round-robin load balancing for both HTTP (port 8123) and TCP (port 9000) connections
- Created ClickHouse server configuration files for cluster coordination, replication, and Keeper setup
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docker-compose.yml | Updated to use parameterized ClickHouse version with alpine variant as default |
| docker-compose.cluster.yml | New cluster configuration defining two ClickHouse nodes and Nginx load balancer |
| .docker/nginx/tcp.conf | TCP stream configuration for load balancing native ClickHouse protocol |
| .docker/nginx/nginx.conf | Main Nginx configuration with HTTP and stream modules |
| .docker/nginx/http.conf | HTTP configuration for load balancing ClickHouse HTTP interface |
| .docker/clickhouse/users.xml | User configuration with default user and random load balancing |
| .docker/clickhouse/cluster/server1_config.xml | Configuration for first cluster node including Keeper and replication settings |
| .docker/clickhouse/cluster/server2_config.xml | Configuration for second cluster node including Keeper and replication settings |
| .docker/clickhouse/cluster/server1_macros.xml | Macro definitions for first node (cluster, replica, shard identifiers) |
| .docker/clickhouse/cluster/server2_macros.xml | Macro definitions for second node (cluster, replica, shard identifiers) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <port>9100</port> | ||
| </replica> | ||
| <replica> | ||
| <host>clickhouse2</host> | ||
| <port>9100</port> |
There was a problem hiding this comment.
The port 9100 specified in the remote_servers configuration does not match the Keeper/Raft port (9181) or the standard TCP port (9000). This appears to be a misconfiguration that would prevent cluster communication. The replica ports should likely be 9000 to match the tcp_port configuration on line 5.
| <port>9100</port> | |
| </replica> | |
| <replica> | |
| <host>clickhouse2</host> | |
| <port>9100</port> | |
| <port>9000</port> | |
| </replica> | |
| <replica> | |
| <host>clickhouse2</host> | |
| <port>9000</port> |
| <port>9100</port> | ||
| </replica> | ||
| <replica> | ||
| <host>clickhouse2</host> | ||
| <port>9100</port> |
There was a problem hiding this comment.
The port 9100 specified in the remote_servers configuration does not match the Keeper/Raft port (9181) or the standard TCP port (9000). This appears to be a misconfiguration that would prevent cluster communication. The replica ports should likely be 9000 to match the tcp_port configuration on line 5.
| <port>9100</port> | |
| </replica> | |
| <replica> | |
| <host>clickhouse2</host> | |
| <port>9100</port> | |
| <port>9000</port> | |
| </replica> | |
| <replica> | |
| <host>clickhouse2</host> | |
| <port>9000</port> |
| <port>9100</port> | ||
| </server> | ||
| <server> | ||
| <id>2</id> | ||
| <hostname>clickhouse2</hostname> | ||
| <port>9100</port> |
There was a problem hiding this comment.
The Raft configuration port 9100 does not match the keeper_server tcp_port 9181 configured on line 46. Keeper nodes should communicate using the port specified in keeper_server/tcp_port. Update this to 9181 for proper Keeper cluster communication.
| <port>9100</port> | |
| </server> | |
| <server> | |
| <id>2</id> | |
| <hostname>clickhouse2</hostname> | |
| <port>9100</port> | |
| <port>9181</port> | |
| </server> | |
| <server> | |
| <id>2</id> | |
| <hostname>clickhouse2</hostname> | |
| <port>9181</port> |
| <port>9100</port> | ||
| </server> | ||
| <server> | ||
| <id>2</id> | ||
| <hostname>clickhouse2</hostname> | ||
| <port>9100</port> |
There was a problem hiding this comment.
The Raft configuration port 9100 does not match the keeper_server tcp_port 9181 configured on line 46. Keeper nodes should communicate using the port specified in keeper_server/tcp_port. Update this to 9181 for proper Keeper cluster communication.
| <port>9100</port> | |
| </server> | |
| <server> | |
| <id>2</id> | |
| <hostname>clickhouse2</hostname> | |
| <port>9100</port> | |
| <port>9181</port> | |
| </server> | |
| <server> | |
| <id>2</id> | |
| <hostname>clickhouse2</hostname> | |
| <port>9181</port> |
Signed-off-by: Kaviraj <[email protected]>
We need cluster mode setup for testing (both manual testing and automated). Both TCP(native) and HTTP
Long term goal is to run all the tests both in single node and multi-node cluster.
Lot's of cluster mode configurations are copied from clickhouse-js client.. But that setup doesn't support TCP load-balancing. I added support for TCP on top of it.
I made sure it works with TCP.
Run the cluster
Check 2 nodes cluster with nginx proxy for both HTTP and TCP
Connect to TCP via proxy
Connect to HTTP via proxy
Summary
Checklist
Delete items not relevant to your PR: