Versions Compared

Key

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

...

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

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

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

Code Block
Release:CentOS Linux       20.04
Codename:       focalrelease 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 FriThu 2022-0709-0108 0017:3117:5932 UTCAEST; 1min 31s14s ago
 Main   Process: 8852 ExecStart=/usr/local/nmis9/bin/nmisdPID: 18086 (code=exited, status=0/SUCCESS)
   Main PID: 8856 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 9528)
     Memory: 26.4M
     CGroup: /systemCGroup: /system.slice/nmis9d.service

JulSep 0104 0003:3031:1410 fernyrhnmis9 systemd[1]: Starting Opmantek NMIS9 Daemon...
JulSep 0104 0003:3031:1513 fernyrhnmis9 systemd[1]: Started Opmantek NMIS9 Daemon.
JulSep 0108 0017:17:31:58 fernyrhnmis9 systemd[1]: Stopping Opmantek NMIS9 Daemon...
JulSep 0108 0017:3117:59 ferny systemd[1]: nmis9d.service: Succeeded.
Jul 01 00:31:59 ferny32 rhnmis9 systemd[1]: Stopped Opmantek NMIS9 Daemon.

...

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 }

...

Redhat/Centos - Install MongoDB 3.6 Repo and Upgrade

Details available here:

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

Commands summarised hereCreate a new repo file using the follow commands:

Code Block
wgetecho -qO - https://www.mongodb.org/static/pgp/server"[mongodb-org-3.6]" > /etc/yum.repos.d/mongodb-org-3.6.asc | sudo apt-key add -repo
echo "deb [ arch=amd64 ] name=MongoDB Repository" >> /etc/yum.repos.d/mongodb-org-3.6.repo
echo "baseurl=https://repo.mongodb.org/yum/aptredhat/ubuntu bionic$releasever/mongodb-org/3.6 multiverse/x86_64/" | sudo tee>> /etc/apt/sourcesyum.listrepos.d/mongodb-org-3.6.listrepo
sudo apt-get update
sudo apt-get upgrade -y
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.

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.repo

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
Code Block
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )'
mongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParametersetFeatureCompatibilityVersion: 1, featureCompatibilityVersion: 1"3.6" } )'
systemctl stopmongo -u <YOUR USERNAME> -p <YOUR PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
systemctl stop mongod
systemctl start mongod

...

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 }

...

Redhat/Centos - Install MongoDB 4.0 Repo and Upgrade

Details available here:

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

Commands summarised hereCreate a new repo file using the follow commands:

Code Block
wgetecho -qO - https://www.mongodb.org/static/pgp/server"[mongodb-org-4.0]" > /etc/yum.repos.d/mongodb-org-4.0.asc | sudo apt-key add -repo
echo "deb [ arch=amd64 ] name=MongoDB Repository" >> /etc/yum.repos.d/mongodb-org-4.0.repo
echo "baseurl=https://repo.mongodb.org/yum/aptredhat/ubuntu bionic$releasever/mongodb-org/4.0 multiverse/x86_64/" | sudo tee>> /etc/apt/sourcesyum.listrepos.d/mongodb-org-4.0.listrepo
sudo apt-get update
sudo apt-get upgrade -y
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.

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.repo

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
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

...

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:

 PASSWORD> --authenticationDatabase=admin --quiet --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'

{ "featureCompatibilityVersion" : "4.0", "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
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.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

...