kafka啟動報錯(Cluster ID)不匹配問題以及解決
kafka啟動報錯(Cluster ID)不匹配問題
有時候在啟動Kafka的時候會出現(xiàn)如下報錯信息:
InconsistentClusterIdException: The Cluster ID -A0n-rHCT9e5IadkrA0tkw doesn't match stored clusterId Some(E-xpRlfuRqicvCYyRf9O9w) in meta.properties.
The broker is trying to join the wrong cluster.
Configured zookeeper.connect may be wrong.
個人嘗試的解決方法
是找到上面提到的meta.properties文件,這個文件在kafka的bin目錄下的installkafka_2.13-2.5.0logs目錄下
(如果是Windows系統(tǒng),則在bin/windows目錄)
這個目錄是在Kafka初次成功啟動后就自動生成的,后續(xù)創(chuàng)建主題和索引偏移量等信息都會在這個目錄
目錄文件如下

installkafka_2.13-2.5.0logs目錄
將該文件中的cluster.id的值改成和報錯信息中的值一樣即可,不需要其他操作:

但還是要注意該操作會不會對之前生產(chǎn)的數(shù)據(jù)造成影響(雖然我自己測試的結果是沒有影響,之前消費過的數(shù)據(jù)仍然能夠消費)。
下面附上Kafka的一些操作命令
- 啟動zookeeper:
.\zookeeper-server-start.bat ..\..\config\zookeeper.properties
- 啟動Kafka:
.\kafka-server-start.bat ..\..\config\server.properties
- 創(chuàng)建主題:
.\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic 主題名稱1
- 查看主題:
.\kafka-topics.bat --zookeeper localhost:2181 --list
- 生產(chǎn)者生產(chǎn)消息:
.\kafka-console-producer.bat --broker-list localhost:9092 --topic 主題名稱1
- 消費者消費消息:
.\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic 主題名稱1 --from-beginning
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
IDEA啟動報錯Internal?error.?Please?refer?to?https://jb.gg/i
這篇文章主要介紹了IDEA啟動報錯Internal?error.?Please?refer?to?https://jb.gg/ide/critical-startup-errors解決辦法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-04-04

