Skip to content

Instantly share code, notes, and snippets.

@jbutko
Last active June 24, 2022 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbutko/36ac33a98d3b83775ee5f06e0167a9f7 to your computer and use it in GitHub Desktop.
Save jbutko/36ac33a98d3b83775ee5f06e0167a9f7 to your computer and use it in GitHub Desktop.
[Ubuntu] Upgrade mongodb version (applies to the replica member)

To upgrade mongodb (even on replica member) from 4.2 to 4.4:

  1. ensure proper feature compatibility version:
sudo mongo
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) -> should return current version (4.2), if not set it:
db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } ) -> set the version to currently installed version
  1. backup mongodb.conf file: sudo cp /etc/mongod.conf ~/mongod.conf.bak
  2. shutdown mongo service: sudo service mongod stop
  3. delete mongodb installation: sudo apt-get -y purge mongodb-org* (the data stays intact)
  4. intall new mongodb version with following steps: https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition
  5. restore mongodb.conf backup:
sudo mv ~/mongod.conf.bak /etc/mongod.conf
  1. restart mongodb service: https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-ubuntu/#start-mongodb-1
 sudo service mongod stop
 sudo service mongod start
  1. Enable backwards-incompatible 4.4 features: db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment