NOTE: All Linux commands in this document are run at root level: you need access to root via su
or sudo -i
...
Upgrade from MongoDB 4.2 to MongoDB 4.4
Prepare the Database for Upgrade
Check the database compatibility mode Set these two environment variables with your MongoDB admin username and password so that these script examples can be used:
export YOUR_USERNAME=opUserRW
export YOUR_PASSWORD=t0pS3cr3tpw
Another useful alias to show fcv is
alias showfcv='mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval "db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )"'
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 } )'
|
...
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
...
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
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
|
...
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.4 is set
...
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
...
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( { setFeatureCompatibilityVersion: "5.0" } )'
mongo -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
systemctl stop mongod ; systemctl start mongod
; systemctl start status mongod
|
As before, check the featureCompatibilityVersion output from above is "5.0"
Example Command and Output
...
As before, the check the featureCompatibilityVersion again confirming the correct value
Example Command and Output
...
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
|
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
mongosh mongosh -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )'
mongosh mongosh -u $YOUR_USERNAME -p $YOUR_PASSWORD --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
systemctl stop mongod
systemctl start mongod
|
As before, check the featureCompatibilityVersion output from above is "6.0"
Example Command and Output
...
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 instance of NMIS:
...