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

Precautions

  • 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 re-establish a connection.
    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 Current major version Major version available for upgrade
Standalone
  • MongoDB 3.4
  • MongoDB 4.0
N/A
Replica set instance MongoDB 5.0 N/A
MongoDB 4.4 MongoDB 5.0
MongoDB 4.2 N/A
MongoDB 4.0 MongoDB 4.2
MongoDB 3.4
  • MongoDB 4.0
  • MongoDB 4.2
Sharded cluster instance MongoDB 5.0 N/A
MongoDB 4.4 MongoDB 5.0
MongoDB 4.2 N/A
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. Depending on the major versions involved, check and modify the client code 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 issues 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 Upgrading the major version.
    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 based on the instance type.
  3. In the upper-left corner of the page, select the resource group and region to which the instance belongs.
  4. Click the ID of an instance, or click More icon in the Actions column corresponding to the instance and select Manage.
  5. Click Upgrade Database Version in the upper-right corner of the Specifications section and select the major version to which you want to upgrade the instance.
  6. In the Upgrade Database Version message, click OK.