Kafka-该服务器不是该主题分区的领导者 [英] Kafka - This server is not the leader for that topic-partition
问题描述
我有两个代理kafka 0.10.2.0集群.复制因子为2.我正在对此Kafka运行1.0.0 kafka流应用程序.在我的kafka流应用程序中,生产者配置具有retries = 10 and retry.backoff.ms = 100
I have two broker kafka 0.10.2.0 cluster.Replication factor is 2. I am running 1.0.0 kafka stream application against this Kafka. In my kafka stream application, producer config has retries = 10 and retry.backoff.ms = 100
运行几分钟后,我观察到Kakfa server.log中的以下日志.由于存在这种Kafka流应用程序会抛出"NOT_LEADER_FOR_PARTITION"异常.
After running few minutes, I observed following logs in Kakfa server.log. Due to this Kafka stream application is throwing 'NOT_LEADER_FOR_PARTITION' exception.
可能是什么原因?请帮助我.
What may be the possible reason? Please help me.
[2017-12-12 10:26:02,583] ERROR [ReplicaFetcherThread-0-1], Error for partition [__consumer_offsets,22] to broker 1:org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition. (kafka.server.ReplicaFetcherThread)
推荐答案
每个主题都由一个或多个经纪人提供服务-一个是领导者,其余的经纪人是关注者.
Each topic is served by one or multiple Brokers - one is leader and the remaining brokers are followers.
生产者需要向领导者经纪人发送新消息,领导者经纪人将数据内部复制到所有关注者.
A producer needs to send new messages to the leader Broker which internally replicate the data to all followers.
我认为,您的生产者客户端未连接到正确的代理,而是连接到关注者而非领导者,并且该关注者拒绝了您的发送请求.
I assume, that your producer client does not connect to the correct Broker, its connect to a follower instead of the leader, and this follower rejects your send request.
尝试运行./kafka-topics.sh --zookeeper localhost:2181 --topic your_topic --describe
Topic:your_topic PartitionCount:3 ReplicationFactor:1 Configs:retention.ms=14400000
Topic: your_topic Partition: 0 Leader: 2 Replicas: 2 Isr: 2
Topic: your_topic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: your_topic Partition: 2 Leader: 1 Replicas: 1 Isr: 1
在此示例中,您可以看到your_topic
具有3个分区,这意味着所有3个经纪人都是该主题在不同分区上的领导者,st broker 2
是partition 0
的领导者,而broker 0
和broker 1
是跟随者在partition 0
上.
In this example you can see that your_topic
have 3 partitions meaning all 3 brokers are leaders of that topic each on different partition, s.t broker 2
is leader on partition 0
and broker 0
and broker 1
are followers on partition 0
.
这篇关于Kafka-该服务器不是该主题分区的领导者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!