If you want to migrate your business in ApsaraMQ for Kafka from Region A to Region B without service interruption or copy the metadata of an existing ApsaraMQ for Kafka instance to a newly created ApsaraMQ for Kafka instance, you can use the migration tool provided by ApsaraMQ for Kafka to migrate topics and groups from an ApsaraMQ for Kafka instance to another ApsaraMQ for Kafka instance.
Prerequisites
Java Development Kit (JDK) 8 is downloaded.
The migration tool kafka-migration-assessment.jar is downloaded.
ApsaraMQ for Kafka instances are purchased and deployed. For more information, see Step 2: Purchase and deploy an instance.
After the migration, the topics and groups of the source ApsaraMQ for Kafka instance are not deleted. Instead, topics and groups with the same configurations are created in the destination ApsaraMQ for Kafka instance.
Only the configurations of topics and groups are migrated.
Procedure
Topic
Open the CLI.
Run the cd command to go to the directory where the migration tool is stored.
Run the following command to perform a precheck on the topics that you want to migrate:
java -jar kafka-migration-assessment.jar TopicMigrationFromAliyun \ --sourceAk <yoursourceAccessKeyId> \ --sourceSk <yoursourceAccessKeySecret> \ --sourceRegionId <yoursourceRegionId> \ --sourceInstanceId <yoursourceInstanceId> \ --destAk <yourdestAccessKeyId> \ --destSk <yourdestAccessKeySecret> \ --destRegionId <yourdestRegionId> \ --destInstanceId <yourdestInstanceId>Replace the content enclosed in
<>in the preceding command with the information of your instance. The following table describes the details.Parameter
Description
sourceAk
The AccessKey ID of the Alibaba Cloud account to which the source ApsaraMQ for Kafka instance belongs.
sourceSk
The AccessKey secret of the Alibaba Cloud account to which the source ApsaraMQ for Kafka instance belongs.
sourceRegionId
The ID of the region where the source ApsaraMQ for Kafka instance resides. Example:
cn-hangzhou.sourceInstanceId
The ID of the source ApsaraMQ for Kafka instance.
destAk
The AccessKey ID of the Alibaba Cloud account to which the destination ApsaraMQ for Kafka instance belongs.
destSk
The AccessKey secret of the Alibaba Cloud account to which the destination ApsaraMQ for Kafka instance belongs.
destRegionId
The ID of the region where the destination ApsaraMQ for Kafka instance resides. Example:
cn-hangzhou.destInstanceId
The ID of the destination ApsaraMQ for Kafka instance.
The following figure shows a sample response.

Run the following command to migrate topics:
java -jar kafka-migration-assessment.jar TopicMigrationFromAliyun \ --sourceAk <yoursourceAccessKeyId> \ --sourceSk <yoursourceAccessKeySecret> \ --sourceRegionId <yoursourceRegionId> \ --sourceInstanceId <yoursourceInstanceId> \ --destAk <yourdestAccessKeyId> \ --destSk <yourdestAccessKeySecret> \ --destRegionId <yourdestRegionId> \ --destInstanceId <yourdestInstanceId> \ --commitParameter
Description
commit
Commits the migration request.
The following figure shows a sample response.

If the value in the MigrationSuccessFlag column is
true, the topic is created in the destination ApsaraMQ for Kafka instance.
Group
Open the CLI.
Run the cd command to go to the directory where the migration tool is stored.
Run the following command to perform a precheck on the groups that you want to migrate:
java -jar kafka-migration-assessment.jar ConsumerGroupMigrationFromAliyun \ --sourceAk <yoursourceAccessKeyId> \ --sourceSk <yoursourceAccessKeySecret> \ --sourceRegionId <yoursourceRegionId> \ --sourceInstanceId <yoursourceInstanceId> \ --destAk <yourdestAccessKeyId> \ --destSk <yourdestAccessKeySecret> \ --destRegionId <yourdestRegionId> \ --destInstanceId <yourdestInstanceId>Replace the content enclosed in
<>in the preceding command with the information of your instance. The following table describes the details.Parameter
Description
sourceAk
The AccessKey ID of the Alibaba Cloud account to which the source ApsaraMQ for Kafka instance belongs.
sourceSk
The AccessKey secret of the Alibaba Cloud account to which the source ApsaraMQ for Kafka instance belongs.
sourceRegionId
The ID of the region where the source ApsaraMQ for Kafka instance resides. Example:
cn-hangzhou.sourceInstanceId
The ID of the source ApsaraMQ for Kafka instance.
destAk
The AccessKey ID of the Alibaba Cloud account to which the destination ApsaraMQ for Kafka instance belongs.
destSk
The AccessKey secret of the Alibaba Cloud account to which the destination ApsaraMQ for Kafka instance belongs.
destRegionId
The ID of the region where the destination ApsaraMQ for Kafka instance resides. Example:
cn-hangzhou.destInstanceId
The ID of the destination ApsaraMQ for Kafka instance.
The following figure shows a sample response.

Run the following command to migrate groups:
java -jar kafka-migration-assessment.jar ConsumerGroupMigrationFromAliyun \ --sourceAk <yoursourceAccessKeyId> \ --sourceSk <yoursourceAccessKeySecret> \ --sourceRegionId <yoursourceRegionId> \ --sourceInstanceId <yoursourceInstanceId> \ --destAk <yourdestAccessKeyId> \ --destSk <yourdestAccessKeySecret> \ --destRegionId <yourdestRegionId> \ --destInstanceId <yourdestInstanceId> \ --commitParameter
Description
commit
Commits the migration request.
The following figure shows a sample response.

If the value in the MigrationSuccessFlag column is
true, the topic is created in the destination ApsaraMQ for Kafka instance.
Verify the result
Log on to the ApsaraMQ for Kafka console. In the Resource Distribution section of the Overview page, select the region where the ApsaraMQ for Kafka instance that you want to manage resides.
On the Instances page, click the name of the instance that you want to manage.
Topic: In the left-side navigation pane of the Instance Details page, click Topics to view the topics that are migrated.
Group: In the left-side navigation pane of the Instance Details page, click Groups to view the groups that are migrated.
What to do next
Instances are switched during migration. Therefore, check whether you need to change the endpoint that clients use to access the instance after migration. For more information, see View endpoints.