简体   繁体   中英

Cannot reassign kafka topic partition

The version of kafka is kafka_2.12-2.2.0, zookeeper is 3.5.4-beta.

1.start broker 0

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

2.create a topic named test

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

describe of topic test is

./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.now I start broker 1,and I want to move partition-1 of topic test to broker 1.Then I create a json file named reassign.json, content of reassign.json is

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

Then I exec command to move partition-1

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

4.After a few seconds,I exec comand to show result of previous command.

./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

I retry 2 times,bug the reassignment of partion is still in progress.

5.Then I get following error log in 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)

Had anyone resolved the same issue? Would you mind sharing your options? Thanks.

I tried your configs and all worked good for me. From the error at number 5 i can see that the replicas of your partition-1 are [1,0] while you have a replication factor of 1.

Based here (check replicas):

[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)

Check if you have added an extra step somewhere that adds broker-1 as a replica for partition-1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM