Upgrade Major MongoDB Version for a Cluster
You can upgrade the major version of your Atlas cluster at any time by modifying the cluster.
To ensure that your transition to the new MongoDB version is smooth and doesn't affect your application, before you upgrade the major version on your production Atlas cluster, use the following procedure to create a staging cluster and test your application against the new MongoDB version.
Considerations
The following considerations apply:
Your cluster must be in a healthy state before upgrading.
If you take an on-demand snapshot before a major version upgrade, wait until the snapshot completes before you upgrade the version.
You can only upgrade your Atlas cluster one major version at a time. You cannot skip any major versions when upgrading your cluster.
Each major version contains some features which may not be backward-compatible with previous versions. When upgrading to a new major version, check the Release Notes for changes which may affect your applications. Alternatively, if you use the Stable API, you ensure that behavior changes between MongoDB versions do not break your application after an upgrade.
The MongoDB Stable API encompasses a subset of MongoDB commands that applications use to read and write data, create collections and indexes, and perform other common tasks. The Stable API allows you to specify which version of the MongoDB API your application runs against and provides long-term API stability for applications. It supports more frequent releases and automatic server upgrades, allowing your applications to take advantage of rapidly released features without risking backward incompatible changes.
After upgrading the MongoDB major version, you will not be able to downgrade to previous versions.
Starting with MongoDB 6.0, the
$$SEARCH_META
aggregation variable can't be used in any subsequent stage after a$searchMeta
stage.If you want to upgrade to MongoDB 6.0 from a previous version and use the
$$SEARCH_META
aggregation variable in your Atlas Search$searchMeta
queries, review them before you upgrade your cluster to avoid errors.
Required Access
To upgrade a cluster, you must have the Project Owner
or
higher role for the project.
Procedure
In Atlas, go to the Clusters page for your project.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
If the Clusters page is not already displayed, click Database in the sidebar.
The Clusters page displays.
Create an Atlas cluster for your staging environment.
Note
You can skip this step if you already have an Atlas cluster as your staging environment.
Click the Create button to open the cluster creation modal. Configure the staging cluster to match your production cluster. You do not have to enable backups for the staging cluster.
To learn how to create a new cluster, see Create a Cluster.
Important
If selecting a smaller cluster tier for the staging cluster, take into consideration that any performance tests run may not be representative of the performance of the upgraded production cluster. You may also need to select a larger storage size depending on the amount of data you want to mirror to your staging cluster.
Refresh the staging cluster with production cluster data.
Note
You can skip this step if you already have an up-to-date Atlas cluster as a staging environment.
If you have backups enabled for the production cluster, restore the most recent snapshot and choose the staging cluster as the destination.
If you do not have backups enabled for the production cluster, use Atlas Live Import to mirror data from your production cluster to the staging cluster. The live migration documentation includes specific instructions for creating staging environments.
Point your staging application at the staging cluster.
Update your staging application to point at your staging cluster. For instructions on retrieving the MongoDB driver-friendly connection string for the staging cluster, see Connect via Drivers.
Confirm that your application can connect successfully to the staging cluster and that the application operates as expected.
(Optional) Upgrade your application to the latest MongoDB drivers.
Upgrading your application to the latest MongoDB drivers for your cluster's MongoDB version enables full access to the features provided by the newer MongoDB version. You may also find better performance or stability with newer driver versions. See Connect via Drivers for documentation on the recommended MongoDB driver for a given MongoDB version and connection examples. By using the Stable API, you can ensure that behavior changes between MongoDB versions do not break your application.
If you encounter a bug after upgrading your application, file a ticket in the JIRA project for your MongoDB driver.
In Atlas, go to the Clusters page for your project.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
If the Clusters page is not already displayed, click Database in the sidebar.
The Clusters page displays.
Update the staging cluster to the new major MongoDB version.
Click Edit Config and select your staging cluster from the drop-down menu.
Change the cluster version to the desired major MongoDB Version.
Important
You cannot downgrade the MongoDB version of a Atlas cluster. If you want to redeploy the staging environment with the original MongoDB version, you must terminate and re-create the cluster.
Click Confirm & Deploy to deploy your changes.
Atlas automatically begins upgrading the cluster. Consider measuring the time required by Atlas to upgrade the cluster to set a general expectation for your production cluster upgrade.
File a support ticket if you encounter version-specific issues with the upgraded staging cluster.
Test your application against the upgraded staging cluster.
Perform any required performance and operational testing of the staging cluster.
File a support ticket if you encounter version-specific issues with the upgraded staging cluster.
Important
The major version upgrade requires at least one replica set election. Use the staging cluster as an opportunity to test your application's resilience to primary failover. See Test Primary Failover for complete documentation.
Upgrade your production cluster to the target MongoDB version.
Once you are confident in the performance and operation of your staging cluster, repeating the upgrade procedure for your production cluster.
Once Atlas completes the upgrade process, check that your production applications are still connected and operating normally.
If you upgraded your staging application with newer MongoDB drivers and are satisfied with the performance and operation, consider scheduling a maintenance period for upgrading your production applications.
If you encounter problems with the upgraded production cluster, file a High Priority support ticket using the procedure in the following section.
Support for Major Version Upgrades
If you have any questions regarding migration support beyond what is covered in this documentation, or if you encounter an error during migration, file a support ticket through the Atlas user interface.
To file a support ticket:
In Atlas, go to the Project Support page.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
Next to the Projects menu, expand the Options menu, then click Project Support.
The Project Support page displays.