Kafka主题存在,但不能从经纪人那里获得

问题描述 投票:0回答:1

我有1,000多个主题。中断后,我发现列出主题时仅显示少数主题。如果我写一个现有的但不可用的主题,它说:

[2020-04-17 16:17:09,153] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 2 : {ONLP_NEWORDER_1428=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)

但是,此后后续写入成功,并且该主题可用并且在列出所有主题时显示。我有什么办法可以使主题再次出现而无需写信?]

apache-kafka kafka-consumer-api kafka-producer-api
1个回答
0
投票

kafka代理上线的延迟可能是由于以下两种情况之一:

  1. 领袖选举中的延迟
  2. Kafka配置为在发布第一条消息时创建主题。

场景1:推迟选举领导人:

错误消息-O NLP_NEWORDER_1428 = LEADER_NOT_AVAILABLE表示该主题的Leader节点尚未联机。

中断后,领导者选举将花费一些时间(几秒钟到几分钟,这取决于配置和网络条件)

通过优化kafka配置,可以最大程度地减少领导人选举的时间。

有关优化kafka的更多信息:

https://www.confluent.io/wp-content/uploads/Optimizing-Your-Apache-Kafka-Deployment-1.pdf

方案2:Kafka配置为在发布第一条消息时创建主题

默认情况下,当制作人发布第一条消息时,kafka设置为创建主题。

    This setting controls the automatic creation of topics.

    producer.auto.create.topics 


    The possible values for this setting are:

    allow-server-side  --> Default. Create topic on first message published

    client-side        --> Create topic at the first request from a consumer

    false              --> Do not create topics automatically

((a)允许服务器端

  • 这是默认设置
  • 此设置允许制作人自动创建主题如果代理的“ auto.create.topics.enable”设置设置为true

((b)false-确实允许创建自动主题。

(c)客户端

当使用者尝试使用消息时,允许创建主题。(仅在经纪人上受支持>仅0.10.1.1版)

更多信息:

https://cwiki.apache.org/confluence/display/KAFKA/KIP-487%3A+Client-side+Automatic+Topic+Creation+on+Producer

https://docs.confluent.io/current/installation/configuration/broker-configs.html

https://docs.confluent.io/current/installation/configuration/producer-configs.html

https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/kafka-working-with-topics/content/creating_a_kafka_topic.html

© www.soinside.com 2019 - 2024. All rights reserved.