When new MongoDB versions are supported by ApsaraDB for MongoDB, you can upgrade your instance to the latest MongoDB version in the ApsaraDB for MongoDB console to try more features. This topic describes the MongoDB versions to which instances can be upgraded and how to upgrade the MongoDB version of an instance.

MongoDB versions

For more information about the MongoDB versions supported by ApsaraDB for MongoDB, see MongoDB versions and storage engines.

MongoDB versions for upgrade

Instance architecture MongoDB version before upgrade MongoDB version after upgrade Description
Standalone instances
  • MongoDB 4.0
  • MongoDB 3.4
- Upgrade to MongoDB 4.0 is not supported. For an ApsaraDB for MongoDB instance that runs MongoDB 4.0, select the MongoDB version when you create the instance. For more information, see Create a standalone instance.
Replica set instances
  • MongoDB 5.0
  • MongoDB 4.4
  • MongoDB 4.2
  • MongoDB 4.0
  • MongoDB 3.4
  • MongoDB 3.2 (phased-out)
  • MongoDB 4.2
  • MongoDB 4.0
  • MongoDB 3.4
Upgrade to MongoDB 5.0 or 4.4 is not supported. For an ApsaraDB for MongoDB instance that runs MongoDB 5.0 or 4.4, select the MongoDB version when you create the instance. For more information, see Create a replica set instance.
Sharded cluster instances
  • MongoDB 4.2
  • MongoDB 4.0
  • MongoDB 3.4
  • MongoDB 3.2 (phased-out)
  • MongoDB 4.2
  • MongoDB 4.0
  • MongoDB 3.4
-

Precautions

  • The duration of upgrading the MongoDB 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 MongoDB version of an instance after you upgrade it.
  • To ensure better performance and stability of the instance, the system will upgrade the minor version to the latest version by default. If the minor version of your instance expires or is not included in the maintenance list and the instance is upgraded, migrated, changed, Created from a backup, Created by point-in-time, or performed Restore one or more databases of an ApsaraDB for MongoDB instance.

Notes

  • 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. This way, a primary/secondary switchover can be performed to ensure that the read and write operations of your application remain available even if a node fails. For more information, 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.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and the region of the target instance.
  3. In the left-side navigation pane, click Replica Set Instances, or Sharded Cluster Instances based on the instance type.
  4. Find the target instance and click its ID.
  5. On the Basic Information page, click Upgrade Database Version and select the version for upgrade.
  6. In the Upgrade Database Version message, click OK.

    The instance state changes to Upgrading. When the instance is in the Running state, the upgrade is complete.