我试着用卡夫卡。 所有配置都正确完成,但当我试图从控制台产生消息时,我一直得到以下错误
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错误可能意味着什么。希望这能帮助到一些人。
其他回答
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错误可能意味着什么。希望这能帮助到一些人。
我尝试了这里列出的所有建议。对我有用的是去服务器。属性和添加:
port = 9092
advertised.host.name = localhost
将监听器和advertised_listeners注释掉。
因为我想让我的kafka代理连接到远程生产者和消费者,所以我不想做广告。要注释掉的侦听器。在我的情况下,(在kubernetes上运行kafka),我发现我的kafka pod没有分配任何集群IP。通过从服务中删除行clusterIP: None。呵呵,kubernetes给kafka pod分配了一个内部ip。这解决了我的LEADER_NOT_AVAILABLE问题,也解决了kafka生产者/消费者的远程连接问题。
我也得到了同样的错误消息
获取关联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服务器
这个警告(在0.10.2.1中)的另一种可能是,你试图对一个刚刚创建的主题进行投票,而这个主题分区的领导者还不可用,你正在进行领导者选举。
在主题创建和轮询之间等待一秒钟是一种变通方法。