创建新主题时,kafka服务器控制台出现错误



我正在尝试学习卡夫卡,并刚刚开始学习。

我正在运行一个带有单个代理的kafka集群,当我创建一个新主题时,我在kafka服务器控制台上收到以下错误。

[2020-03-06 06:26:15,458] ERROR [KafkaApi-0] Error when handling request: clientId=0, correlationId=1, api=LEADER_AND_ISR, version=4, body={controller_id=0,controller_epoch=1,broker_epoch=25,topic_states=[{topic_name=t_one,partition_states=[{partition_index=1,controller_epoch=1,leader=0,leader_epoch=0,isr=[0],zk_version=0,replicas=[0],adding_replicas=[],removing_replicas=[],is_new=true,_tagged_fields={}},{partition_index=0,controller_epoch=1,leader=0,leader_epoch=0,isr=[0],zk_version=0,replicas=[0],adding_replicas=[],removing_replicas=[],is_new=true,_tagged_fields={}},{partition_index=2,controller_epoch=1,leader=0,leader_epoch=0,isr=[0],zk_version=0,replicas=[0],adding_replicas=[],removing_replicas=[],is_new=true,_tagged_fields={}}],_tagged_fields={}}],live_leaders=[{broker_id=0,host_name=127.0.0.1,port=9092,_tagged_fields={}}],_tagged_fields={}} (kafka.server.KafkaApis)
java.io.IOException: Invalid argument
at sun.nio.ch.FileChannelImpl.map0(Native Method)
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:924)
at kafka.log.AbstractIndex.<init>(AbstractIndex.scala:127)
at kafka.log.OffsetIndex.<init>(OffsetIndex.scala:54)
at kafka.log.LazyIndex$$anonfun$forOffset$1.apply(LazyIndex.scala:72)
at kafka.log.LazyIndex$$anonfun$forOffset$1.apply(LazyIndex.scala:72)
at kafka.log.LazyIndex$$anonfun$get$1.apply(LazyIndex.scala:59)
at kafka.log.LazyIndex$$anonfun$get$1.apply(LazyIndex.scala:56)
at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:253)
at kafka.log.LazyIndex.get(LazyIndex.scala:55)
at kafka.log.LogSegment.offsetIndex(LogSegment.scala:65)
at kafka.log.LogSegment.readNextOffset(LogSegment.scala:457)
at kafka.log.Log.kafka$log$Log$$recoverLog(Log.scala:809)
at kafka.log.Log$$anonfun$2.apply$mcJ$sp(Log.scala:724)
at kafka.log.Log$$anonfun$2.apply(Log.scala:724)
at kafka.log.Log$$anonfun$2.apply(Log.scala:724)
at kafka.log.Log.retryOnOffsetOverflow(Log.scala:2327)
at kafka.log.Log.loadSegments(Log.scala:723)
at kafka.log.Log.<init>(Log.scala:298)
at kafka.log.Log$.apply(Log.scala:2460)
at kafka.log.LogManager$$anonfun$getOrCreateLog$1.apply(LogManager.scala:759)
at kafka.log.LogManager$$anonfun$getOrCreateLog$1.apply(LogManager.scala:724)
at scala.Option.getOrElse(Option.scala:121)
at kafka.log.LogManager.getOrCreateLog(LogManager.scala:724)
at kafka.cluster.Partition.createLog(Partition.scala:326)
at kafka.cluster.Partition.createLogIfNotExists(Partition.scala:310)
at kafka.cluster.Partition$$anonfun$6.apply(Partition.scala:505)
at kafka.cluster.Partition$$anonfun$6.apply(Partition.scala:496)
at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:253)
at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:261)
at kafka.cluster.Partition.makeLeader(Partition.scala:496)
at kafka.server.ReplicaManager$$anonfun$makeLeaders$4.apply(ReplicaManager.scala:1369)
at kafka.server.ReplicaManager$$anonfun$makeLeaders$4.apply(ReplicaManager.scala:1367)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:236)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:130)
at kafka.server.ReplicaManager.makeLeaders(ReplicaManager.scala:1367)
at kafka.server.ReplicaManager.becomeLeaderOrFollower(ReplicaManager.scala:1256)
at kafka.server.KafkaApis.handleLeaderAndIsrRequest(KafkaApis.scala:217)
at kafka.server.KafkaApis.handle(KafkaApis.scala:130)
at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:70)
at java.lang.Thread.run(Thread.java:748)

请注意,主题已成功创建,但此错误已记录到kafka服务器控制台。这是我用来创建主题的命令

kafka-topics.sh --zookeeper 127.0.0.1:2181 --create --topic t_one --partitions 3 --replication-factor 1
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic t_one.
vagrant@vm1:/vagrant$ kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic t_one --describe
Topic: t_one PartitionCount: 3 ReplicationFactor: 1 Configs:
Topic: t_one Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: t_one Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: t_one Partition: 2 Leader: 0 Replicas: 0 Isr: 0

最后,当我尝试测试控制台生产者时,我得到了以下警告和错误

vagrant@vm1:/vagrant$ kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic t_one
>hi
>[2020-03-06 06:31:06,460] WARN [Producer clientId=console-producer] Got error produce response with correlation id 4 on topic-partition t_one-2, retrying (2 attempts left). Error: NOT_LEADER_FOR_PARTITION (org.apache.kafka.clients.producer.internals.Sender)
[2020-03-06 06:31:06,460] WARN [Producer clientId=console-producer] Received invalid metadata error in produce request on partition t_one-2 due to org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.. Going to request metadata update now (org.apache.kafka.clients.producer.internals.Sender)
[2020-03-06 06:31:06,577] WARN [Producer clientId=console-producer] Got error produce response with correlation id 6 on topic-partition t_one-2, retrying (1 attempts left). Error: NOT_LEADER_FOR_PARTITION (org.apache.kafka.clients.producer.internals.Sender)
[2020-03-06 06:31:06,577] WARN [Producer clientId=console-producer] Received invalid metadata error in produce request on partition t_one-2 due to org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.. Going to request metadata update now (org.apache.kafka.clients.producer.internals.Sender)
[2020-03-06 06:31:06,699] WARN [Producer clientId=console-producer] Got error produce response with correlation id 8 on topic-partition t_one-2, retrying (0 attempts left). Error: NOT_LEADER_FOR_PARTITION (org.apache.kafka.clients.producer.internals.Sender)
[2020-03-06 06:31:06,699] WARN [Producer clientId=console-producer] Received invalid metadata error in produce request on partition t_one-2 due to org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.. Going to request metadata update now (org.apache.kafka.clients.producer.internals.Sender)
[2020-03-06 06:31:06,805] ERROR Error when sending message to topic t_one with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.
[2020-03-06 06:31:06,820] WARN [Producer clientId=console-producer] Received invalid metadata error in produce request on partition t_one-2 due to org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.. Going to request metadata update now (org.apache.kafka.clients.producer.internals.Sender)

如果我启动kafka控制台消费者,我看不到任何明显的消息,因为生产者抛出了上述错误。

我认为我在kafka控制台生产者上看到的错误是创建主题后产生的错误的结果,但作为kafka的新手,我不确定这里出了什么问题以及如何修复它。

您似乎没有正确配置kafka。你能看看你的服务器吗??您指定了日志目录吗?

承载log.dirs的文件系统出现了一些问题,我花了很长时间才弄清楚主题是如何创建的。我将log.dirs更改为其他文件系统,它对我有效。

最新更新