Upgrading production MongoDB to a newer version
In this recipe, we will look at how to upgrade MongoDB binaries in a replica set. This recipe holds true even for config and shard servers.
Getting ready
We will assume you have a three-node MongoDB replica set.
How to do it...
- Before even touching a system, go through the release notes carefully. There are serious implications when upgrading binaries that have backward-incompatible changes or variance in operational parameters.
- Take a full backup of your entire system.
- If you have installed MongoDB binaries using the operating system's package manager, such as
apt
(Ubuntu) oryum
(Red Hat/CentOS), the upgrade process might trigger a service restart. Hence, do not install new packages until the service is manually shut down. - Log in to one of the secondary nodes in the replica set and shut it down:
use admin db.shutdownServer()
- Once the mongod/mongos instance is shut down, install the upgraded package on the system and start the service.
- Log in to the...