无法重新分配kafka主题分区

时间:2019-09-13 08:51:55

标签: apache-kafka

kafka的版本为kafka_2.12-2.2.0,zookeeper为3.5.4-beta。

1。启动代理0

./bin/kafka-server-start.sh -daemon config/server.properties

2。创建一个名为test的主题

./bin/kafka-topics.sh --zookeeper 192.168.18.128:2181/kafka --topic test --create --partitions 2 --replication-factor 1

主题测试的描述是

./bin/kafka-topics.sh --zookeeper 192.168.18.128:2181/kafka --topic test --describe
Topic:test  PartitionCount:2    ReplicationFactor:1 Configs:
Topic: test Partition: 0    Leader: 0   Replicas: 0 Isr: 0
Topic: test Partition: 1    Leader: 0   Replicas: 0 Isr: 0

3。现在我启动代理1,然后将主题测试的partition-1移到代理1。然后我创建一个名为reassign.json的json文件,reassign.json的内容为

{
    "version": 1, 
    "partitions": [
        {
            "topic": "test", 
            "partition": 1, 
            "replicas": [
                1
            ], 
            "log_dirs": [
                "any"
            ]
        }
    ]
}

然后我执行命令以移动分区1

./bin/kafka-reassign-partitions.sh --zookeeper 192.168.18.128:2181/kafka --reassignment-json-file json/reassign.json --execute

4。几秒钟后,我执行命令并显示上一条命令的结果。

./bin/kafka-reassign-partitions.sh --zookeeper 192.168.18.128:2181/kafka --verify --reassignment-json-file json/reassign.json
Status of partition reassignment: 
Reassignment of partition test-1 is still in progress

我重试了2次,但是对分区的重新分配仍在进行中。

5。然后在server.log中出现以下错误日志。

[2019-09-13 15:37:04,696] ERROR [KafkaApi-0] Error when handling request: clientId=0, correlationId=6, api=UPDATE_METADATA, body={controller_id=0,controller_epoch=1,broker_epoch=62,topic_states=[{topic=test,partition_states=[{partition=1,controller_epoch=1,leader=0,leader_epoch=0,isr=[0],zk_version=0,replicas=[1,0],offline_replicas=[]}]}],live_brokers=[{id=0,end_points=[{port=9092,host=ubuntu,listener_name=PLAINTEXT,security_protocol_type=0}],rack=null},{id=1,end_points=[{port=9092,host=ubuntu,listener_name=PLAINTEXT,security_protocol_type=0}],rack=null}]} (kafka.server.KafkaApis)
java.lang.IllegalStateException: Epoch 62 larger than current broker epoch 28
        at kafka.server.KafkaApis.isBrokerEpochStale(KafkaApis.scala:2414)
        at kafka.server.KafkaApis.handleUpdateMetadataRequest(KafkaApis.scala:236)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:114)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
        at java.lang.Thread.run(Thread.java:748)

有人解决了同样的问题吗?您介意分享您的选择吗?谢谢。

1 个答案:

答案 0 :(得分:0)

我尝试了您的配置,对我来说一切都很好。从数字5的错误中,我可以看到VLOOKUP(element, f_range, col_num, true_false) 的副本是partition-1,而复制因子为1。

基于此处(检查副本):

[1,0]

检查是否在某个地方添加了额外的步骤,以将[2019-09-13 15:37:04,696] ERROR [KafkaApi-0] Error when handling request: clientId=0, correlationId=6, api=UPDATE_METADATA, body={controller_id=0,controller_epoch=1,broker_epoch=62,topic_states=[{topic=test,partition_states=[{partition=1,controller_epoch=1,leader=0,leader_epoch=0,isr=[0],zk_version=0,replicas=[1,0],offline_replicas=[]}]}],live_brokers=[{id=0,end_points=[{port=9092,host=ubuntu,listener_name=PLAINTEXT,security_protocol_type=0}],rack=null},{id=1,end_points=[{port=9092,host=ubuntu,listener_name=PLAINTEXT,security_protocol_type=0}],rack=null}]} (kafka.server.KafkaApis) 添加为broker-1的副本。