Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Following the release notes for MongoDB you must upgrade to each version of MongoDB along the way.

...

MongoDB 3.4 through 4.2 are officially supported on the following Ubuntu Redhat/Centos platforms:

  • 18.04 LTS (“Bionic”)
  • 16.04 LTS (“Xenial”)6.2+ x64
  • 7.0 x64
  • 8.0 x64

We have tested the upgrade process on:

  • Ubuntu 20.04 LTS ("focal"CentOS Linux release 7.9.2009 (Core)

To determine the version of Linux running on your system use the following command in a terminal session:

Code Block
lsb_release -rccat /etc/redhat-release

An example output of this command

Release: 20.04 Codename: focal
Code Block
CentOS Linux release 7.9.2009 (Core)


MongoDB 3.4 Installed and Running

...

Code Block
grep -i "active storage" /var/log/mongodb/mongod.log*

Example correct log output - notice the log entry declares the storage engine to be using "wiredTiger"

Code Block
/var/log/mongodb/mongod.log.1:2022-0607-28T0709T01:5327:3324.568052+00001000 I -      STORAGE  [initandlisten] Detected data files in /var/lib/mongodbmongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.

...

  • 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 Redhat/Centos Packages

After completing the snapshot/backup follow Ubuntu's Redhat/Centos instructions for upgrading and checking the sanity of the apt package system.

Here is a link to an Ubuntu apt-get howto for further referenceCommunity documentation for CentOS/Redhat YUM: https://helpwww.ubuntutecmint.com/community/AptGet/Howtocheck-and-install-updates-on-centos-and-rhel/

An example of the update/upgrade cycle is as follows:

Code Block
apt-getyum update && apt-get upgrade -y

This command will execute all outstanding upgrades. Check for any errors and address as required.

...

Code Block
titleExample Command and Output
user@servername:~/installers#[root@rhnmis9 ~]# systemctl status nmis9d
● nmis9d.service - Opmantek NMIS9 Daemon
     Loaded: loaded (/etc/systemd/system/nmis9d.service; enabled; vendor preset: enableddisabled)
 
   Active: inactive (dead) since Fri 2022-07-01 00:31:59 UTC; 1min 31s ago
    Process: 8852 ExecStart=/usr/local/nmis9/bin/nmisd (code=exited, status=0/SUCCESS)
    inactive (dead) since Thu 2022-09-08 17:17:32 AEST; 14s ago
 Main PID: 885618086 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nmis9d.service

Sep 04 Tasks03:31:10 0 (limitrhnmis9 systemd[1]: 9528)Starting Opmantek NMIS9 Daemon...
Sep 04 Memory03:31:13 26.4M
     CGroup: /system.slice/nmis9d.service

Jul 01 00:30:14 fernyrhnmis9 systemd[1]: Started Opmantek NMIS9 Daemon.
Sep 08 17:17:31 rhnmis9 systemd[1]: StartingStopping Opmantek NMIS9 Daemon...
JulSep 0108 0017:3017:1532 fernyrhnmis9 systemd[1]: StartedStopped Opmantek NMIS9 Daemon.
Jul 01 00:31:58 ferny systemd[1]: Stopping Opmantek NMIS9 Daemon...
Jul 01 00:31:59 ferny systemd[1]: nmis9d.service: Succeeded.
Jul 01 00:31:59 ferny systemd[1]: Stopped Opmantek NMIS9 Daemon.

Upgrade from MongoDB 3.4 to MongoDB 3.6

Prepare the Database for Upgrade

...


Upgrade from MongoDB 3.4 to MongoDB 3.6

Prepare the Database for Upgrade

Check the database compatibility mode is set to "3.4"

Code Block
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 3.4 is set

Code Block
{ "featureCompatibilityVersion" : "3.4", "ok" : 1 }

If MongoDB is on version 3.4 and the featureCompatibilityVersion is not "3.4" then set this with the following command

Code Block
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 3.4 is set

Code Block
{ "featureCompatibilityVersion" : setFeatureCompatibilityVersion: "3.4", "ok" : 1 }

If MongoDB is on version 3.4 and the featureCompatibilityVersion is not "3.4" then set this with the following command

code
} )';

As before, the check the featureCompatibilityVersion again confirming the correct value

Code Block
titleExample Command and Output
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "3.4" getParameter: 1, featureCompatibilityVersion: 1 } )';

As before, the check the featureCompatibilityVersion again confirming the correct value

Code Block
titleExample Command and Output
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'

{ "featureCompatibilityVersion" : "3.4", "ok" : 1 }

Ubuntu - Install MongoDB 3.6 Repo and Upgrade

Details available here:

https://www.mongodb.com/docs/v3.6/tutorial/install-mongodb-on-ubuntu/

Commands summarised here:

Code Block
wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list

{ "featureCompatibilityVersion" : "3.4", "ok" : 1 }

Redhat/Centos - Install MongoDB 3.6 Repo and Upgrade

Details available here:

https://www.mongodb.com/docs/v3.6/tutorial/install-mongodb-on-red-hat/

Create a new repo file using the follow commands:

Code Block
echo "[mongodb-org-3.6]" > /etc/yum.repos.d/mongodb-org-3.6.repo
echo "name=MongoDB Repository" >> /etc/yum.repos.d/mongodb-org-3.6.repo
echo "baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/" >> /etc/yum.repos.d/mongodb-org-3.6.repo
echo "gpgcheck=1" >> /etc/yum.repos.d/mongodb-org-3.6.repo
echo "enabled=1" >> /etc/yum.repos.d/mongodb-org-3.6.repo
echo "gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc" >> /etc/yum.repos.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get upgraderepo

Upgrading the installation is as follows:

Code Block
sudo yum update -y mongodb-org
systemctl stop mongod
systemctl start mongod
systemctl daemon-reload
systemctl is-active mongod

...

If MongoDB is on version 3.6 and the featureCompatibilityVersion is not the featureCompatibilityVersion is not "3.6" then set this with the following command

Code Block
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "3.6"

...

Code Block
 } )';

As before, the check the featureCompatibilityVersion again confirming the correct value

Code Block
titleExample Command and Output
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "3.6" getParameter: 1, featureCompatibilityVersion: 1 } )';

As before, the check the featureCompatibilityVersion again confirming the correct value

Code Block
titleExample Command and Output
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'

{ "featureCompatibilityVersion" : "3.6", "ok" : 1 }

Ubuntu - Install MongoDB 4.0 Repo and Upgrade

Details available here:

https://www.mongodb.com/docs/v4.0/tutorial/install-mongodb-on-ubuntu/

Commands summarised here:

Code Block
wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list

{ "featureCompatibilityVersion" : "3.6", "ok" : 1 }

Redhat/Centos - Install MongoDB 4.0 Repo and Upgrade

Details available here:

https://www.mongodb.com/docs/v4.0/tutorial/install-mongodb-on-red-hat/

Create a new repo file using the follow commands:

Code Block
echo "[mongodb-org-4.0]" > /etc/yum.repos.d/mongodb-org-4.0.repo
echo "name=MongoDB Repository" >> /etc/yum.repos.d/mongodb-org-4.0.repo
echo "baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/" >> /etc/yum.repos.d/mongodb-org-4.0.repo
echo "gpgcheck=1" >> /etc/yum.repos.d/mongodb-org-4.0.repo
echo "enabled=1" >> /etc/yum.repos.d/mongodb-org-4.0.repo
echo "gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc" >> /etc/yum.repos.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get upgraderepo

Upgrading the installation is as follows:

Code Block
sudo yum update -y mongodb-org
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.

Code Block
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } )'
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
systemctl stop mongod
systemctl start mongod

...

If MongoDB is on version 4.0 and the featureCompatibilityVersion is not not "4.0" then set this with the following command

Code Block
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "4.0"

...

code
 } )';

As before, the check the featureCompatibilityVersion again confirming the correct value

Code Block
titleExample Command and Output
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersiongetParameter: 1, featureCompatibilityVersion: 1 } )'

{ "featureCompatibilityVersion" : "4.0" } )';

...

,

...

Code Block
titleExample Command and Output
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'

{ "featureCompatibilityVersion" : "4.0", "ok" : 1 }

Ubuntu - Install MongoDB 4.2 Repo and Upgrade

Details available here:

https://www.mongodb.com/docs/v4.2/tutorial/install-mongodb-on-ubuntu/

Commands summarised here:

Code Block
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list "ok" : 1 }

Redhat/Centos - Install MongoDB 4.2 Repo and Upgrade

Details available here:

https://www.mongodb.com/docs/v4.2/tutorial/install-mongodb-on-red-hat/

Create a new repo file using the follow commands:

Code Block
echo "[mongodb-org-4.2]" > /etc/yum.repos.d/mongodb-org-4.2.repo
echo "name=MongoDB Repository" >> /etc/yum.repos.d/mongodb-org-4.2.repo
echo "baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/" >> /etc/yum.repos.d/mongodb-org-4.2.repo
echo "gpgcheck=1" >> /etc/yum.repos.d/mongodb-org-4.2.repo
echo "enabled=1" >> /etc/yum.repos.d/mongodb-org-4.2.repo
echo "gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc" >> /etc/yum.repos.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get upgrade -yrepo

Upgrading the installation is as follows:

Code Block
sudo yum update -y mongodb-org
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.

Code Block
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } )'
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
systemctl stop mongod
systemctl start mongod

...