Upgrade a Replica Set to 3.6

Note

  • MongoDB 3.6 is not tested on APFS, the new filesystem in macOS 10.13and may encounter errors.

  • Starting in MongoDB 3.6.13, MongoDB 3.6-series removes support for Ubuntu 16.04 PPCLE.

For earlier MongoDB Enterprise versions that support Ubuntu 16.04POWER/PPC64LE:

Due to a lock elision bug present in older versionsof the glibc package on Ubuntu 16.04 for POWER, you mustupgrade the glibc package to at least glibc 2.23-0ubuntu5before running MongoDB. Systems with older versions of theglibc package will experience database server crashes andmisbehavior due to random memory corruption, and are unsuitablefor production deployments of MongoDB

Important

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

If you need guidance on upgrading to 3.6, 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 3.6, you must berunning a 3.4-series release.

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

Preparedness

Before beginning your upgrade, see the Compatibility Changes in MongoDB 3.6 document toensure that your applications and deployments are compatible withMongoDB 3.6. 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 3.6, if you need to downgrade, we recommend downgrading to the latest patch release of 3.4.

Default Bind to Localhost

Starting in MongoDB 3.6, mongod and mongosinstances bind to localhost by default. Remote clients, including othermembers of the replica set, cannot connect to an instance bound only tolocalhost. To override and bind to other ip addresses, use thenet.bindIp configuration file setting or the —bind_ipcommand-line option to specify a list of ip addresses.

The upgrade process will require that you specify thenet.bindIp setting (or —bind_ip) if your replica setmembers are run on different hosts or if you wish remote clients toconnect to your replica set.

Warning

Before binding to a non-localhost (e.g. publicly accessible)IP address, ensure you have secured your cluster from unauthorizedaccess. For a complete list of security recommendations, seeSecurity Checklist. At minimum, considerenabling authentication andhardening network infrastructure.

For more information, see Localhost Binding Compatibility Changes

Initial Syncs

Before starting the upgrade, ensure that no initial sync is inprogress. Performing the upgrade while an initial sync is inprogress will cause the initial sync to restart.

Read Concern Majority

Starting in MongoDB 3.6, MongoDB enables support for “majority” read concern by default.

For MongoDB 3.6.1 - 3.6.x, you can disable read concern“majority” to prevent thestorage cache pressure from immobilizing a deployment with aprimary-secondary-arbiter (PSA) architecture. Disabling“majority” read concern alsodisables support for change streams

For more information, see Disable Read Concern Majority.

Prerequisites

    • Feature Compatibility Version
    • The 3.4 replica set must havefeatureCompatibilityVersion set to 3.4.

To ensure that all members of the replica set havefeatureCompatibilityVersion set to 3.4, connect to eachreplica set member and check the featureCompatibilityVersion:

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

All members should return a result that includes"featureCompatibilityVersion": "3.4".

To set or update featureCompatibilityVersion, run thefollowing command on the primary. A majority of the data-bearingmembers must be available:

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

For more information, seesetFeatureCompatibilityVersion.

    • Replica Set Member State
    • Ensure that no replica set member is in ROLLBACK orRECOVERING state.

Download 3.6 Binaries

Via Package Manager

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

Follow the appropriate 3.6 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 3.6 installation instructions for more information.

Upgrade Process

You can upgrade from MongoDB 3.4 to 3.6 using a“rolling” upgrade to minimize downtime by upgrading the membersindividually while the other members are available:

Upgrade secondary members of the replica set.

Upgrade the secondarymembers of the replica set one at a time:

  • Shut down the mongod instance and replace the 3.4binary with the 3.6 binary.

  • Restart the member.

Important

If your replica set members are run on different hosts or ifyou wish remote clients to connect to your instance, you mustspecify the net.bindIp setting (or —bind_ip).For more information, see Localhost Binding Compatibility Changes.

Step down the replica set primary.

Connect a mongo shell to the primary and users.stepDown() to step down the primary and force anelection of a new primary.

Upgrade the primary.

When rs.status()shows that the primary has stepped down and another memberhas assumed PRIMARY state, upgrade the stepped-down primary:

  • Shut down the stepped-down primary and replace themongod binary with the 3.6 binary.

  • Restart the member.

Important

If your replica set members are run on different hosts or ifyou wish remote clients to connect to your instance, you mustspecify the net.bindIp setting (or —bind_ip).

Enable backwards-incompatible 3.6 features.

At this point, you can run the 3.6 binaries without the3.6 features that are incompatible with 3.4.

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

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.

Tip

Ensure that no initial sync is in progress. RunningsetFeatureCompatibilityVersion command while an initialsync is in progress will cause the initial sync to restart.

On the primary, run the setFeatureCompatibilityVersion command in the admin database:

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

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

Additional Upgrade Procedures