2

I have a mongodb 3.6 database with about 7TB of data, and wish to upgrade this to 6.0. It is a very basic db with no replicas, no sharding, etc. Downtime is not an issue - it can be down for days.

I am wondering how to best go about this. If I simply make a copy of the 3.6 db directory and try to load it on an up-to-date mongo version, this doesn't work as I am getting WiredTiger compatibility issues ("Failed to start up WiredTiger under any compatibility version" etc).

I am assuming that a mongodump of the 3.6 and restore in a 6.0 would work in theory, but with this amount of data I'm guessing the dump + restore would take weeks to run, if it even ever finishes?

1
  • I guess mongodump ... | mongorestore ... would work without the need to store 7TB physically on any disc. Commented Aug 16, 2022 at 12:49

2 Answers 2

4

ok I figured it out

one can simply update the mongo binaries but doing this via all the intermediate versions; first to 4.0, then 4.2, 4.4, 5.0, and finally 6.0

I did this without any copying or backup of the data, but I guess it would be advisable to do so for data you don't want to lose if something goes wrong.

each step follows standard mongodb major-version upgrade, e.g. running db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } ) when having upgraded from 3.6 to 4.0, and so on

1
  • Can you tell me if the performance of the database got better or worse after this update? I have the same version of Mongo and having performance problems on 3.6, and this link telling that it's going to be worse in the new version. serpapi.com/blog/the-downfall-of-mongodb-performance-2
    – Mahdi
    Commented May 20, 2023 at 8:31
0

Elaborating on @fso4242's answer:

I'm assuming here that this happened due to an upgrade from Ubuntu 20.04 to 22.04, so everything will be "apt-y".

First remove the already installed 6.0 version: apt remove mongodb-org -y && apt autoremove -y

Then:

  • wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add - and use deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse in /etc/apt/sources.list.d/mongodb.list

  • start mongod: /usr/bin/mongod --config /etc/mongodb.conf

    • open the mongo-shell with mongo
    • run db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )
    • wait for the { ok: 1 }.
    • Ctrl-D out of mongo, Ctrl-C the mongod server.
  • repeat above steps for:

    • wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - and deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse
    • wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - and deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse
      • here apt will complain - you can fix it with: apt --fix-broken install
    • wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - and deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse
    • and lastly wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add - and deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse
      • here the mongo cli is replaced by mongosh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.