Upgrade a Standalone to 4.0

Important

MongoDB 4.0 may lose data during unclean shutdowns on macOS 10.12.x and 10.13.x.

For details, see WT-4018.

The following steps outline the procedure to upgrade a standalonemongod from version 3.6 to 4.0.

Important

Before you attempt any upgrade, please familiarize yourself with thecontent of this document.

If you need guidance on upgrading to 4.0, MongoDB offers major versionupgrade services to help ensurea smooth transition without interruption to your MongoDB application.

Upgrade Recommendations and Checklists

When upgrading, consider the following:

Upgrade Version Path

To upgrade an existing MongoDB deployment to 4.0, you must berunning a 3.6-series release.

To upgrade from a version earlier than the 3.6-series, you mustsuccessively upgrade major releases until you have upgraded to3.6-series. For example, if you are running a 3.4-series, you mustupgrade first to 3.6before you can upgrade to 4.0.

Preparedness

Before beginning your upgrade, see the Compatibility Changes in MongoDB 4.0 document toensure that your applications and deployments are compatible withMongoDB 4.0. Resolve the incompatibilities in your deployment beforestarting the upgrade.

Before upgrading MongoDB, always test your application in a stagingenvironment before deploying the upgrade to your productionenvironment.

Downgrade Consideration

Once upgraded to 4.0, if you need to downgrade, we recommend downgrading to the latest patch release of 3.6.

Prerequisites

Remove Support for MONGODB-CR

Starting in version 4.0, MongoDB removes support for the deprecatedMongoDB Challenge-Response (MONGODB-CR) authentication mechanism.

If your deployment has user credentials stored in MONGODB-CRschema, you must upgrade to Salted Challenge ResponseAuthentication Mechanism (SCRAM)before youupgrade to version 4.0. For information on upgrading to SCRAM, seeUpgrade to SCRAM.

See also

Compatibility Changes in MongoDB 4.0

Remove Support for $isolated

MongoDB drops support for the $isolated operator. If you have anexisting partial index that includes the $isolated operator or aview that includes a $isolated operator, recreate the index orview without the operator in the definition before upgrading.

Feature Compatibility Version

The 3.6 instance must have featureCompatibilityVersion setto 3.6. To check featureCompatibilityVersion:

  1. db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )

The operation should return a result that includes"featureCompatibilityVersion" : { "version" : "3.6" }.

To set or update featureCompatibilityVersion, run the followingcommand:

  1. db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )

For more information, see setFeatureCompatibilityVersion.

Download 4.0 Binaries

Via Package Manager

If you installed MongoDB from the MongoDB apt, yum, dnf, orzypper repositories, you should upgrade to 4.0 using your packagemanager.

Follow the appropriate 4.0 installation instructions for your Linux system. Thiswill involve adding a repository for the new release, then performingthe actual upgrade process.

Manually

If you have not installed MongoDB using a package manager, you canmanually download the MongoDB binaries from the MongoDB DownloadCenter.

See 4.0 installation instructions for more information.

Upgrade Process

Replace existing 3.6 binaries with the 4.0 binaries.

Shut down your mongod instance. Replace the existingbinary with the 4.0 mongod binary.

Restart your deployment with the 4.0 mongod.

Enable backwards-incompatible 4.0 features.

At this point, you can run the 4.0 binaries without the4.0 features that are incompatible with 3.6.

To enable these 4.0 features, set the feature compatibilityversion (FCV) to 4.0.

Tip

Enabling these backwards-incompatible features can complicate thedowngrade process since you must remove any persistedbackwards-incompatible features before you downgrade.

It is recommended that after upgrading, you allow your deployment torun without enabling these features for a burn-in period to ensurethe likelihood of downgrade is minimal. When you are confident thatthe likelihood of downgrade is minimal, enable these features.

Run the setFeatureCompatibilityVersion command against the admin database:

  1. db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )

This command must perform writes to an internal systemcollection. If for any reason the command does not completesuccessfully, you can safely retry the command asthe operation is idempotent.

Additional Upgrade Procedures