Upgrading Ubuntu breaks MongoDB

I am new to MongoDB devops, and I’m having issues upgrading multiple servers from Ubuntu 16.04 to 18.04. Doing the upgrade breaks the Mongo databases present on the system. The servers are running the Ubuntu official versions of MongoDB, 2.6.10 on 16.04 and 3.6.3 after the upgrade. As far as I understand the way to fix it is to downgrade mongo and to the rolling updates.

This does not feel like the intended way to upgrade the systems, and I have so far been unable to find a propper way to do it. Is it really the intended result to have to downgrade Mongo manually and upgrade step by step?

I appreciate any suggestions, thank you in advance.

Related bug on Launchpad: https://answers.launchpad.net/ubuntu/+source/mongodb/+question/691008

From Mongo Ubuntu Install.


The mongodb package provided by Ubuntu is not maintained by MongoDB Inc. and conflicts with the official mongodb-org package. If you have already installed the mongodb package on your Ubuntu system, you must first uninstall the mongodb package before proceeding with these instructions.

This is the best supported way to upgrade your database to a supported version. The documentation is in each releases, upgrade notes. There are important steps along the way

My advise is to also remove the Ubuntu repository version of mongodb and install from the MongoDB repository.

You are also well advised to look at your client drivers as this many major versions include depreciations along the way.

1 Like

Thank you for replying Chris. I understand the Ubuntu package is not maintained by MongoDB Inc, do you have any idea why it is this way?

For this project other third party repositories is not an option, so I will have to rely on what is available from Ubuntu. We also need to find a way to upgrade these systems automatically but I will create a new post for that.

Hi @LostNotFound while I can’t state why Ubuntu maintains their own packages for MongoDB I will state that for a production system it’s probably best to pin the MongoDB version so any type of update is not going to upgrade MongoDB before you’re ready to do that.

There are notes in the documentation that shows how you would pin a version in Ubuntu. This will keep MongoDB from getting updated when running apt upgrade. I would hope that it would stop when you ran do-release-upgrade as well, but I’ve not tried that before to verify. A system wouldn’t know that there are specific steps to follow for upgrading packages and will just install the newest versions of installed software unless told not to.

The other option you have, and this is what I’ve done in the past, is to manually install MongoDB without a package manager. This requires more work as you’d have to manually add the user/groups, build out the directories and write your own service file among other things as well as perform the upgrades and any changes that might be needed.

1 Like

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

Thank you for your suggestion Doug, pinning seems to be what we have to do in the short term. As for the long run I suspect we will have to move away from MongoDB, or at least rely a lot less on it compared to now.