``执行select * from system.clusters;查看集群信息,没有显示出集群信息,说明分布式集群搭建失败,如以下图1:
┌─cluster───────────────────────────┬─shard_num─┬─replica_num─┬─host_name─┬─port─┬─user────┐ default │ 1 │ test_cluster_two_shards │ 1 │ 1 │ 127.0.0.1 │ 9000 │ default │ 2 │ test_cluster_two_shards │ 2 │ 1 │ 127.0.0.2 │ 9000 │ default │ 3 │ test_cluster_two_shards_localhost │ 1 │ 1 │ localhost │ 9000 │ default │ 4 │ test_cluster_two_shards_localhost │ 2 │ 1 │ localhost │ 9000 │ default │ 5 │ test_shard_localhost │ 1 │ 1 │ localhost │ 9000 │ default │ 6 │ test_shard_localhost_secure │ 1 │ 1 │ localhost │ 9440 │ default │ 7 │ test_unavailable_shard │ 1 │ 1 │ localhost │ 9000 │ default │ 8 │ test_unavailable_shard │ 2 │ 1 │ localhost │ 1 │ default │ 9 └───────────────────────────────────┴───────────┴─────────────┴───────────┴──────┴───────
原因分析:
看了下资料中显示的集群信息是要有集群名,集群节点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的关键信息:
/etc/metrika-node1.xml
从这里面可以看出,config.xml是通过以上配置和metrika.xml文件进行联动,以下贴出部分metrika.xml的配置,clickhouse_remote_servers、 zookeeper-servers、macros命名要与metrika.xml中一致:
解决方案:true ch201 9000 true ch202 9000 true ch203 9000 ch201 2181 ch202 2181 ch203 2181 ch203 ::/0 10000000000 0.01 lz4 ch201
在config.xml里添加以下配置,请在集群每台节点上添加:
/etc/metrika-node1.xml
搭建参考1
集群信息未显示参考2



