我是靠谱客的博主 明理美女,最近开发中收集的这篇文章主要介绍Kafka各种报错1.Replication factor: 2 larger than available brokers: 12.ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)3.Configured broker.id 130 doesn’t match stored broker.id 0 in meta.properties4.消费者启动报zookeeper is not a recognized option5.消费,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Kafka各种报错

  • 1.Replication factor: 2 larger than available brokers: 1
  • 2.ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
  • 3.Configured broker.id 130 doesn't match stored broker.id 0 in meta.properties
  • 4.消费者启动报zookeeper is not a recognized option
  • 5.消费者无法接收到消息
  • 6.ERROR Exiting Kafka due to fatal exception

1.Replication factor: 2 larger than available brokers: 1

ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 2 larger than available brokers: 1.

原因创建topic时–replication-factor 2,超过了broker的数量
使用zookeeper可以查看broker的数量

[root@localhost zookeeper-3.4.14]# ./bin/zkCli.sh -server 192.168.230.129
Connecting to 192.168.230.129
[zk: 192.168.230.129(CONNECTED) 2] ls /brokers/ids
[]

2.ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)

ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
java.nio.file.NoSuchFileException: config/server.properties
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
	at java.nio.file.Files.newByteChannel(Files.java:361)
	at java.nio.file.Files.newByteChannel(Files.java:407)
	at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
	at java.nio.file.Files.newInputStream(Files.java:152)
	at org.apache.kafka.common.utils.Utils.loadProps(Utils.java:574)
	at kafka.Kafka$.getPropsFromArgs(Kafka.scala:51)
	at kafka.Kafka$.main(Kafka.scala:67)
	at kafka.Kafka.main(Kafka.scala)

找不到properties文件所致,按下面的启动方式即可

[root@localhost local]# cd kafka_2.11-2.3.0/
[root@localhost kafka_2.11-2.3.0]# ./bin/kafka-server-start.sh config/server.properties &

3.Configured broker.id 130 doesn’t match stored broker.id 0 in meta.properties

ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentBrokerIdException: Configured broker.id 130 doesn't match stored broker.id 0 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).
	at kafka.server.KafkaServer.getBrokerIdAndOfflineDirs(KafkaServer.scala:712)
	at kafka.server.KafkaServer.startup(KafkaServer.scala:214)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
	at kafka.Kafka$.main(Kafka.scala:84)
	at kafka.Kafka.main(Kafka.scala)

原因:本来当做单机服务器,把数据文件删除掉再启动
在这里插入图片描述

4.消费者启动报zookeeper is not a recognized option

高版本启动改为 --bootstrap-server

bin/kafka-console-consumer.sh --bootstrap-server 192.168.230.128:2181 --topic MY_TOPIC --from-beginning

5.消费者无法接收到消息

若采用系列教程先单机安装,再集群安装,就会出现这个问题,这是因为broker.id改变的原因。
解决:请关闭kafka、zookeeper,清除data、log文件夹,重启即可,注意zookeeper的data文件夹里myid文件不要删除了!!!
zookeeper的清除可以参考:https://blog.csdn.net/sndayYU/article/details/100537922中报错解决

6.ERROR Exiting Kafka due to fatal exception

java.nio.file.NoSuchFileException: .ocnfigserver.properties, 应该是config…

D:YDGreenNewkafka_2.12-2.2.0>.binwindowskafka-server-start.bat .ocnfigserver.properties
[2021-08-25 15:21:42,584] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$)
[2021-08-25 15:21:42,640] ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
java.nio.file.NoSuchFileException: .ocnfigserver.properties
        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
        at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
        at java.nio.file.Files.newByteChannel(Files.java:361)
        at java.nio.file.Files.newByteChannel(Files.java:407)
        at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
        at java.nio.file.Files.newInputStream(Files.java:152)
        at org.apache.kafka.common.utils.Utils.loadProps(Utils.java:564)
        at kafka.Kafka$.getPropsFromArgs(Kafka.scala:42)
        at kafka.Kafka$.main(Kafka.scala:58)
        at kafka.Kafka.main(Kafka.scala)

最后

以上就是明理美女为你收集整理的Kafka各种报错1.Replication factor: 2 larger than available brokers: 12.ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)3.Configured broker.id 130 doesn’t match stored broker.id 0 in meta.properties4.消费者启动报zookeeper is not a recognized option5.消费的全部内容,希望文章能够帮你解决Kafka各种报错1.Replication factor: 2 larger than available brokers: 12.ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)3.Configured broker.id 130 doesn’t match stored broker.id 0 in meta.properties4.消费者启动报zookeeper is not a recognized option5.消费所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部