Mongodb version upgrade 3.4 to latest

Hi Hello Everyone,

I’m trying to find best solution for migration all MongoDB cluster from 3.4 to latest. the old system is running on MongoDB 3.4 on Centos7.
In mongo official page(Release Notes for MongoDB 8.0 - Database Manual - MongoDB Docs) 4 and 5 versions are not available.
How to upgrade the mongodb from version 3.4 to latest?
And i am maintaining primary and 2 secondaries.

Thanks,
Yaswanth

These versions should be available. In the MongoDB Download page go to “More Options … → Archived Releases”
There you can download MongoDB down to version 2.6

Hi Wernfried_Domscheit

Thanks for the update, can you please guide me how to upgrade process?

3.4 to one-by-one version to upgrade, right?

Thanks,
yaswanth

@yaswanth_k

Generally yes it is major version to major version. But there are many changes over all these versions. If you download the legacy docs for v4.2 that will include the release notes, compatibility changes and upgrade instructions for all the versions until 4.2, follow the online manual after that.

All the versions to upgrade through looks like:
3.4 → 3.6 → 4.0 → 4.2 → 4.4 → 5.0 → 6.0 → 7.0 → 8.0

An OS upgrade will have to take place to get to MongoDB version 8.0 as RHEL/Centos 7 is not supported for that version.

Good luck, take backups and document as you go!

Since MongoDB 3.4 is quite old (released in 2016), a direct upgrade to the latest version (8.0) requires a phased approach. Below is the detailed upgrade path and steps:

Upgrade Path

The officially recommended MongoDB upgrade sequence is:

3.4 → 3.6 → 4.0 → 4.2 → 4.4 → 5.0 → 6.0 → 7.0 → 8.0

Detailed Upgrade Steps

1. Preparations

Back up data:

mongodump --host <old_host> --port --out /backup/path

Check compatibility:

  • Verify application compatibility with the new version
  • Check for deprecated features in use
  • Ensure CentOS 7 meets the requirements for newer versions (system library updates may be needed)

2. Phased Upgrade

Step 1: 3.4 → 3.6

  1. Install MongoDB 3.6:

sudo yum install -y mongodb-org-3.6 mongodb-org-server-3.6 mongodb-org-shell-3.6 mongodb-org-mongos-3.6 mongodb-org-tools-3.6

  1. Stop the 3.4 service and start 3.6:

sudo systemctl stop mongod sudo systemctl start mongod

  1. Run compatibility check:

mongo --eval “db.adminCommand({getParameter:1,featureCompatibilityVersion:1})”

  1. Set the feature compatibility version:

mongo --eval “db.adminCommand({setFeatureCompatibilityVersion:‘3.6’})”

Subsequent Steps

Repeat a similar process for each version, paying special attention to:

  • 4.0+: Requires the WiredTiger (WT) storage engine (MMAPv1 is no longer supported)
  • 4.2+: Must set featureCompatibilityVersion to the latest version
  • 5.0+: Index compatibility must be verified
  • 6.0+: Check for time-series collections and change stream usage
  • 7.0+: Review new aggregation pipeline features
  • 8.0+: Validate new query capabilities and encryption options

3. Alternative: Logical Migration

If a step-by-step upgrade is too complex, consider:

  1. Installing MongoDB 8.0 on a new server
  2. Migrating data using mongodump and mongorestore
  3. Performing selective migration with mongoexport and mongoimport

Export data mongoexport --host old_host:port --db dbname --collection collname --out collname.json # Import data mongoimport --host new_host:port --db dbname --collection collname --file collname.json

4. Post-Upgrade Verification

  1. Confirm all applications are functioning correctly
  2. Validate index and query performance
  3. Check replica set status (if applicable)
  4. Test sharded cluster functionality (if used)

Important Considerations

  1. Downtime: Plan sufficient maintenance windows
  2. Rollback Plan: Prepare a strategy to revert to the old version if needed
  3. Driver Compatibility: Ensure application MongoDB drivers support the new version
  4. CentOS 7 Limitations: Newer MongoDB versions may require updated system libraries; consider upgrading to CentOS 8 or migrating to another supported platform

For more detailed version-specific upgrade instructions, refer to the “Upgrade” section in the official MongoDB documentation for each release.

Thanks for the guidance @chris

Thanks for the guidance @dogs_Cute

I upgraded 3.4 to 4.4, working fine.

But, i want to upgrade to latest version of mongodb.
issue is - i am using centos7 server.

how to upgrade?

which OS is best for new setup?
Guide me how to move.

If MongoDB 8.0 is not supported on Centos7, then I would suggest upgrade to MongoDB version 7.0 which is fully supported and way better than version 3.4.
Later, when you upgraded your Linux (Centos 7 is also out of support), then you can go for MongoDB 8.0

Thanks @Wernfried_Domscheit