我试着用卡夫卡。 所有配置都正确完成,但当我试图从控制台产生消息时,我一直得到以下错误

WARN Error while fetching metadata with correlation id 39 : 
     {4-3-16-topic1=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

Kafka版本:2.11-0.9.0.0


当前回答

在服务器上添加侦听器设置后,问题得到解决。属性文件位于配置目录。 listener =PLAINTEXT://localhost(或您的服务器):9092 修改完成后重新启动kafka。使用版本2.11

其他回答

这是我在config/server中添加的。属性,这解决了我的问题类似上述问题。希望这有助于,它在服务器中有很好的文档。属性文件,在修改此文件之前,请尝试阅读和理解。 advertised.listeners =明文:/ / < your_kafka_server_ip >: 9092

我也得到了同样的错误消息

获取关联id为39的元数据时出错: {4-3-16-topic1 = LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

解决步骤:

去C:\Windows\System32\drivers\etc\hosts 如果下面的行不存在,那么将它添加到hosts文件的末尾

127.0.0.1       localhost

打开C:\<Kafka_Config_Path>\server。属性,并在文件末尾添加

    advertised.listeners = PLAINTEXT://localhost:9092
    listeners = PLAINTEXT://0.0.0.0:9092

重新启动Kafka服务器

对我来说,这是由于配置失误造成的 Docker端口(9093) Kafka命令端口"bin/ Kafka -console-producer.sh——broker-list localhost:9092——topic TopicName" 我检查了我的配置匹配端口,现在一切正常

如果你得到这样重复的错误消息:

Error while fetching metadata with correlation id 3991 : {your.topic=LEADER_NOT_AVAILABLE}

Or

Discovered group coordinator 172.25.1.2:9092 (id: 2147483645 rack: null) (org.apache.kafka.clients.consumer.internals.AbstractCoordinator:677)
(Re-)joining group (org.apache.kafka.clients.consumer.internals.AbstractCoordinator:509)
Group coordinator 172.25.1.2:9092 (id: 2147483645 rack: null) is unavailable or invalid, will attempt rediscovery (org.apache.kafka.clients.consumer.internals.AbstractCoordinator:729)
Discovered group coordinator 172.25.40.219:9092 (id: 2147483645 rack: null) (org.apache.kafka.clients.consumer.internals.AbstractCoordinator:677)
Group coordinator 172.25.1.2:9092 (id: 2147483645 rack: null) is unavailable or invalid, will attempt rediscovery (org.apache.kafka.clients.consumer.internals.AbstractCoordinator:729)

然后,你需要像这样在kafka server.properties中配置监听器:

 listeners=PLAINTEXT://your.server.ip:9092

这是在Kafka 2.5.0和confluent 5.4.1平台上尝试的解决方案。

For all those struggling with the Kafka ssl setup and seeing this LEADER_NOT_AVAILABLE error. One of the reasons that might be broken is the keystore and truststore. In the keystore you need to have private key of the server + signed server certificate. In the client truststore, you need to have intermedidate CA certificate so that client can authenticate the kafka server. If you will use ssl for interbroker communication, you need this truststore also set in the server.properties of the brokers so they can authenticate each other.

我错误地漏掉了最后一篇文章,这让我痛苦地花了很多时间去寻找这个LEADER_NOT_AVAILABLE错误可能意味着什么。希望这能帮助到一些人。