How to upgrade mongoDB 3.x to 5.x

Need help to understand in-place upgrade from Mongo 3.x to 5.x.

Hi @kalyan_kumar and welcome in the MongoDB Community :muscle: !

If you want to upgrade in place, you have to follow the usual rolling upgrade procedure for each major release of MongoDB.

This is a bit old, but the concept haven’t changed a lot: Your Ultimate Guide to Rolling Upgrades | MongoDB Blog

Basically the idea is to update the secondaries one by one first. Then stepdown the primary and upgrade the former primary node.

For each major release, you have a page in the release notes that explains how to move from the previous major release to the next.

For example 3.6 => 4.0:

So basically if you are starting in 3.0, you will have to upgrade as follow:

3.0 => 3.2 => 3.4 => 3.6 => 4.0 => 4.2 => 4.4 => 5.0

Another way to upgrade easily would be to use the live migration tool and migrate to Atlas. This support a wider gap between the source and the destination cluster.

So for example, you could directly migration from 3.0 to a 5.0 cluster in Atlas with this live migration tool.

As you can see, keeping MongoDB up-to-date with the latest features and security patches (OS and MongoDB) is a bit tedious. MongoDB Atlas removes that workload from your shoulders as everything is automated in Atlas and the rolling upgrade mechanism with zero downtime is of course implemented correctly in the workflow.



Thanks Maxime for detailed info

1 Like

Make sure to read all the “Upgrade Docs” in the release notes for each version. Each major release comes with a bunch of verifications, recommendations or commands that you must run in order to upgrade properly and keep your RS healthy while following the procedure.

For example the bind_ip new option in 3.6 is an easy trap to miss and your nodes won’t be able to communicate with each other without a proper update of the config files.

This command is also important for example:

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

All these specificities for each versions are in the docs.


1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.