Upgrading from MongoDB 2.4 to 4.4

I want to upgrade mongodb from 2.4 to 4.4.

Is there mongodb upgrade any step?

  1. 2.4 →2.6→3.0→3.2→3.4→3.6→4.0→4.2→4.4
    sequential step

  2. 2.4→3.0→4.0→4.4
    large sequential step

  3. 2.4→4.4
    direct step

How should I do it? or is there another step?

Hi @Kim_Hakseon,

Your general options are currently #1 (sequential in-place major version upgrades with minimal downtime) or #3 (use mongodump & mongorestore to try to upgrade directly). You also have to coordinate upgrading your driver(s), which should happen prior to the server upgrade.

There are some variations on the upgrade options if you can get to a version of MongoDB supported by automation tooling. For further discussion, see my reply on Replace mongodb binaries all at once?.

Since you are catching up on seven years of upgrades, a lot has changed. If you are following the in-place upgrade approach, make sure you read the upgrade steps and compatibility changes for each major release. Some major releases may have slightly different upgrade steps. In particular, MongoDB 3.4+ major version upgrades include an explicit setFeatureCompatibilityVersion command to enable persisting data changes that previous releases may not not handle gracefully.

Regards,
Stennie

Oh, Thank you very much for your reply. :smiley:

Are you a mongodb vendor employee?

Hi @Kim_Hakseon,

Yes, I work for MongoDB. You can find out more in my intro on the forum: G'day, I'm Stennie from MongoDB 🇦🇺.

Regards,
Stennie

Thank you

Your answer will be very, very helpful to me.

Thank you. :smiley:

1 Like

I have one more question.

I am now upgrading mongodb step by step.

But there’s something I don’t understand.

image

This is what I record as I upgrade, and when I go from 3.x version to 4.0 version, the engine changes and the db size changes.
But why does the db size change when upgrading from 2.x version to 3.x version even though it is the same engine?

I used dump/restore to go up from 2.6 version and 3.6 version to 3.0 and 4.0 version.

Hi @Kim_Hakseon,

Some storage size differences are expected depending on the provenance of your data and the server versions/configuration involved. For a general comparison after upgrading or restoring your data, I would look at the db/collection/document counts and the data size which should be consistent.

Assuming “db size” is measuring the storage size of your dbPath, the change you observed is likely due to MMAPv1 Record Allocation Behaviour Changes in MongoDB 3.0 which removed support for the legacy dynamic record allocation strategy.

Earlier versions of MongoDB supported a dynamic record allocation strategy (variable sizes with padding factor for document growth) which was the historical MMAP default for new collections created prior to MongoDB 2.6. The dynamic allocation strategy could result in fragmentation and excessive storage use over time, and it was replaced with Power of 2 Sized Allocations. The new Power of 2 allocation strategy enabled better reuse of disk space with MMAP, but may preallocate more initial space depending on the size of your documents.

MongoDB server versioning scheme

Current server releases aren’t using semantic versioning so the first two digits of each release series are significant (2.4, 2.6, 3.0, …) rather than comparing 2.x versus 3.x (see MongoDB Versioning). The MMAP storage engine version is associated with a server release, with the general expectation that patch releases (x.y.z) do not introduce and backward compatibility changes but major releases (x.y) may. Any changes are documented in the release notes.

That may be helpful when considering why the in-place upgrade path currently doesn’t support skipping one or more successive major releases.

Note: the server versioning scheme will change starting with MongoDB 5.0 in 2021: Accelerating Delivery with a New Quarterly Release Cycle, Starting with MongoDB 5.0.

Regards,
Stennie

1 Like

That’s the difference in allocation, that’s the difference in size.

Thank you very much.

And I’m really excited and excited to hear that 5.0 will be released next year.

1 Like

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