Skip to content

MongoDB Upgrade Procedure

Felix Gabler edited this page Nov 9, 2022 · 6 revisions

Upgrading MongoDB on our servers

Always update step by step! The links change depending on the MongoDB version and the operating system version!

In-Depth instructions: https://www.mongodb.com/docs/manual/release-notes/6.0-upgrade-standalone/

Stop old installation

  1. Check feature capabilities are set correctly in authenticated mongo shell db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) => should be old version
  2. Stop mongod: service mongod stop

Update version

Refer to: https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-ubuntu/

Balata

  1. Import public key: wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | apt-key add -
  2. Create list file for MongoDB: echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
  3. Reload packages: apt update
  4. Update MongoDB: apt install -y mongodb-org
  5. Check versions of mongo and mongod with --version
  6. If this did not update the version, reinstall with: apt-get purge mongodb-org* && apt install -y mongodb-org

Rye

  1. Download new mongo version into ~/mongodb/sources: wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-5.0.13.tgz
  2. Extract tar xfz mongodb-linux-x86_64-ubuntu2004-5.0.13.tgz && rm mongodb-linux-x86_64-ubuntu2004-5.0.13.tgz
  3. Update symlink in ~/mongodb: rm mongo && ln -s sources/mongodb-linux-x86_64-ubuntu2004-5.0.13/ mongo
  4. Check versions of mongo and mongod with --version

Start new installation

  1. Start mongod: service mongod start
  2. Set new feature capabilities in authenticated mongo shell db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )
  3. Check feature capabilities are set correctly in authenticated mongo shell db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) => should be new version