我试着用卡夫卡。 所有配置都正确完成,但当我试图从控制台产生消息时,我一直得到以下错误
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
我试着用卡夫卡。 所有配置都正确完成,但当我试图从控制台产生消息时,我一直得到以下错误
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
当前回答
以我为例,它在家里工作得很好,但在办公室里,当我连接到办公室网络时,它就不行了。
所以修改了config/server.properties 监听器=明文://:9092 to监听器=明文://localhost:9092
在我的例子中,我是在描述消费者群体时得到的
其他回答
我让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实例指定代理id。 当它在Docker环境中重启时,有时会从zookeeper获取一个新的id。 如果您的代理id大于1000,只需指定环境变量KAFKA_BROKER_ID。
使用它可以查看代理、主题和分区。
brew install kafkacat
kafkacat -b [kafka_ip]:[kafka_poot] -L
我也得到了同样的错误消息
获取关联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服务器
当我们试图订阅一个尚未创建的主题时,我们往往会收到这条消息。我们通常依赖于在部署环境中预先创建的主题,但我们有针对dockerized kafka实例运行的组件测试,每次都干净启动。
在这种情况下,我们在测试设置中使用AdminUtils来检查主题是否存在,如果不存在就创建它。有关设置AdminUtils的更多信息,请参阅另一个堆栈溢出。
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错误可能意味着什么。希望这能帮助到一些人。