Help Center/ MapReduce Service/ Component Operation Guide (LTS)/ Using Kafka/ Common Issues About Kafka/ What Can I Do When kafka-reassign-partitions.sh Does Not Have a Rollback Solution?
Updated on 2026-06-27 GMT+08:00

What Can I Do When kafka-reassign-partitions.sh Does Not Have a Rollback Solution?

Symptom

After the kafka-reassign-partitions.sh task completes, no rollback solution is available.

Procedure

  1. Log in as a client installation user to the node on which the Kafka client is installed.
  2. Switch to the Kafka client installation directory, for example, /opt/client.

    cd /opt/client

  3. Run the following command to configure environment variables:

    source bigdata_env

  4. Run the following command to authenticate the user (skip this step in normal mode):

    kinit Component service user

  5. Run the following command to switch to the Kafka client installation directory:

    cd Kafka/kafka

  6. Obtain the original partition and replica distribution before executing the reassignment.

    ./bin/kafka-reassign-partitions.sh --bootstrap-server <Kafka cluster IP address:Port> --topics-to-move-json-file topic.json --broker-list "BrokerId1,BrokerId2,..." --generate --command-config config/client.properties | sed -n '2p' > JSON file

    Example:

    ./bin/kafka-reassign-partitions.sh --bootstrap-server 192.168.1.1:21007 --topics-to-move-json-file topic.json --broker-list "1,2,3" --generate --command-config config/client.properties | sed -n '2p' > original.json

    • The topic.json file contains the topics for reassignment, formatted as follows: {"topics": [{"topic": "topic1-name"},{"topic": "topic2-name"}], "version": 1}
    • --broker-list: The IDs of the target brokers. Separate multiple IDs with commas (,). The number of IDs must be equal to or greater than the number of brokers used in the original topic assignment.
    • The original.json file is an output file that saves the current partition replica distribution for verification or rollback.

  7. To roll back the reassignment, run the following command:

    ./bin/kafka-reassign-partitions.sh --bootstrap-server <Kafka cluster IP address: Port> --reassignment-json-file JSON file obtained in 6 --execute --command-config ../config/client.properties