I am trying to upgrade mongodb from 4.4 > 5.0

I have a 2 separate replica set (replicaset1, replicaset2) which hosts different platform on our site.

replicaset1 setup: (mongodb version 4.4)
rs1VM1 ( - PRIMARY
rs2VM1 ( - ARBITER
replicaset2 setup: (mongodb version 4.4)
rs2VM1 ( - PRIMARY
rs1VM1 ( - ARBITER

We happened to put the arbiter for each replicaset on the other platform to provide at least a little bit of HA on our setup.

Now I want to upgrade only the replicaset1 from 4.4 > 5.0

My proposed approach would be:

  1. Create a arbiter on rs1VM1 ( that would be - ARBITER
  2. Delete the old arbiter rs2VM1 ( on the replicaset1
  3. Shutdown the secondary then upgrade the binary files. Restart mongod on secondary

After this the setup would be

replicaset1 setup: (mongodb version 4.4)
rs1VM1 ( - PRIMARY (mongod 4.4)
rs1VM2 ( - SECONDARY (mongod 5.0)
rs1VM3 ( - ARBITER (mongod 4.4)
  1. Once secondary is already good. I would create another arbiter which will be located on rs1VM2 ( After this the setup would be
replicaset1 setup: 
rs1VM1 ( - PRIMARY (mongod 4.4)
rs1VM2 ( - SECONDARY (mongod 5.0)
rs1VM2 ( - ARBITER (mongod 5.0)
  1. Now I can now upgrade the PRIMARY. Perform rs.stepDown() then db.shutdownServer(), then upgrade the binary files to 5.0 then restart mongodb service
replicaset1 setup: 
rs1VM1 ( - PRIMARY (mongod 5.0)
rs1VM2 ( - SECONDARY (mongod 5.0)
rs1VM2 ( - ARBITER (mongod 5.0)

is this feasible or there are much more easier approach to this

  • I don't think you can mix MongoDB version within a replica set. However, the MongoDB is a simple binary, you can run multiple versions on the same machine, just install them in different directories. Sep 2, 2022 at 21:09
  • @WernfriedDomscheit how is this possible on Ubuntu 18.04?
    – JRA
    Sep 5, 2022 at 6:35
  • Yes, of course. However, the installer installs it into default directory (e.g. /usr/bin/mongod). Download the binary package tgz. It's really just a single binary mongod, copy it to your machine, then you can use it. Of course, you must edit your .service files accordingly. See manpages.ubuntu.com/manpages/xenial/man5/systemd.service.5.html Sep 5, 2022 at 6:59
  • @WernfriedDomscheit Can I just use the downloaded mongod from tgz in this script? sudo nohup mongod --port 27018--dbpath /datadrive/mongodb-arb --replSet rep1 --bind_ip --keyFile /home/test/repkey &
    – JRA
    Sep 5, 2022 at 7:48
  • Yes, it should wok. I prefer rather a configuration file and define it as as service but that's up to you. Sep 5, 2022 at 9:26

2 Answers 2


Yes, you can do that. However, because arbiters don't have any DB data, there is no reason to do that. Just upgrade your arbiters to 5.0, then upgrade your secondaries to 5.0, when those secondaries are "up-to-date", step down primaries (they become secondary) and upgrade those last nodes to 5.0.

Look here!

  • this is my problem on the arbiter. Since the original arbiter is on a different platform (currently on 4.4 which will not be upgraded to 5.0) how can I make this happen?
    – JRA
    Sep 5, 2022 at 6:37

I deviated from my original approach and I tried to download the tgz and not the normal installer for mongodb as per suggestion of @Wernfried which contains the binary files.

From there, the method that I did was pretty simple.

  1. Upgrade the Arbiter, Secondary then the Primary

After extracting the tgz file, I just pointed the mongod on the new directory where I extracted the tgz file. (which contains the updated binary mongod, mongo, etc.)

sudo nohup mongod --port 27018--dbpath /datadrive/mongodb-arb --replSet rep1 --bind_ip --keyFile /home/test/repkey &

Then the upgrade process went smooth

Your Answer

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

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