docker部署Clickhouse集群遇到的坑--第一部

项目场景:

在使用docker部署Clickhouse集群时,遇到的各种坑

问题一

``执行select * from system.clusters;查看集群信息,没有显示出集群信息,说明分布式集群搭建失败,如以下图1

┌─cluster───────────────────────────┬─shard_num─┬─replica_num─┬─host_name─┬─port─┬─user────┐
 default1 │ test_cluster_two_shards           │         11127.0.0.19000default2 │ test_cluster_two_shards           │         21127.0.0.29000default3 │ test_cluster_two_shards_localhost │         11 │ localhost │ 9000default4 │ test_cluster_two_shards_localhost │         21 │ localhost │ 9000default5 │ test_shard_localhost              │         11 │ localhost │ 9000default6 │ test_shard_localhost_secure       │         11 │ localhost │ 9440default7 │ test_unavailable_shard            │         11 │ localhost │ 9000default8 │ test_unavailable_shard            │         21 │ localhost │    1default9 └───────────────────────────────────┴───────────┴─────────────┴───────────┴──────┴───────

原因分析:

看了下资料中显示的集群信息是要有集群名,集群节点ip等信息的,而不是以上只显示出单机信息:

例如:以下图2为正确的,其中perf_3s_1r是集群的名字,在/etc/metrika.xml里面设置`┌─cluster───────────────────────────┬─shard_num─┬─replica_num─┬─host_name─┬─port─┬─user────┐
1 │ perf_3s_1r │ 1 │ 1 │ master │ 9000 │ default │
2 │ perf_3s_1r │ 2 │ 1 │ slaver1 │ 9000 │ default │
3 │ perf_3s_1r │ 3 │ 1 │ slaver2 │ 9000 │ default │
4 │ test_cluster_two_shards │ 1 │ 1 │ 127.0.0.1 │ 9000 │ default │
5 │ test_cluster_two_shards │ 2 │ 1 │ 127.0.0.2 │ 9000 │ default │
6 │ test_cluster_two_shards_localhost │ 1 │ 1 │ localhost │ 9000 │ default │
7 │ test_cluster_two_shards_localhost │ 2 │ 1 │ localhost │ 9000 │ default │
8 │ test_shard_localhost │ 1 │ 1 │ localhost │ 9000 │ default │
9 │ test_shard_localhost_secure │ 1 │ 1 │ localhost │ 9440 │ default │
10 │ test_unavailable_shard │ 1 │ 1 │ localhost │ 9000 │ default │
11 │ test_unavailable_shard │ 2 │ 1 │ localhost │ 1 │ default │
└───────────────────────────────────┴───────────┴─────────────┴–仔细分析,现在的现象就是集群配置没有生效。clickhouse应该是通过config.xml文件加载集群配置,看了这篇文章后,幡然醒悟:https://www.cnblogs.com/fkdby/articles/15242373.html 链接可能已经失效,暂时只贴出config.xml的关键信息:

<include_from>/etc/metrika-node1.xml</include_from>
<remote_servers incl="clickhouse_remote_servers" />
<zookeeper incl="zookeeper-servers" optional="true" />
<macros incl="macros" optional="true" />

从这里面可以看出,config.xml是通过以上配置和metrika.xml文件进行联动,以下贴出部分metrika.xml的配置,clickhouse_remote_servers、 zookeeper-servers、macros命名要与metrika.xml中一致:

<yandex>
<clickhouse_remote_servers>
<!-- clickhouse_remote_servers、 zookeeper-servers、macros命名要与config.xml中一致-->
<!-- 以下perf_3s_1r就是分布式集群的名字-->
<perf_3s_1r>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>ch201</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>ch202</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>ch203</host>
<port>9000</port>
</replica>
</shard>
</perf_3s_1r>
</clickhouse_remote_servers>

<!--zookeeper相关配置-->
<zookeeper-servers>
<node index="1">
<host>ch201</host>
<port>2181</port>
</node>
<node index="2">
<host>ch202</host>
<port>2181</port>
</node>
<node index="3">
<host>ch203</host>
<port>2181</port>
</node>
</zookeeper-servers>

<macros>
<replica>ch203</replica>
</macros>

<networks>
<ip>::/0</ip>
</networks>

<clickhouse_compression>
<case>
<min_part_size>10000000000</min_part_size>
<min_part_size_ratio>0.01</min_part_size_ratio>
<method>lz4</method>
</case>
</clickhouse_compression>

</yandex>
<!-- 其中大部分配置一样,以下的配置根据节点的IP/域名具体配置,当前是ch201容器上添加的metrika.xml配置 -->
<macros>
<replica>ch201</replica>
</macros>

解决方案:

在config.xml里添加以下配置,请在集群每台节点上添加:

<include_from>/etc/metrika-node1.xml</include_from>
<remote_servers incl="clickhouse_remote_servers" />
<zookeeper incl="zookeeper-servers" optional="true" />
<macros incl="macros" optional="true" />

搭建参考1
集群信息未显示参考2

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

day-day-up2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值