我试着用卡夫卡。 所有配置都正确完成,但当我试图从控制台产生消息时,我一直得到以下错误
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
当前回答
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错误可能意味着什么。希望这能帮助到一些人。
其他回答
试试这个监听器=PLAINTEXT://localhost:9092 一定很有帮助
非常感谢
对我来说,这是由于配置失误造成的 Docker端口(9093) Kafka命令端口"bin/ Kafka -console-producer.sh——broker-list localhost:9092——topic TopicName" 我检查了我的配置匹配端口,现在一切正常
对我来说,原因是使用了一个特定的Zookeeper,这不是Kafka包的一部分。该Zookeeper已经安装在机器上用于其他目的。显然卡夫卡不会和任何一个动物园管理员合作。切换到卡夫卡附带的Zookeeper为我解决了这个问题。为了不与现有的Zookeeper发生冲突,我不得不修改我的配置,让Zookeeper监听不同的端口:
[root@host /opt/kafka/config]# grep 2182 *
server.properties:zookeeper.connect=localhost:2182
zookeeper.properties:clientPort=2182
加上这个,因为它可能会帮助其他人。一个常见的问题可能是advertised.host.name配置错误。在Docker中,使用Docker -compose设置KAFKA_ADVERTISED_HOST_NAME中的服务名称将不起作用,除非你也设置了主机名。docker-compose。yml例子:
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
hostname: kafka
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_CREATE_TOPICS: "test:1:1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
上面没有hostname: kafka可以在尝试连接时发出一个LEADER_NOT_AVAILABLE。 您可以在这里找到一个工作docker-compose配置的示例
这是我在config/server中添加的。属性,这解决了我的问题类似上述问题。希望这有助于,它在服务器中有很好的文档。属性文件,在修改此文件之前,请尝试阅读和理解。 advertised.listeners =明文:/ / < your_kafka_server_ip >: 9092