All Products
Search
Document Center

ApsaraDB for MongoDB:Migrate an instance across zones

Last Updated:Aug 29, 2025

This topic describes how to migrate an ApsaraDB for MongoDB instance to a different zone in the same region. The instance's account password and connection address remain unchanged after the migration.

Prerequisites

  • The instance meets one of the following requirements:

    • The instance is a replica set or sharded cluster instance that uses local disks and runs MongoDB 4.0 or 4.2.

    • The instance is a replica set or sharded cluster instance that uses cloud disks and runs MongoDB 4.4 or later.

  • Transparent Data Encryption (TDE) is disabled for the instance.

  • The destination zone is in the same region as the current zone of the instance.

  • Before you migrate an instance in a virtual private cloud (VPC), make sure that a vSwitch is created in the destination zone. For more information, see Create and manage vSwitches.

  • An instance that uses local disks cannot have a public endpoint. If a public endpoint exists, you must release it before you migrate the instance. For more information, see Release a public endpoint.

Usage notes

  • You cannot change the VPC of an instance during the migration.

  • The migration time varies based on factors such as network conditions, the task queue, and the data volume. We recommend that you perform the migration during off-peak hours.

  • The migration causes a transient connection interruption that lasts for approximately 30 seconds. Make sure that your application has an automatic reconnection mechanism.

  • The virtual IP address (VIP) of the instance changes after the migration. An example of a VIP is 172.16.88.60. If your application connects to the database using the old VIP, the connection fails.

    Note

    To ensure high availability (HA), connect to the instance using its connection string URI. For replica set instances, see Connect to a replica set instance. For sharded cluster instances, see Connect to a sharded cluster instance.

Supported migration types and scenarios

Migration type

Common scenarios

Migration from a single zone to another single zone

Migrate the MongoDB instance to the same zone as an ECS instance to reduce network latency for internal connections.

Migration from a single zone to multiple zones

Improve the disaster recovery capability of the instance across data centers.

A single-zone instance can tolerate server-level and rack-level failures. A multi-zone instance can tolerate data center-level failures. For example, you can deploy the three nodes of a replica set instance across three different zones in the same region. This allows the instance to achieve a higher level of disaster recovery.

Note

For more information about the node deployment policies for multi-zone replica set and sharded cluster instances, see Node deployment policies or Create a multi-zone sharded cluster instance.

Migration from multiple zones to a single zone

Meet the requirements of a specific feature.

Migration from multiple zones to another set of multiple zones

The MongoDB instance requires more resources for an upgrade, and a new multi-zone deployment can provide the required resources.

Important
  • An ApsaraDB for MongoDB instance that uses local disks can be migrated only from a single zone to another single zone. To deploy the instance across multiple zones, you must select a zone that uses the Region (Zone 1+Zone 2+Zone 3) format, such as Shenzhen (C+D+E). This format is available only in some regions. For more information, see Supported regions and zones.

  • For an ApsaraDB for MongoDB instance that uses cloud disks, you can change the instance type during the zone migration.

Procedure

  1. Go to the MongoDB Replica Set Instances or MongoDB Sharded Cluster Instances page. In the upper part of the page, select a resource group and a region. Then, click the ID of the desired instance.

  2. In the Basic Information section, click Cross-zone Migration to the right of Zone.

  3. In the Migrate Instance Across Zones panel, configure the parameters.

    The parameters vary based on the disk type of the instance.

    Cloud disk

    Parameter

    Description

    Instance

    The ID of the current instance.

    Current Zone

    The zone where the instance currently resides.

    Zone Type

    Select Single-zone or Multi-zone as needed.

    Migrate To

    Select the destination zone.

    If you set Zone Type to Multi-zone, you must also configure the Migrate Secondary Zone 1 To and Migrate Secondary Zone 2 To parameters.

    Current VPC

    The VPC to which the instance currently belongs.

    Select vSwitch

    Select the destination vSwitch.

    Switchover Time

    Select when the zone migration takes effect.

    • Switch Immediately after Migration: The system starts the migration task immediately after the parameters are configured. The instance is switched over immediately after the task is complete.

    • Switch within Maintenance Window: Set the effective period for the instance migration. You can select the current maintenance window or set a new one as needed.

      1. To set the switchover time, click Edit to the right of the Switch within Maintenance Window option.

      2. In the Instance Specifications section, click Edit to the right of Maintenance Window to set the switch time. For more information, see Set a maintenance window.

    Local disk

    The parameters vary based on the network type of the instance.

    • The network type is VPC or hybrid access.

      Parameter

      Description

      Instance

      The ID of the current instance.

      Current Zone

      The zone where the instance currently resides.

      Migrate To

      Select the destination zone.

      Current VPC

      The VPC to which the instance currently belongs.

      Select vSwitch

      Select the destination vSwitch.

      Switchover Time

      Select when the zone migration takes effect.

      • Switch Immediately after Migration: The system starts the migration task immediately after the parameters are configured. The instance is switched over immediately after the task is complete.

      • Switch within Maintenance Window: Set the effective period for the instance migration. You can select the current maintenance window or set a new one as needed.

        1. To set the switch time, click Edit next to Switch within Maintenance Window.

        2. In the Instance Specifications section, click Edit to the right of Maintenance Window to set the switch time. For more information, see Set a maintenance window.

    • The network type is classic network.

      Parameter

      Description

      Instance

      The ID of the current instance.

      Current Zone

      The zone where the instance currently resides.

      Migrate To

      Select the destination zone.

      Switchover Time

      Select when the zone migration takes effect.

      • Switch Immediately after Migration: The system starts the migration task immediately after the parameters are configured. The instance is switched over immediately after the task is complete.

      • Switch within Maintenance Window: Set the effective period for the instance migration. You can select the current maintenance window or set a new one as needed.

        1. Click Edit to the right of Switch within Maintenance Window to set the switch time.

        2. In the Instance Specifications section, click Edit to the right of Maintenance Window to set the switch time. For more information, see Set a maintenance window.

  4. Read the on-screen instructions and select the check box.

  5. (Optional) Select I Need To Change The Configuration to change the instance type during the zone migration.

  6. Click OK.

FAQ

Q: Can I migrate a cloud disk instance if disk encryption is enabled?

A: Yes, you can. Zone migration is supported for instances with disk encryption enabled.