Upgrade a Replica Set to 3.4
Note
Starting in version 3.4.21, MongoDB 3.4-series removes support forUbuntu 16.04 POWER/PPC64LE.
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-0ubuntu5
before 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.4, 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.4, you must berunning a 3.2-series release.
To upgrade from a version earlier than the 3.2-series, you mustsuccessively upgrade major releases until you have upgraded to3.2-series. For example, if you are running a 3.0-series, you must3.2before you can upgrade to 3.4.
Preparedness
Before beginning your upgrade, see the Compatibility Changes in MongoDB 3.4 document toensure that your applications and deployments are compatible withMongoDB 3.4. 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.4, you cannot downgrade to a 3.2.7 or earlierversion. You can only downgrade to a 3.2.8 or later version.
Warning
Avoid reconfiguring replica sets that contain members of differentMongoDB versions as validation rules may differ across MongoDB versions.
Prerequisites
To upgrade a replica set to 3.4, all replica set members must berunning version 3.2. To upgrade a replica set from an earlier MongoDBversion, upgrade all members of the replica set to the latest3.2-series releasefirst, and thenfollow the procedure to upgrade from MongoDB 3.2 to 3.4.
Download 3.4 Binaries
Via Package Manager
If you installed MongoDB from the MongoDB apt
, yum
, dnf
, orzypper
repositories, you should upgrade to 3.4 using your packagemanager.
Follow the appropriate 3.4 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.4 installation instructions for more information.
Upgrade Process
You can upgrade from MongoDB 3.2 to 3.4 using a “rolling” upgrade tominimize downtime by upgrading the members individually while the othermembers 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.2binary with the 3.4 binary. - Restart the member and wait for the member to recover to
SECONDARY
state before upgrading the next secondary member.To check the member’s state, issuers.status()
in themongo
shell.
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 the
mongod
binary with the 3.4 binary. - Restart.
Enable backwards-incompatible 3.4 features.
At this point, you can run the 3.4 binaries without the3.4 features that are incompatible with 3.2.
To enable these 3.4 features, set the feature compatibilityversion to 3.4.
Warning
Enabling these backwards-incompatible features can complicatethe downgrade process. For details,see Remove 3.4 Incompatible Features.
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.
On the primary, run the setFeatureCompatibilityVersion
command in the admin
database:
- db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
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
- To upgrade a standalone, see Upgrade a Standalone to 3.4.
- To upgrade a sharded cluster, see Upgrade a Sharded Cluster to 3.4.