Skip to content

Commit

Permalink
🧹 refactor: enhance clickhouse cluster support (featbit#500)
Browse files Browse the repository at this point in the history
* feat: enhence clickhouse cluster support

* feat: 3 brokers kafka cluster in docker

* update requirements.txt

* kafka user and pass

---------

Co-authored-by: deleteLater <[email protected]>
  • Loading branch information
dsun0720 and deleteLater authored Oct 13, 2023
1 parent c1f7d75 commit 29446fd
Show file tree
Hide file tree
Showing 35 changed files with 1,059 additions and 31 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<clickhouse>
<!-- Listen wildcard address to allow accepting connections from other containers and host network. -->
<listen_host>::</listen_host>
<listen_host>0.0.0.0</listen_host>
<listen_try>1</listen_try>
<max_concurrent_queries>1000</max_concurrent_queries>
<!--
<logger>
<console>1</console>
</logger>
-->

<!-- Kafka -->
<kafka>
<security_protocol>sasl_plaintext</security_protocol>
<sasl_username>kafka</sasl_username>
<sasl_password>bitnami</sasl_password>
<sasl_mechanisms>PLAIN</sasl_mechanisms>
</kafka>

</clickhouse>
32 changes: 32 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-1/enable_keeper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<clickhouse>
<keeper_server>
<tcp_port>9181</tcp_port>
<server_id>1</server_id>
<log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
<snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>

<coordination_settings>
<operation_timeout_ms>10000</operation_timeout_ms>
<session_timeout_ms>30000</session_timeout_ms>
<raft_logs_level>trace</raft_logs_level>
</coordination_settings>

<raft_configuration>
<server>
<id>1</id>
<hostname>clickhouse-blue-1</hostname>
<port>9234</port>
</server>
<server>
<id>2</id>
<hostname>clickhouse-blue-2</hostname>
<port>9234</port>
</server>
<server>
<id>3</id>
<hostname>clickhouse-green-1</hostname>
<port>9234</port>
</server>
</raft_configuration>
</keeper_server>
</clickhouse>
10 changes: 10 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-1/macros.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<clickhouse>
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
<macros>
<cluster>events</cluster>
<shard>blue</shard>
<replica>r1</replica>
</macros>
</clickhouse>
39 changes: 39 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-1/remote_servers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<clickhouse>
<remote_servers>
<featbit_ch_cluster>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-blue-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-blue-2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-green-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-green-2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-orange-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-orange-2</host>
<port>9000</port>
</replica>
</shard>
</featbit_ch_cluster>
</remote_servers>
</clickhouse>
16 changes: 16 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-1/use_keeper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<clickhouse>
<zookeeper>
<node index="1">
<host>clickhouse-blue-1</host>
<port>9181</port>
</node>
<node index="2">
<host>clickhouse-blue-2</host>
<port>9181</port>
</node>
<node index="3">
<host>clickhouse-green-1</host>
<port>9181</port>
</node>
</zookeeper>
</clickhouse>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<clickhouse>
<!-- Listen wildcard address to allow accepting connections from other containers and host network. -->
<listen_host>::</listen_host>
<listen_host>0.0.0.0</listen_host>
<listen_try>1</listen_try>
<max_concurrent_queries>1000</max_concurrent_queries>
<!--
<logger>
<console>1</console>
</logger>
-->

<!-- Kafka -->
<kafka>
<security_protocol>sasl_plaintext</security_protocol>
<sasl_username>kafka</sasl_username>
<sasl_password>bitnami</sasl_password>
<sasl_mechanisms>PLAIN</sasl_mechanisms>
</kafka>

</clickhouse>
32 changes: 32 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-2/enable_keeper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<clickhouse>
<keeper_server>
<tcp_port>9181</tcp_port>
<server_id>2</server_id>
<log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
<snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>

<coordination_settings>
<operation_timeout_ms>10000</operation_timeout_ms>
<session_timeout_ms>30000</session_timeout_ms>
<raft_logs_level>trace</raft_logs_level>
</coordination_settings>

<raft_configuration>
<server>
<id>1</id>
<hostname>clickhouse-blue-1</hostname>
<port>9234</port>
</server>
<server>
<id>2</id>
<hostname>clickhouse-blue-2</hostname>
<port>9234</port>
</server>
<server>
<id>3</id>
<hostname>clickhouse-green-1</hostname>
<port>9234</port>
</server>
</raft_configuration>
</keeper_server>
</clickhouse>
10 changes: 10 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-2/macros.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<clickhouse>
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
<macros>
<cluster>events</cluster>
<shard>blue</shard>
<replica>r2</replica>
</macros>
</clickhouse>
39 changes: 39 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-2/remote_servers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<clickhouse>
<remote_servers>
<featbit_ch_cluster>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-blue-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-blue-2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-green-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-green-2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-orange-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-orange-2</host>
<port>9000</port>
</replica>
</shard>
</featbit_ch_cluster>
</remote_servers>
</clickhouse>
16 changes: 16 additions & 0 deletions infra/clickhouse/shards/clickhouse-blue-2/use_keeper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<clickhouse>
<zookeeper>
<node index="1">
<host>clickhouse-blue-1</host>
<port>9181</port>
</node>
<node index="2">
<host>clickhouse-blue-2</host>
<port>9181</port>
</node>
<node index="3">
<host>clickhouse-green-1</host>
<port>9181</port>
</node>
</zookeeper>
</clickhouse>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<clickhouse>
<!-- Listen wildcard address to allow accepting connections from other containers and host network. -->
<listen_host>::</listen_host>
<listen_host>0.0.0.0</listen_host>
<listen_try>1</listen_try>
<max_concurrent_queries>1000</max_concurrent_queries>
<!--
<logger>
<console>1</console>
</logger>
-->

<!-- Kafka -->
<kafka>
<security_protocol>sasl_plaintext</security_protocol>
<sasl_username>kafka</sasl_username>
<sasl_password>bitnami</sasl_password>
<sasl_mechanisms>PLAIN</sasl_mechanisms>
</kafka>

</clickhouse>
32 changes: 32 additions & 0 deletions infra/clickhouse/shards/clickhouse-green-1/enable_keeper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<clickhouse>
<keeper_server>
<tcp_port>9181</tcp_port>
<server_id>3</server_id>
<log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
<snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>

<coordination_settings>
<operation_timeout_ms>10000</operation_timeout_ms>
<session_timeout_ms>30000</session_timeout_ms>
<raft_logs_level>trace</raft_logs_level>
</coordination_settings>

<raft_configuration>
<server>
<id>1</id>
<hostname>clickhouse-blue-1</hostname>
<port>9234</port>
</server>
<server>
<id>2</id>
<hostname>clickhouse-blue-2</hostname>
<port>9234</port>
</server>
<server>
<id>3</id>
<hostname>clickhouse-green-1</hostname>
<port>9234</port>
</server>
</raft_configuration>
</keeper_server>
</clickhouse>
10 changes: 10 additions & 0 deletions infra/clickhouse/shards/clickhouse-green-1/macros.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<clickhouse>
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
<macros>
<cluster>events</cluster>
<shard>green</shard>
<replica>r1</replica>
</macros>
</clickhouse>
39 changes: 39 additions & 0 deletions infra/clickhouse/shards/clickhouse-green-1/remote_servers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<clickhouse>
<remote_servers>
<featbit_ch_cluster>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-blue-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-blue-2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-green-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-green-2</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>clickhouse-orange-1</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse-orange-2</host>
<port>9000</port>
</replica>
</shard>
</featbit_ch_cluster>
</remote_servers>
</clickhouse>
16 changes: 16 additions & 0 deletions infra/clickhouse/shards/clickhouse-green-1/use_keeper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<clickhouse>
<zookeeper>
<node index="1">
<host>clickhouse-blue-1</host>
<port>9181</port>
</node>
<node index="2">
<host>clickhouse-blue-2</host>
<port>9181</port>
</node>
<node index="3">
<host>clickhouse-green-1</host>
<port>9181</port>
</node>
</zookeeper>
</clickhouse>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<clickhouse>
<!-- Listen wildcard address to allow accepting connections from other containers and host network. -->
<listen_host>::</listen_host>
<listen_host>0.0.0.0</listen_host>
<listen_try>1</listen_try>
<max_concurrent_queries>1000</max_concurrent_queries>
<!--
<logger>
<console>1</console>
</logger>
-->

<!-- Kafka -->
<kafka>
<security_protocol>sasl_plaintext</security_protocol>
<sasl_username>kafka</sasl_username>
<sasl_password>bitnami</sasl_password>
<sasl_mechanisms>PLAIN</sasl_mechanisms>
</kafka>

</clickhouse>
Loading

0 comments on commit 29446fd

Please sign in to comment.