All Products
Search
Document Center

ApsaraDB for MongoDB:Upgrade the major version of an ApsaraDB for MongoDB instance

Last Updated:Mar 18, 2024

This topic describes the major versions available for upgrades in ApsaraDB MongoDB and how to upgrade the major versions of an ApsaraDB for MongoDB instance.

Usage notes

  • You can only upgrade the major version of an ApsaraDB for MongoDB sharded cluster instance that uses the MongoDB protocol.

  • Nodes in an instance are upgraded in turn. An instance is automatically restarted two or three times during an upgrade. We recommend that you perform the upgrade during off-peak hours or make sure that your application is configured to automatically reconnect to the instance.

    Note

    If your application runs in a production environment, we recommend that you use a connection string URI to connect your application to the instance.

    If you use this URI, the primary node is always connected and the read and write operations of your application are not affected by primary/secondary switchover. For more information about how to connect to a database by using a connection string URI, see Connect to a replica set instance or Connect to a sharded cluster instance.

  • The balancer of a sharded cluster instance is disabled during an upgrade and is enabled after the upgrade.

  • The duration of upgrading the major version of an instance is related to the data volume of databases in this instance. We recommend that you schedule your upgrade task during off-peak hours.

  • You cannot downgrade the major version of an instance after you upgrade it.

  • After you upgrade the major version of an instance, the backup data of an instance that uses an earlier major version cannot be restored to the upgraded instance. You can download the backup file of an instance that uses an earlier major version and restore the backup file to a self-managed database. For more information about how to restore backup data to a self-managed database, see Restore data of an ApsaraDB for MongoDB instance to a self-managed MongoDB database by using logical backup or Restore data of an ApsaraDB for MongoDB instance to a self-managed MongoDB database by using physical backup.

Major versions available for upgrades

The following table lists the major versions and describes whether the versions are supported in different instance architectures and versions.

Architecture

Category

Current major version

Major version available for upgrade

Standalone instance

General-purpose instance that uses cloud disks

MongoDB 4.0

No new major version is available for upgrade.

General-purpose instance that uses cloud disks

MongoDB 3.4

You cannot upgrade the major version of the instance.

To upgrade the major version of an instance, you can create an instance and replace the old instance with the new instance. For information about how to create a standalone instance, see Create a standalone instance.

Replica set instance

Dedicated instance that uses cloud disks

MongoDB 7.0

No new major version is available for upgrade.

MongoDB 6.0

MongoDB 7.0

MongoDB 5.0

MongoDB 6.0

MongoDB 4.4

MongoDB 5.0

  • General-purpose instance that uses local disks

  • Dedicated instance that uses local disks

  • Dedicated host instance

MongoDB 4.2

You cannot upgrade the major version of the instance.

To upgrade the major version of an instance, you can create an instance and replace the old instance with the new instance. For more information about how to create a replica set instance, see Create a replica set instance.

MongoDB 4.0

MongoDB 4.2

MongoDB 3.4

  • MongoDB 4.0

  • MongoDB 4.2

Sharded cluster instance

Dedicated instance that uses cloud disks

MongoDB 7.0

No new major version is available for upgrade.

MongoDB 6.0

MongoDB 7.0

MongoDB 5.0

MongoDB 6.0

MongoDB 4.4

MongoDB 5.0

  • General-purpose instance that uses local disks

  • Dedicated instance that uses local disks

  • Dedicated host instance

MongoDB 4.2

You cannot upgrade the major version of the instance.

To upgrade the major version of an instance, you can create an instance and replace the old instance with the new instance. For more information about how to create a sharded cluster instance, see Create a sharded cluster instance.

MongoDB 4.0

MongoDB 4.2

MongoDB 3.4

  • MongoDB 4.0

  • MongoDB 4.2

Compatibility testing

Before you upgrade the major version of an instance, perform the following steps to complete compatibility testing.

  1. Check and modify the client code based on the major versions that are involved to prevent possible compatibility issues. For more information about how to modify the client code, see Upgrades of MongoDB major versions

  2. (Optional) Use the data restoration method to test compatibility between different major versions.

    Important

    Data restoration incurs additional fees.

    1. Create an instance of the same major version for data restoration. For more information about how to restore data, see Restoration solution overview.

    2. Upgrade the major database version of the new instance. For more information about major versions available for upgrades and how to upgrade the major version of an instance, see Major versions available for upgrades and Procedure.

    3. Verify whether the modified client has compatibility issues on the new instance.

      If compatibility issues occur, check and modify the client code again based on the error message until no compatibility issues occur.

    4. After compatibility testing is complete, release the new instance.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Replica Set Instances or Sharded Cluster Instances.

  3. In the upper-left corner of the page, select the resource group and region to which the desired instance belongs.

  4. Click the ID of the instance or click Manage in the Actions column.

  5. In the Specifications section of the instance details page, click Upgrade Database Version and select the major version to which you want to upgrade the instance.

  6. In the Upgrade Database Version message, click OK.