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

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


当前回答

我知道这是很久以前发布的,我想分享我是如何解决它的。 因为我有我的办公室笔记本电脑(VPN和代理配置)。 我检查了环境变量NO_PROXY

> echo %NO_PROXY%

返回空值 现在我已经设置了NO_PROXY与localhost和127.0.0.1

> set NO_PROXY=127.0.0.1,localhost  

如果您想追加现有值,则

> set NO_PROXY=%NO_PROXY%,127.0.0.1,localhost  

在这之后,我重新启动了zookeeper和kafka 工作起来很有魅力

其他回答

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错误可能意味着什么。希望这能帮助到一些人。

这个警告(在0.10.2.1中)的另一种可能是,你试图对一个刚刚创建的主题进行投票,而这个主题分区的领导者还不可用,你正在进行领导者选举。

在主题创建和轮询之间等待一秒钟是一种变通方法。

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

我让kafka作为Docker容器运行,类似的消息充斥在日志中。 KAFKA_ADVERTISED_HOST_NAME被设置为'kafka'。

在我的例子中,错误的原因是在“kafka”容器本身中缺少“kafka”的/etc/hosts记录。 因此,例如,在'kafka'容器中运行ping kafka将失败,使用ping: bad address 'kafka'

在Docker中,这个问题可以通过指定容器的主机名来解决。

实现它的选项:

Docker run——hostname… Docker运行-add-host… docker-compose中的主机名 AWS EC2任务定义中的主机名

如果你在本地机器上运行kafka,尝试更新$KAFKA_DIR/config/server。以下行包含的属性: //localhost:9092然后重启kafka。