Overview

Upgrading in mongo is performed depending on the starting point. If you are like me and started with old release like 2.6, then you are screwed because you will have to pass through a lot of upgrades to reach the current one (4.3). So let's get going:

Upgrade from 2.6 to 4.3

In order to upgrade from 2.6 to 4.3 we have to do the following:

Upgrade binaries: 2.6 → 3.0 → 3.2 → 3.4

Upgrade datafiles: 3.2 → 3.4

Upgrade Binaries: 3.4 → 3.6 → 4.0 → 4.2 → 4.3

So let's get going:

Upgrade to 3.0

The upgrades until 3.4 are so called “drop-in” upgrades. Meaning exactly that:

Stop the server

Modify the yum configuration file

Upgrade the libraries

Start the server

Check the version

Stop the server

As I mentioned, stopping of the server can be done gracefully or killfully. Let's do it killfully (not recommended though)

Modify yum config file

In order to upgrade the libraries, we have to add new entry in the /etc/yum.repod.d/mongodb.conf for the new repository:

Once it is added, we can upgrade to the new version:

Upgrade the libraries

And voila, the mongo was upgraded from 2.6 → 3.0. Now, let's verify if all was fine with the upgrade:

Start the server

Check the version

So let's continue then.

Upgrade to 3.2

One again:

Stop the server

P.S. THIS ISN'T RECOMMENDED WAY TO STOP IT, please addess “Stopping/Starting” section in the chapter for better way. I do it like that to save time, since I will need to change the IP and use localhost and bla bla bla…

Modify the yum config file

Upgrade the libraries

Start the server

Check the version

Upgrade to 3.4

And again :)

Shutdown server

Modify the yum config file

Upgrade the libraries

Start the server

Verify the version

Now I know that this was boring BUT, I wanted to reach at least up to 3.4 so I can show you what happens if you don't upgrade the datafiles as well. If you continue like that and upgrade to 3.6, without upgrading the datafiles, you will receive the following error:

That pretty much says, that there was a problem starting the server, but no what is THE PROBLEM :) You can find more info in the LOG file, whose location is configured in the main config file (e.g. /etc/mongod.conf)

So in order to not encounter that (because if we encounter it we have to delete the 3.6, install 3.4 and do what we will do now :) ) We have to upgrade also the datafiles

Upgrade datafiles

It is done very easy. Just login on the server and execute: db.adminCommand( { setFeatureCompatibilityVersion: “3.4” } )

You can verify which is the current version of the datafiles using the following command:

And that is that, so let's continue to 3.6 and then I will skip it till 4.3 :)