MongoDB upgrade requires that you must upgrade to each version of MongoDB along the way.
...
Table of Contents
Prerequisites for Upgrading MongoDB 4.2 to MongoDB 6.0
This document outlines the process to bring MongoDB up to version 6.0. There are a series of prerequisites that determine the type of update required. This document outlines the process for MongoDB Standalone.
...
- Operating System
- MongoDB Version
- MongoDB Storage Engine
- NMIS and Modules for Mongo 6.0
Supported Operating Systems
MongoDB 6.0 is officially supported on the following Debian platforms:
...
Release: 11
Codename: bullseye
|
MongoDB 4.2 Installed and Running
Verify by running (with your mongodb <username> and <password>)
...
MongoDB shell version v4.2.25 MongoDB server version: 4.2.25
|
MongoDB Storage Engine
Verify storage engine by running
...
https://www.mongodb.com/docs/v4.2/tutorial/change-standalone-wiredtiger/
NMIS and Modules must be updated to versions that support MongoDB 6.0 before upgrading to MongoDB 6.0. These releases are backwards compatible with MongoDB v4.2 which means that you can upgrade to NMIS and Modules that support MongoDB 6.0, restart NMIS and Modules, and continue to use them with MongoDB 4.2, then upgrade your MongoDB from 4.2 to 6.0 later.
...
You should follow the standard upgrade process for each of these packages, which is handled by the FirstWave Installer.
Preparation
The preparation phase includes 3 sections
...
This is to be done in this specific sequence.
System Snapshot/Backup
For System Snapshots and Backups you will need to refer to the documentation for your environment.
...
- Full system backups, including Operating System and Data - Contact your IT department, Vendor Support, or Integrator
- Virtual Machine Snapshots - Refer to the solution guides for the environment
- Database Dump - MongoDB documentation: https://www.mongodb.com/docs/database-tools/mongodump/
Upgrade Linux Packages
After completing the snapshot/backup follow Debian's instructions for upgrading and checking the sanity of the apt package system.
...
Once this step is completed you may optionally reboot the system. This can clear out any memory leaks and instabilities in the system that occur due to long uptimes.
Shutdown All FirstWave Daemons
Prior to commencing into the MongoDB upgrade cycles it is required to shutdown all FirstWave processes.
...
user@servername:~ /installers
● nmis9d.service - FirstWave NMIS9 Daemon
Loaded: loaded (/etc/systemd/system/nmis9d.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2024-06-27 17:32:05 AEST; 26s ago
Process: 252049 ExecStartPre=/bin/sh -c sleep 3 (code=exited, status=0/SUCCESS)
Process: 252058 ExecStart=/usr/local/nmis9/bin/nmisd (code=exited, status=0/SUCCESS)
Main PID: 252105 (code=exited, status=0/SUCCESS)
CPU: 1h 23.745s
Jun 27 17:32:04 m6poller1 systemd[1]: Stopping FirstWave NMIS9 Daemon...
Jun 27 17:32:05 m6poller1 systemd[1]: nmis9d.service: Succeeded.
Jun 27 17:32:05 m6poller1 systemd[1]: Stopped FirstWave NMIS9 Daemon.
Jun 27 17:32:05 m6poller1 systemd[1]: nmis9d.service: Consumed 1h 23.745s CPU time.
|
Upgrade from MongoDB 4.2 to MongoDB 4.4
Prepare the Database for Upgrade
Check the database compatibility mode is set to "4.2"
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
|
The result should be as follows ensuring that the
The result should be as follows ensuring that the value 4.2 is set
{ "featureCompatibilityVersion" : "4.2" , "ok" : 1 }
|
If MongoDB is on version 4.2 and the featureCompatibilityVersion is not "4.2" then set this with the following command
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )';
|
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )' showMongoFcv
{ "featureCompatibilityVersion" : "4.2" , "ok" : 1 }
|
Debian - Install MongoDB 4.4 Repo and Upgrade
Details available here:
https://www.mongodb.com/docs/v4.4/release-notes/4.4-upgrade-standalone/ and https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-debian/
...
systemctl stop mongod
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add
echo "deb [ trusted=yes ] http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | \ sudo sudo gpg -o /usr/share/keyrings/mongodb-server-4.4.gpg \ --dearmor
echo "deb [ arch=amd64,arm64 signed-by=signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] httpshttp://repo.mongodb.org/apt/ubuntu focaldebian buster/mongodb-org/4.4 multiversemain" | \ sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get upgrade mongodb-org -y --allow-unauthenticated
mongod --version
systemctl stop mongod
systemctl start mongod
systemctl daemon-reload
systemctl is-active mongod
|
Complete the upgrade with the following commands and retest. If you skip the stop/start sequence above the following command will fail.
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )'
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
systemctl stop mongod
systemctl start mongod
|
setMongoFcv 4.4
showMongoFcv
systemctl stop mongod
systemctl start mongod
|
Upgrade from MongoDB 4.4 to MongoDB 5.0
Prepare the Database for Upgrade
Check the database compatibility mode is set to "4.4"
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
|
The result should be as follows ensuring that the value 4
The result should be as follows ensuring that the value 4.4 is set
{ "featureCompatibilityVersion" : "4.4" , "ok" : 1 }
|
...
Example Command and Output
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin -- quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
{ "featureCompatibilityVersion" : "4.4" , "ok" : 1 }
|
...
showMongoFcv
{ "featureCompatibilityVersion" : "4.4" , "ok" : 1 }
|
Debian - Install MongoDB 5.0 Repo and Upgrade
Details available here:
https://www.mongodb.com/docs/manual/release-notes/5.0-upgrade-standalone/ and https://www.mongodb.com/docs/v5.0/tutorial/install-mongodb-on-debian/
...
systemctl stop mongod
wget -qO - https: //www .mongodb.org /static/pgp/server-5 .0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-5.0.gpg --dearmor
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-5.0.gpg] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/5.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo ap t-get update
sudo apt-get upgrade -y mongodb-org
------------------------------------
If you get an error
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-database-tools-extra_5.0.27_amd64.deb
Fix it by using: sudo dpkg -i --force-overwrite /var/cache/apt/archives/mongodb-org-database-tools-extra_5.0.27_amd64.deb
then sudo apt-get upgrade -y mongodb-org
and answer N to keep your currently installed version of /etc/mongod.conf -------------------------------------
systemctl stop mongod ; systemctl start mongod ; systemctl daemon-reload ; systemctl is-active mongod ; systemctl status mongod
|
Complete the upgrade with the following commands and retest. If you skip the stop/start sequence above the following command will fail.
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )'
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )' setMongoFcv5.0
showMongoFcv
systemctl stop mongod ; systemctl start mongod ; systemctl status mongod
|
As before, check the featureCompatibilityVersion output from above is "5.0"
Example Command and Output
mongod ; systemctl status mongod
|
As before, check the featureCompatibilityVersion output from above is "5.0"
Example Command and Output
showMongoFcv
{ "featureCompatibilityVersion" : "5.0" , "ok" : 1 }
|
Upgrade from MongoDB 5.0 to MongoDB 6.0
Prepare the Database for Upgrade
Check the database compatibility mode is set to "5.0"
...
to "5.0"
The result should be as follows ensuring that the value 5.0 is set
{ "featureCompatibilityVersion" : "5.0" , "ok" : 1 }
|
If MongoDB is on version 5.0 and the featureCompatibilityVersion is not "5.0" then set this with the following command
...
5.0 and the featureCompatibilityVersion is not "5.0"
...
then set this with the following command
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin -- quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )' showMongoFcv
{ "featureCompatibilityVersion" : "5.0" , "ok" : 1 }
|
Debian - Install MongoDB 6.0 Repo and Upgrade
Details available here:
https://www.mongodb.com/docs/manual/release-notes/6.0-upgrade-standalone/ and https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-debian/k
Commands summarised here:
systemctl stop mongod
wget -qO - https: //www .mongodb.org /static/pgp/server-6 .0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get upgrade -y mongodb-org
and answer N to keep your currently installed version of /etc/mongod.conf
systemctl stop mongod ; systemctl start mongod ; systemctl daemon-reload ; systemctl is-active mongod ; systemctl status mongod
|
...
Note that you must now use the mongosh command instead of mongo
...
of mongo
setMongoFcv 6.0
showMongoFcv
systemctl stop mongod
systemctl start mongod
|
...
Example Command and Output
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin -- quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )' showMongoFcv
{ "featureCompatibilityVersion" : "6.0" , "ok" : 1 }
|
This completes the in-situ upgrade of MongoDB 4.2 to 6.0 Standalone
Restart All FirstWave Daemons
Now the MongoDB upgrade is complete, you can start all the NMIS and FirstWave daemons.
...