问题现象:
clickhouse 数据库,执行分布式DDL(建库、建表、删库、删表等)时,永远卡在49%,超过180秒以后,自动转为后台。
cjcdb01 :) create database cjc ON CLUSTER ck_cjc_cluster;
CREATE DATABASE cjc ON CLUSTER ck_cjc_cluster
Query id: x0cxxx92-xxdc-430b-b7f1-06bxxxx3dxx0
┌─host────────┬──port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ 192.0.10.11 │ 9100 │ 0 │ │ 5 │ 0 │
│ 192.0.10.12 │ 9100 │ 0 │ │ 4 │ 0 │
│ 192.0.10.13 │ 9100 │ 0 │ │ 3 │ 0 │
└─────────────┴───────┴────────┴───────┴─────────────────────┴──────────────────┘
→ Progress: 3.00 rows, 165.00 B (0.05 rows/s., 2.59 B/s.) 49%
↖ Progress: 3.00 rows, 165.00 B (0.02 rows/s., 1.27 B/s.) 49%
↘ Progress: 3.00 rows, 165.00 B (0.02 rows/s., 0.91 B/s.) 49%
3 rows in set. Elapsed: 180.665 sec.
Received exception from server (version 23.3.8):
Code: 159. DB::Exception: Received from cjcdb01:9000. DB::Exception: Watching task /clickhouse/9000/task_queue/ddl/query-0000000000 is executing longer than distributed_ddl_task_timeout (=180) seconds. There are 3 unfinished hosts (0 of them are currently active), they are going to execute the query in background. (TIMEOUT_EXCEEDED)
架构说明:
ck部署在3台服务器上,每台服务器上配置两个ck实例,端口分别为9100和9200,架构是3分片2副本架构。
问题原因:
通过前台显示,9100实例分布式DDL语句执行成功了,登陆9200实例,发现执行失败。
由于一台服务器上安装两个实例,两个实例的端口和路径配置都不同。
其中有一个配置分布式DDL的参数,两个实例的配置分别为:
9100端口:
<distributed_ddl>
<path>/clickhouse/9100/task_queue/ddl</path>
</distributed_ddl>
9200端口:
<distributed_ddl>
<path>/clickhouse/9200/task_queue/ddl</path>
</distributed_ddl>
实际上这种配置方式是有问题的,因为这块配置的实际是zookeeper的路径,不是clickhouse的路径,当有分布式DDL执行时是在zookeeper的<distributed_ddl>路径下生成数据,
而不是clickhouse的<distributed_ddl>路径下。
解决方案:
所以这块需要修改为相同的路径,修改后的参数:
9100端口:
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
9200端口:
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
修改后,不需要重启,再次执行分布式DDL,可以瞬间执行完成。
###chenjuchao 20241001###
欢迎关注我的公众号《IT小Chen》