溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

kafka啟動報錯 missingTopicsFatal is true怎么辦

發(fā)布時間:2021-07-05 09:45:30 來源:億速云 閱讀:589 作者:小新 欄目:開發(fā)技術(shù)

小編給大家分享一下kafka啟動報錯 missingTopicsFatal is true怎么辦,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

kafka 啟動報錯:missingTopicsFatal is true

報錯信息

org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is java.lang.IllegalStateException: Topic(s) [async] is/are not present and missingTopicsFatal is true
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:894) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]

報錯原因:消費監(jiān)聽接口監(jiān)聽的主題不存在時,默認會報錯

解決方法:

配置文件中將listener的屬性missingTopicsFatal設(shè)置為false

spring:
  kafka:
    listener:
      missing-topics-fatal: false

kafka常見報錯警告異常解決

1.自行修改server.properties中broker id后造成與meta.properties中數(shù)據(jù)不匹配

kafka.common.InconsistentBrokerIdException: Configured broker.id 2 doesn't match stored broker.id 1 in meta.properties. If you moved your data, make sure your configured broker.id matches. If you intend to create a new broker, you should remove all data in your data directories (log.dirs).

kafka啟動報錯 missingTopicsFatal is true怎么辦

2.__consumer_offsets這個topic是由kafka自動創(chuàng)建的,默認49個,這個topic是不能被刪除的!

Error while executing topic command : Topic __consumer_offsets is a kafka internal topic and is not allowed to be marked for deletion.

kafka啟動報錯 missingTopicsFatal is true怎么辦

為什么這里會是這樣存儲__consumer_offsets的呢:

  • [1.] 將所有 N Broker 和待分配的 i 個 Partition 排序

  • [2.] 將第 i 個 Partition 分配到第(i mod n)個 Broker 上

3.刪除topic時

Topic frist is already marked for deletion.

kafka啟動報錯 missingTopicsFatal is true怎么辦

徹底刪除topic:

  • [1. ] 刪除Topic,delete.topic.enable=true這里要設(shè)置為true

  • [2. ] 刪除log日志

  • [3. ] 刪除ZK中的Topic記錄

kafka啟動報錯 missingTopicsFatal is true怎么辦

命令:./bin/zkCli.sh

找到topic所在的目錄:ls /brokers/topics

執(zhí)行命令:rmr /brokers/topics/{topic name}即可,此時topic被徹底刪除。

另外被標(biāo)記為marked for deletion的topic你可以在zookeeper客戶端中通過命令獲得:ls /admin/delete_topics/{topic name},如果你刪除了此處的topic,那么marked for deletion 標(biāo)記消失

當(dāng)然,這里是你delete.topic.enable設(shè)置為false時Zookeeper下才會有這個節(jié)點。

以上是“kafka啟動報錯 missingTopicsFatal is true怎么辦”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI