Kafka各种报错

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.消费者无法接收到消息

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)

原因:本来当做单机服务器,把数据文件删除掉再启动
Kafka各种报错_第1张图片

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中报错解决

你可能感兴趣的:(Kafka)