All Products
Search
Document Center

ApsaraMQ for Kafka:Migrate topics and groups from an ApsaraMQ for Kafka instance to another ApsaraMQ for Kafka instance

Last Updated:Nov 22, 2024

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

Important
  • 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

  1. Open the CLI.

  2. Run the cd command to go to the directory where the migration tool is stored.

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

    image

  4. 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>  \ 
    --commit

    Parameter

    Description

    commit

    Commits the migration request.

    The following figure shows a sample response.

    image

    If the value in the MigrationSuccessFlag column is true, the topic is created in the destination ApsaraMQ for Kafka instance.

Group

  1. Open the CLI.

  2. Run the cd command to go to the directory where the migration tool is stored.

  3. 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.image

  4. 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>  \
    --commit

    Parameter

    Description

    commit

    Commits the migration request.

    The following figure shows a sample response.image

    If the value in the MigrationSuccessFlag column is true, the topic is created in the destination ApsaraMQ for Kafka instance.

Verify the result

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

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