Example: Partition Reassignment in Seconds
This document outlines the process for using Kafka CLI tools to verify AutoMQ's sub-second partition reassignment capability. The Kafka CLI tool is executed via a Docker image provided by AutoMQ.
First, create a new Kafka topic with a single partition and initiate a producer to write a certain amount of data into it. Next, attempt to reassign the partition among different AutoMQ brokers using the reassign command. Observe the time it takes to complete the partition reassignment.
Prerequisites
Before carrying out a partition reassignment test, the following conditions must be met:
Complete the installation and deployment of the AutoMQ cluster. You can refer to the following methods to install and deploy AutoMQ:
Additionally, the host running the test program must meet the following conditions:
-
Linux/Mac/Windows Subsystem for Linux
-
Docker
If downloading container images is slow, please refer to Docker Hub Mirror Configuration▸.
- Deploy Multi-Nodes Test Cluster on Docker
- Deploy Multi-Nodes Cluster on Linux
If the previous AutoMQ cluster was deployed using Deploy Multi-Nodes Test Cluster on Docker▸, the acquired cluster Bootstrap address will resemble "server1:9092,server2:9092,server3:9092," and the AutoMQ cluster will be located in the "automq_net" Docker network.
Please update the bootstrap-server address below to match the actual address of the cluster based on the deployment configuration.
Create Topic
docker run --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-topics.sh --create --topic reassign-topic --bootstrap-server server1:9092,server2:9092,server3:9092"
Send Messages
Execute the following command to send a specified amount of data.
docker run --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-producer-perf-test.sh --topic reassign-topic --num-records=1024000 --throughput 5120 --record-size 1024 --producer-props bootstrap.servers=server1:9092,server2:9092,server3:9092 linger.ms=100 batch.size=524288 buffer.memory=134217728 max.request.size=67108864"
Check Partition Distribution
docker run --network automq_net automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-topics.sh --topic reassign-topic --describe --bootstrap-server server1:9092,server2:9092,server3:9092"
Reassign Partitions Across Brokers
In this step, assume that partition 0 of the "reassign-topic" is located on node 1, and reassign this partition to node 2. During the actual testing process, you can choose a different node for reassignment based on partition distribution.
- Create a plan for partition reassignment.
echo '{
"partitions": [
{
"topic": "reassign-topic",
"partition": 0,
"replicas": [
2
]
}
],
"version": 1
}' > move.json
- Implement the partition reassignment plan.
docker run --network automq_net -v $(pwd)/move.json:/move.json automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-reassign-partitions.sh --bootstrap-server server1:9092,server2:9092,server3:9092 --reassignment-json-file /move.json --execute"
3. Verify if the Reassignment Is Complete.
docker run --network automq_net -v $(pwd)/move.json:/move.json automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-reassign-partitions.sh --bootstrap-server server1:9092,server2:9092,server3:9092 --reassignment-json-file /move.json --verify"
If the previous AutoMQ cluster was deployed by referring to Deploy Multi-Nodes Cluster on Linux▸, then the obtained cluster bootstrap address would resemble "192.168.0.1:9092,192.168.0.2:9092,192.168.0.3:9092".
Please replace the bootstrap-server address below with the actual cluster's address based on the deployment configuration.
Create Topic
docker run automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-topics.sh --create --topic reassign-topic --bootstrap-server 192.168.0.1:9092,192.168.0.2:9092,192.168.0.3:9092"
Send Messages
docker run automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-producer-perf-test.sh --topic reassign-topic --num-records=1024000 --throughput 5120 --record-size 1024 --producer-props bootstrap.servers=192.168.0.1:9092,192.168.0.2:9092,192.168.0.3:9092 linger.ms=100 batch.size=524288 buffer.memory=134217728 max.request.size=67108864"
View Partition Distribution
docker run automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-topics.sh --topic reassign-topic --describe --bootstrap-server 192.168.0.1:9092,192.168.0.2:9092,192.168.0.3:9092"
Reassign Partitions Between Brokers
In this step, it's assumed that partition 0 of the test topic "reassign-topic" is currently on node 1, and the goal is to reassign this partition to node 2. Depending on the actual partition distribution during testing, you might opt to reassign to different nodes.
- Create the partition reassignment plan.
echo '{
"partitions": [
{
"topic": "reassign-topic",
"partition": 0,
"replicas": [
2
]
}
],
"version": 1
}' > move.json
- Execute the partition reassignment plan.
docker run -v $(pwd)/move.json:/move.json automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-reassign-partitions.sh --bootstrap-server 192.168.0.1:9092,192.168.0.2:9092,192.168.0.3:9092 --reassignment-json-file /move.json --execute"
3. Check if the Reassignment Is Complete.
docker run -v $(pwd)/move.json:/move.json automqinc/automq:latest /bin/bash -c "/opt/kafka/kafka/bin/kafka-reassign-partitions.sh --bootstrap-server 192.168.0.1:9092,192.168.0.2:9092,192.168.0.3:9092 --reassignment-json-file /move.json --verify"