Does updating the version of mongodb affect the system's program?

Hi, pro
Now, I want to update my mongodb from 2.6.9 to 4.0.28 or maybe higher.
But i am worried when i update mongodb will affect system program. For example, there is syntax change (mongodb driver syntax) that causes the project to crash.
My back-end is Nodejs (v6.11.5) and mongodb driver version is 2.1.0

If it doesn’t affect anything, that’s great.

Thanks very much

Check release notes for any incompatible changes.

Upgrading MongoDB from version 2.6.9 to 4.0.28 (or higher) is a multi-step process that involves upgrading through several major versions. MongoDB does not support skipping major versions in an upgrade path. Here’s a general overview of the steps you would need to follow:

Upgrade Path

  1. Upgrade from 2.6 to 3.0
  2. Upgrade from 3.0 to 3.2
  3. Upgrade from 3.2 to 3.4
  4. Upgrade from 3.4 to 3.6
  5. Upgrade from 3.6 to 4.0

General Steps for Each Upgrade

  1. Review Release Notes: For each target version, review the release notes and upgrade notes provided by MongoDB. Pay special attention to any backward-incompatible changes or removed features.

  2. Backup Data: Before starting the upgrade, make sure you have a recent backup of your data.

  3. Test in a Staging Environment: It’s highly recommended to test each upgrade step in a staging environment before applying it to your production environment.

  4. Upgrade MongoDB Binaries: Download and install the MongoDB binaries for the target version.

  5. Upgrade Standalone Instances: If you have a standalone MongoDB server, simply stop the server, replace the binary, and start the server again.

  6. Upgrade Replica Sets: For a replica set, upgrade the secondary nodes first:

    • Step down the primary (if needed).
    • Stop the MongoDB process on a secondary node.
    • Replace the MongoDB binary with the new version.
    • Start the MongoDB process and wait for the node to catch up.
    • Repeat for each secondary node.
    • Finally, step down the primary, upgrade it, and restart it.
  7. Upgrade Sharded Clusters: If you have a sharded cluster, the process involves upgrading all components (config servers, shards, and mongos routers). Upgrade all shard replica sets first, then the config servers, and finally the mongos instances.

  8. Update Configuration Files: If the new version introduces new configuration options or deprecates existing ones, update your configuration files accordingly.

  9. Monitor Applications and Performance: After each upgrade, monitor your applications for any unexpected behavior and check the performance of the MongoDB server.

  10. Set Feature Compatibility Version (FCV): After reaching MongoDB 3.4 and above, set the FCV to the version you just upgraded to. This enables the features of that version and finalizes the upgrade.

    db.adminCommand( { setFeatureCompatibilityVersion: "<version>" } )


  • MongoDB 4.0 requires WiredTiger as the storage engine. If you’re using MMAPv1, you’ll need to migrate to WiredTiger.
  • Review the hardware and software requirements for each version, as they might change between major releases.
  • The upgrade process can be complex and time-consuming. It’s crucial to thoroughly plan and test each step.

Upgrading Beyond 4.0

If you plan to upgrade to a version higher than 4.0, continue the same process:

  • Upgrade to each subsequent major version (4.2, 4.4, etc.) following the same steps and considerations.

Remember, the exact details and commands may vary based on your specific MongoDB setup, so always refer to the official MongoDB documentation for each version you are upgrading to.