简体   繁体   English

如何使用 sarama go 客户端连接 zookeeper?

[英]How to connect zookeeper using sarama go client?

I am a beginner at using the sarama client.我是使用 sarama 客户端的初学者。 Although my code is working fine with the bootstrap servers but unable to connect with the zookeepers.虽然我的代码在引导服务器上运行良好,但无法连接到动物园管理员。

kafka node version: confluent-kafka-2.11-0.10.2.1-2.noarch kafka节点版本: confluent-kafka-2.11-0.10.2.1-2.noarch
sarama client version: v1.38.0 sarama客户端版本: v1.38.0

config := kafka.NewConfig()
broker := []string{"localhost:9092"}
kafkaClient, err := kafka.NewClusterAdmin(broker, config)

Error:错误:
kafka: client has run out of available brokers to talk to: EOF kafka:客户已经用完可用的经纪人来与之交谈:EOF

Your error simply says Kafka isn't running at the host:port you've provided, and has nothing to do with Zookeeper您的错误只是说Kafka没有在您提供的主机:端口上运行,并且与 Zookeeper 无关


Sarama is a Kafka client . Sarama 是Kafka 客户端 You should not be using it to connect to Zookeeper.您不应该使用它来连接到 Zookeeper。

If you need to execute Zookeeper operations, you will need a different library, but you should never need Zookepeer operations for a Kafka application.如果您需要执行 Zookeeper 操作,您将需要一个不同的库,但您永远不需要 Kafka 应用程序的 Zookepeer 操作。 KafkaAdminClient will forward any requests to Zookeeper, if it needs to (unless you run Kafka in Kraft mode, where Zookeeper isn't used).如果需要, KafkaAdminClient会将任何请求转发给 Zookeeper(除非您在不使用 Zookeeper 的 Kraft 模式下运行 Kafka)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Sarama 单独或批量提交消息 - 用于 Go 的 kafka 客户端 - Commit message Individually or Batchwise using Sarama - kafka client for Go 如何使用Sarama Go Kafka Consumer从最新的抵消量消费 - How to consume from latest offset using Sarama Go Kafka Consumer go(sarama)中连接kafka,消费者无法通过topic获取消息 - Connect kafka in go(sarama), the consumer can not get message through topic 如何在GO中的GCE中连接到客户端 - How to connect to client in GCE in GO Kafka Consumer:如何以编程方式从 Go Sarama 中的特定偏移量消费 - Kafka Consumer: How to programatically consume from specific offset in Go Sarama 如何为 kafka 消费者添加自定义消息反序列化器(使用 sarama lib) - How to add custom message deserializer for kafka consumer(using sarama lib) 如何使用 Sarama 从多个 goroutine 中的 Kafka 主题中消费? - How to consume from Kafka topic in multiple goroutines, using Sarama? 如何使用 Shopify/sarama golang 库为 kafka 中的主题添加 consumerGroup? - How to add consumerGroup for a topic in kafka using Shopify/sarama golang library? go-zookeeper Connect在没有有效连接的情况下返回 - go-zookeeper Connect returns without a valid connection Go lang / client:如何使用 go/client 描述节点 - Go lang / client : How to describe a node using go/ client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM