Upgrade a Standalone to 4.2
The following steps outline the procedure to upgrade a standalonemongod
from version 4.0 to 4.2.
Important
Before you attempt any upgrade, please familiarize yourself with thecontent of this document.
If you need guidance on upgrading to 4.2, 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.2, you must berunning a 4.0-series release.
To upgrade from a version earlier than the 4.0-series, you mustsuccessively upgrade major releases until you have upgraded to4.0-series. For example, if you are running a 3.6-series, you mustupgrade first to 4.0before you can upgrade to 4.2.
Preparedness
Before beginning your upgrade, see the Compatibility Changes in MongoDB 4.2 document toensure that your applications and deployments are compatible withMongoDB 4.2. 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.2, if you need to downgrade, we recommend downgrading to the latest patch release of 4.0.
Prerequisites
MMAPv1 to WiredTiger Storage Engine
MongoDB 4.2 removes support for the deprecated MMAPv1 storage engine.
If your 4.0 deployment uses MMAPv1, you must change the 4.0 deploymentto WiredTiger Storage Engine before upgrading to MongoDB 4.2. For details,see Change Standalone to WiredTiger.
Review Current Configuration
With MongoDB 4.2, the mongod
andmongos
processes will not start withMMAPv1 Specific Configuration Options. Previous versions of MongoDB runningWiredTiger ignored MMAPv1 configurations options if they were specified.With MongoDB 4.2, you must remove these from your configuration.
Feature Compatibility Version
The 4.0 instance must have featureCompatibilityVersion
setto 4.0
. To check featureCompatibilityVersion
:
- db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
The operation should return a result that includes"featureCompatibilityVersion" : { "version" : "4.0" }
.
To set or update featureCompatibilityVersion
, run the followingcommand:
- db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
For more information, see setFeatureCompatibilityVersion
.
Download 4.2 Binaries
Via Package Manager
If you installed MongoDB from the MongoDB apt
, yum
, dnf
, orzypper
repositories, you should upgrade to 4.2 using your packagemanager.
Follow the appropriate 4.2 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.2 installation instructions for more information.
Upgrade Process
Replace existing 4.0 binaries with the 4.2 binaries.
Shut down your mongod
instance. Replace the existingbinary with the 4.2 mongod
binary.
Restart your deployment with the 4.2 mongod
.
Enable backwards-incompatible 4.2 features.
At this point, you can run the 4.2 binaries without the4.2 features that are incompatible with 4.0.
To enable these 4.2 features, set the feature compatibilityversion (FCV
) to 4.2.
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:
- db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )
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.
Post Upgrade
TLS
Options Replace DeprecatedSSL
Options- Starting in MongoDB 4.2, MongoDB deprecates the SSL options for themongod, the mongos, and the mongo shell aswell as the corresponding net.ssl Options configurationfile options.
To avoid deprecation messages, use the new TLS
options for themongod, the mongos, and the mongo shell.
- For the command-line TLS options, refer to the mongod, mongos, andmongo shell pages.
- For the corresponding
mongod
andmongos
configuration fileoptions, refer to the configuration file page. - For the connection string
tls
options, refer to theconnection string page.- 4.2-Compatible Drivers Retry Writes by Default
- The official MongoDB 3.6 and 4.0-compatible drivers required including the
retryWrites=true
option in the connectionstring to enable retryable writes for that connection.
The official MongoDB 4.2-compatible drivers enable Retryable Writes bydefault. Applications upgrading to the 4.2-compatible drivers that requireretryable writes may omit the retryWrites=true
option. Applications upgrading to the 4.2-compatible drivers that requiredisabling retryable writes must includeretryWrites=false
in the connection string.
Additional Upgrade Procedures
- To upgrade a replica set, see Upgrade a Replica Set to 4.2.
- To upgrade a sharded cluster, see Upgrade a Sharded Cluster to 4.2.