問題
最近上線跑了一個(gè)flink任務(wù),運(yùn)行不久,就會(huì)掛掉,初步查看日志報(bào)錯(cuò)如下
WARN org.apache.flink.connector.kafka.source.reader.KafkaSourceReader [] - Failed to commit consumer offsets for checkpoint 1
org.apache.kafka.clients.consumer.RetriableCommitFailedException: Offset commit failed with a retriable exception. You should retry committing the latest consumed offsets.
Caused by: org.apache.kafka.common.errors.CoordinatorNotAvailableException: The coordinator is not available.
報(bào)錯(cuò)原因?yàn)門he coordinator is not available.
報(bào)錯(cuò)在網(wǎng)上搜了一下,根據(jù)網(wǎng)友的經(jīng)驗(yàn),是消費(fèi)組協(xié)調(diào)leader不存在導(dǎo)致
查看kafka __consumer_offsets topic
kafka-topics.sh -bootstrap-server node1:9092,node2:9092,node3:9092,node4:9092,node5:9092 --topic __consumer_offsets --describe
發(fā)現(xiàn)確實(shí)有Leader:none的
可能原因是 __consumer_offset topic的默認(rèn)分區(qū)是50,但是備份只有1份; kafka集群部署了5臺(tái),也就是5個(gè)brokers
消費(fèi)者組連接kafka,并會(huì)請(qǐng)求某一臺(tái)來查找Coordinator(協(xié)調(diào)者),如果連接的機(jī)器上沒有備份就不會(huì)有Leader,就會(huì)出現(xiàn)
找不到Coordinator(協(xié)調(diào)者)
查看offsets.topic.replication.factor默認(rèn)配置文章來源:http://www.zghlxwxcb.cn/news/detail-483981.html
cat kafak/config/server.properties | grep offsets.topic.replication.factor
默認(rèn)值果然只是1;文章來源地址http://www.zghlxwxcb.cn/news/detail-483981.html
解決方式
- 1、停止kafka, 修改kafka配置 config/server.properties添加
修改成broker的數(shù)量
offsets.topic.replication.factor=3
- 2、刪除zookeeper配置信息
./bin/zkCli.sh -server 127.0.0.1:2181
- 刪除/config/topics/__consumer_offsets
delete /config/topics/__consumer_offsets
- 刪除/brokers/topics/__consumer_offsets
deleteall /brokers/topics/__consumer_offsets
- 3、重啟kafka
到了這里,關(guān)于【異常解決】The coordinator is not available的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!