我用三个代理设置了一个kafka集群,并使用--replication-factor 2 --partitions 1参数创建了几个主题,没有消息产生或使用。
但是我发现其中一个代理,每秒连续输出INFO日志,而其他两个代理看起来还不错:
[2018-07-09 10:11:17,
743] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:18,744] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:19,744] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:20,745] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:21,746] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:22,746] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:23,747] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:24,747] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:25,748] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:26,749] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:27,749] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:28,750] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:29,750] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:30,751] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:31,752] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:32,752] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
[2018-07-09 10:11:33,753] INFO [ReplicaFetcher replicaId=3, leaderId=128, fetcherId=0] Retrying leaderEpoch request for partition TOPIC_LOGIN_EVENT-0 as the leader reported an error: NOT_LEADER_FOR_PARTITION (kafka.server.ReplicaFetcherThread)
答案 0 :(得分:3)
我找到了问题的根源,没有配置侦听地址,因此每个代理默认情况下都使用InetAddress.getLocalHost()绑定它。因此,不幸的是,拥有该主题的主要分区的一个经纪人使用“ localhost:9092”。问题代理被“ localhost:9092”告知连接到线索分区,结果被连接到自身, 当然是-NOT_LEADER_FOR_PARTITION”
我更正了/ etc / hosts,并且有效