...
MongoDB 6.0 is officially supported on the following Ubuntu platforms:
MongoDB 6.0 supported on Ubuntu 22.04 LTS ("Jammy"), 20.04 LTS ("Focal"), 18.04 LTS ("Bionic")
MongoDB 5.0 supported on Ubuntu 20.04 LTS ("Focal"), 18.04 LTS ("Bionic")
MongoDB 4.4 supported on Ubuntu 20.04 LTS ("Focal"), 18.04 LTS ("Bionic"), 16.04 LTS ("Xenial")
We have tested the upgrade process from MongoDB 4.2 to MongoDB 6.0 on:
...
To determine the version of Linux running on your system use the following command in a terminal session:
An example output of this command
Release: 11
Codename: bullseye
|
MongoDB 4.2 Installed and Running
...
This command does not do anything however, the output will show us the running shell and server that is running.
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --eval 'quit()' | grep MongoDB
|
Result will look like below, we are looking for the two version numbers to be 4.2.x
If the versions do not match there may be an issue with your running installation and you should not proceed until this is resolved.
MongoDB shell version v4.2.25 MongoDB server version: 4.2.25
|
MongoDB Storage Engine
Verify storage engine by running
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.serverStatus().storageEngine'
|
The "name" line should have "wiredTiger" in order to proceed.
{
"name" : "wiredTiger" ,
"supportsCommittedReads" : true ,
"readOnly" : false ,
"persistent" : true
}
|
If this mongo cli command does not work you can try the following to determine the storage engine in use
grep -i "active storage engine" /var/log/mongodb/mongod.log*
|
Example correct log output - notice the log entry declares the storage engine to be using "wiredTiger"
2024-06-19T06:45:27.632+0000 I STORAGE [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
|
If the system is not using wiredTiger the data migration process should follow a different process. Refer to the following link.
...
An example of the update/upgrade cycle is as follows:
apt-get update && apt-get upgrade -y
|
This command will execute all outstanding upgrades. Check for any errors and address as required.
...
The following commands are used to complete this task
/usr/local/omk/bin/checkomkdaemons .sh stop
systemctl stop nmis9d
# confirm that the daemons have stopped /usr/local/omk/bin/checkomkdaemons.sh status systemctl status nmis9d
|
Example Command and Output
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
...
Check the database compatibility mode is set to "4.2"
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
showMongoFcv
{ "featureCompatibilityVersion" : "4.2" , "ok" : 1 }
|
Ubuntu - Install MongoDB 4.4 Repo and Upgrade
...
Commands summarised here:
systemctl stop mongod
curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-4.4.gpg --dearmor echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-4.4.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | \ sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get upgrade mongodb-org -y
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.
setMongoFcv 4.4
showMongoFcv
systemctl stop mongod
systemctl start mongod
|
Upgrade from MongoDB 4.4 to MongoDB 5.0
...
Check the database compatibility mode is set to "4.4"
The result should be as follows ensuring that the value 4.4 is set
{ "featureCompatibilityVersion" : "4.4" , "ok" : 1 }
|
If MongoDB is on version 4.4 and the featureCompatibilityVersion is not "4.4" then set this with the following command
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
showMongoFcv
{ "featureCompatibilityVersion" : "4.4" , "ok" : 1 }
|
Ubuntu - Install MongoDB 5.0 Repo and Upgrade
...
Commands summarised here:
systemctl stop mongod
curl -fsSL https://www.mongodb.org/static/pgp/server-5.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-5.0.gpg --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-5.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | \
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: /tmp/apt-dpkg-install-s9INqt/4-mongodb-org-database-tools-extra_5.0.27_amd64.deb
Fix it by using: sudo apt --fix-broken install sudo dpkg -i --force-overwrite /var/cache/apt/archives/mongodb-org-database-tools-extra_5.0.27_amd64.deb
sudo apt-get upgrade -y mongodb-org
and if you are prompted Which services should be restarted? tab down to Ok and press Enter. -------------------------------------
mongod --version
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.
setMongoFcv 5.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
showMongoFcv
{ "featureCompatibilityVersion" : "5.0" , "ok" : 1 }
|
Upgrade from MongoDB 5.0 to MongoDB 6.0
...
Check the database compatibility mode is set 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
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
showMongoFcv
{ "featureCompatibilityVersion" : "5.0" , "ok" : 1 }
|
Ubuntu - Install MongoDB 6.0 Repo and Upgrade
...
Commands summarised here:
systemctl stop mongod
curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | \
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 and if you are prompted Which services should be restarted? tab down to Ok and press Enter.
mongod --version
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.
Note that you must now use the mongosh command instead of mongo
setMongoFcv 6.0
showMongoFcv
systemctl stop mongod
systemctl start mongod
|
As before, check the featureCompatibilityVersion output from above is "6.0"
Example Command and Output
showMongoFcv
{ "featureCompatibilityVersion" : "6.0" , "ok" : 1 }
|
This completes the in-situ upgrade of MongoDB 4.2 to 6.0 Standalone
...
The following commands are used to complete this task
systemctl start nmis9d
/usr/local/omk/bin/checkomkdaemons .sh start
# confirm that the daemons have started /usr/local/omk/bin/checkomkdaemons.sh status ; systemctl status nmis9d
|
You can now browse to your FirstWave instance with:
...