在测试 ClickHouse 分布式表时,创建分布式表成功,但是查询数据时报错,如下:

Received exception from server (version 22.2.2):
Code: 516. DB::Exception: Received from 192.168.38.101:9000. DB::Exception: Received from 192.168.38.103:9000. DB::Exception: default: Authentication failed: pass
word is incorrect or there is no user with such name. (AUTHENTICATION_FAILED)

排查后发现,是集群开始安装时设置了密码,而配置分布式表时,没有添加各服务器的用户名和密码,所以访问不到别的服务器的数据,在我们的/etc/clickhouse-server/config.d/metrika.xml中,加入用户名和密码即可正常查询数据,如下: 


   
   
  1. <clickhouse_remote_servers>
  2. <!--market_ck_cluster:for market business and Marketing platform-->
  3. <market_ck_cluster>
  4. <shard>
  5. <internal_replication>true </internal_replication>
  6. <replica>
  7. <host>192.168.38.101 </host>
  8. <port>9000 </port>
  9. <user>default </user>
  10. <password>123456 </password>
  11. <password_sha256_hex>8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92 </password_sha256_hex>
  12. </replica>
  13. <replica>
  14. <host>192.168.38.102 </host>
  15. <port>9000 </port>
  16. <user>default </user>
  17. <password>123456 </password> <password_sha256_hex>8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92 </password_sha256_hex>
  18. </replica>
  19. </shard>
  20. <shard>
  21. <internal_replication>true </internal_replication>
  22. <replica>
  23. <host>192.168.38.103 </host>
  24. <port>9000 </port>
  25. <user>default </user>
  26. <password>123456 </password>
  27. <password_sha256_hex>8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92 </password_sha256_hex>
  28. </replica>
  29. </shard>
  30. </market_ck_cluster>
  31. </clickhouse_remote_servers>


就是这两行:


   
   
  1. <user>default </user>
  2. <password>123456 </password>

 修改完成后,查询分布式成功:


   
   
  1. node102 :) select dt , count(id) from dbapi_db.dwd_middle_homework_students_correct_detail_1_all group by dt order by dt;
  2. SELECT
  3. dt,
  4. count(id)
  5. FROM dbapi_db.dwd_middle_homework_students_correct_detail_1_all
  6. GROUP BY dt
  7. ORDER BY dt ASC
  8. Query id: 1409ea4e -0f74 -417d -9026 -8409a2e4e887
  9. ┌─dt─────────┬─ count(id)─┐
  10. 2022 -06 -09522346
  11. 2022 -06 -10460020
  12. └────────────┴───────────┘
  13. 2 rows in set. Elapsed: 0.052 sec. Processed 982.37 thousand rows, 51.08 MB ( 19.05 million rows /s., 990.39 MB /s.)

问题解决,开始开心的学习.....

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐