异常信息

 ERROR [ReplicaManager broker=2] Error while making broker the leader for partition Topic: __consumer_offsets; Partition: 41; Leader: None; AssignedReplicas: ; InSyncReplicas:  in dir None (kafka.server.ReplicaManager)
org.apache.kafka.common.errors.KafkaStorageException: Error while reading checkpoint file /export/servers/kafka_2.11-1.0.0/logs/replication-offset-checkpoint
Caused by: java.io.IOException: Malformed line in checkpoint file (/export/servers/kafka_2.11-1.0.0/logs/replication-offset-checkpoint): '
        at kafka.server.checkpoints.CheckpointFile.malformedLineException$1(CheckpointFile.scala:84)
        at kafka.server.checkpoints.CheckpointFile.liftedTree2$1(CheckpointFile.scala:117)
        at kafka.server.checkpoints.CheckpointFile.read(CheckpointFile.scala:86)
        at kafka.server.checkpoints.OffsetCheckpointFile.read(OffsetCheckpointFile.scala:61)
        at kafka.cluster.Partition$$anonfun$getOrCreateReplica$1.apply(Partition.scala:147)
        at kafka.cluster.Partition$$anonfun$getOrCreateReplica$1.apply(Partition.scala:142)
        at kafka.utils.Pool.getAndMaybePut(Pool.scala:65)
        at kafka.cluster.Partition.getOrCreateReplica(Partition.scala:141)
        at kafka.cluster.Partition$$anonfun$6$$anonfun$8.apply(Partition.scala:196)
        at kafka.cluster.Partition$$anonfun$6$$anonfun$8.apply(Partition.scala:196)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
        at scala.collection.AbstractTraversable.map(Traversable.scala:104)
        at kafka.cluster.Partition$$anonfun$6.apply(Partition.scala:196)
        at kafka.cluster.Partition$$anonfun$6.apply(Partition.scala:190)
        at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:217)
        at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:225)
        at kafka.cluster.Partition.makeLeader(Partition.scala:190)
        at kafka.server.ReplicaManager$$anonfun$makeLeaders$4.apply(ReplicaManager.scala:1128)
        at kafka.server.ReplicaManager$$anonfun$makeLeaders$4.apply(ReplicaManager.scala:1126)
        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:1126)
        at kafka.server.ReplicaManager.becomeLeaderOrFollower(ReplicaManager.scala:1061)
        at kafka.server.KafkaApis.handleLeaderAndIsrRequest(KafkaApis.scala:173)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:103)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:65)
        at java.lang.Thread.run(Thread.java:748)

解决方案

我的是测试环境 我把读取失败的offset文件给删除了

kafka消费者无法消费(读取offset文件IO异常)_java

重启kafka集群就好了