CentOS Linux 7.9. Process for Upgrading MongoDB 4.2 Standalone to MongoDB 6.0 Standalone.
MongoDB upgrade requires that you must upgrade to each version of MongoDB along the way.
This document will follow the MongoDB upgrade path from 4.2 → 4.4 → 5.0 → 6.0, with the document structured as follows:
Prerequisites
Upgrade Preparation
Upgrade from MongoDB 4.2 to MongoDB 4.4
Upgrade from MongoDB 4.4 to MongoDB 5.0
Upgrade from MongoDB 5.0 to MongoDB 6.0
Services Restart
1.- Prerequisites.
his 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.
There are 4 prerequisites to confirm:
Operating System
MongoDB Version
MongoDB Storage Engine
NMIS and Modules for Mongo 6.0
Operating System.
We have tested the upgrade process from MongoDB 4.2 to MongoDB 6.0 on:
[root@centosmongo6 ~]# more /etc/redhat-release CentOS Linux release 7.9.2009 (Core)
MongoDB version.
[root@centosmongo6 ~]# mongod --version db version v4.2.25 git version: 41b59c2bfb5121e66f18cc3ef40055a1b5fb6c2e OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 allocator: tcmalloc modules: none build environment: distmod: rhel70 distarch: x86_64 target_arch: x86_64 [root@centosmongo6 ~]#
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'quit()' | grep MongoDB MongoDB shell version v4.2.25 MongoDB server version: 4.2.25
MongoDB storage engine.
The "name" line should have "wiredTiger" in order to proceed.
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --quiet --eval 'db.serverStatus().storageEngine' { "name" : "wiredTiger", "supportsCommittedReads" : true, "oldestRequiredTimestampForCrashRecovery" : Timestamp(0, 0), "supportsPendingDrops" : true, "dropPendingIdents" : NumberLong(0), "supportsSnapshotReadConcern" : true, "readOnly" : false, "persistent" : true, "backupCursorOpen" : false }
NMIS and Modules for Mongo 6.
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.
Minimum releases that support MongoDB 6.0 are:
NMIS 9.5.0
opAddress 2.4.0
opCharts 4.8.0
opConfig 4.6.0
opEvents 4.4.0
opHA 4.1.0
opReports 4.6.0
opFlow 4.1.0
You can determine the versions you are running by browsing to:
https://<yourserveraddress>/omk/
You should follow the standard upgrade process for each of these packages, which is handled by the FirstWave Installer.
2.- Upgrade Preparation.
The preparation phase includes 3 sections
System Snapshot/Backup
Upgrade Linux to latest stable release packages
Shutdown all OMK Daemons
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.
If the information on your system, or stability of the system is critical to your business it is important to retain a working backup. It is important that you have confirmed that your backups can be restored.
Options:
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 Centos instructions for upgrading and checking the sanity of the system.
An example of the update/upgrade cycle is as follows:
# yum update
Shutdown All FirstWave Daemons
Prior to commencing into the MongoDB upgrade cycles it is required to shutdown all FirstWave processes. The following commands are used to complete this task
[root@centosmongo6 ~]# /usr/local/omk/bin/checkomkdaemons.sh stop job complete! [root@centosmongo6 ~]# systemctl stop nmis9d
Confirm that the daemons have stopped.
[root@centosmongo6 ~]# /usr/local/omk/bin/checkomkdaemons.sh status [root@centosmongo6 ~]# systemctl status nmis9d
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.
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })' MongoDB shell version v4.2.25 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("b91ff10a-0029-44bc-8daf-fe469ed4a68b") } MongoDB server version: 4.2.25 { "featureCompatibilityVersion" : { "version" : "4.2" }, "ok" : 1 }
Deleted the old mongoDB repo.
rm -f /etc/yum.repos.d/mongodb-org-4.2.repo
Create a new repo file.
[root@centosmongo6 ~]# vi /etc/yum.repos.d/mongodb-org-4.4.repo
Please insert this:
[mongodb-org-4.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Install mongoDB
[root@centosmongo6 ~]# yum install -y mongodb-org
Example output:
... ... ... Dependency Installed: mongodb-database-tools.x86_64 0:100.10.0-1 mongodb-org-database-tools-extra.x86_64 0:4.4.29-1.el7 Updated: mongodb-org.x86_64 0:4.4.29-1.el7 Dependency Updated: mongodb-org-mongos.x86_64 0:4.4.29-1.el7 mongodb-org-server.x86_64 0:4.4.29-1.el7 mongodb-org-shell.x86_64 0:4.4.29-1.el7 mongodb-org-tools.x86_64 0:4.4.29-1.el7 Complete!
Restart mongoDB daemon.
[root@centosmongo6 ~]# systemctl restart mongod
Example output:
[root@centosmongo6 ~]# systemctl restart mongod You have new mail in /var/spool/mail/root [root@centosmongo6 ~]# systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-09-30 17:27:41 CDT; 7s ago Docs: https://docs.mongodb.org/manual Main PID: 29866 (mongod) Tasks: 31 CGroup: /system.slice/mongod.service └─29866 /usr/bin/mongod -f /etc/mongod.conf Sep 30 17:27:41 centosmongo6 systemd[1]: Started MongoDB Database Server. Sep 30 17:27:41 centosmongo6 mongod[29866]: {"t":{"$date":"2024-09-30T22:27:41.571Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"main","msg":"Environme...to false"} Hint: Some lines were ellipsized, use -l to show in full. [root@centosmongo6 ~]#
Check the mongoDB version
[root@centosmongo6 ~]# mongod --version db version v4.4.29 Build Info: { "version": "4.4.29", "gitVersion": "f4dda329a99811c707eb06d05ad023599f9be263", "openSSLVersion": "OpenSSL 1.0.1e-fips 11 Feb 2013", "modules": [], "allocator": "tcmalloc", "environment": { "distmod": "rhel70", "distarch": "x86_64", "target_arch": "x86_64" } } [root@centosmongo6 ~]#
Change and Check the mongoDB compatibility mode.
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })' MongoDB shell version v4.4.29 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("4b95aa66-2b64-4a43-b6a7-daa989303848") } MongoDB server version: 4.4.29 { "featureCompatibilityVersion" : { "version" : "4.2" }, "ok" : 1 }
To change the mongoDB compatibility mode, please use this command. It must be 4.4
# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.4" })'
Example output:
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.4" })' MongoDB shell version v4.4.29 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("dda35d6d-dbbc-4ef2-aa2c-cc9e38413ca6") } MongoDB server version: 4.4.29 { "ok" : 1 }
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.
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })' MongoDB shell version v4.4.29 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("8de8fcf3-bfd7-49b8-a886-68d69c742e58") } MongoDB server version: 4.4.29 { "featureCompatibilityVersion" : { "version" : "4.4" }, "ok" : 1 }
Deleted the old mongoDB repo.
[root@centosmongo6 ~]# rm -f /etc/yum.repos.d/mongodb-org-4.4.rep
Create a new repo file.
[root@centosmongo6 ~]# vi /etc/yum.repos.d/mongodb-org-5.0.repo
Please insert this:
[mongodb-org-5.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
Install mongoDB
[root@centosmongo6 ~]# yum install -y mongodb-org
Example output:
... ... ... Installing : mongodb-org-database-tools-extra-5.0.29-1.el7.x86_64 1/7 Installing : mongodb-org-tools-5.0.29-1.el7.x86_64 2/7 Installing : mongodb-org-shell-5.0.29-1.el7.x86_64 3/7 Installing : mongodb-org-server-5.0.29-1.el7.x86_64 4/7 Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service. Installing : mongodb-org-mongos-5.0.29-1.el7.x86_64 5/7 Installing : mongodb-org-database-5.0.29-1.el7.x86_64 6/7 Installing : mongodb-org-5.0.29-1.el7.x86_64 7/7 Verifying : mongodb-org-mongos-5.0.29-1.el7.x86_64 1/7 Verifying : mongodb-org-tools-5.0.29-1.el7.x86_64 2/7 Verifying : mongodb-org-server-5.0.29-1.el7.x86_64 3/7 Verifying : mongodb-org-shell-5.0.29-1.el7.x86_64 4/7 Verifying : mongodb-org-database-tools-extra-5.0.29-1.el7.x86_64 5/7 Verifying : mongodb-org-5.0.29-1.el7.x86_64 6/7 Verifying : mongodb-org-database-5.0.29-1.el7.x86_64 7/7 Installed: mongodb-org.x86_64 0:5.0.29-1.el7 Dependency Installed: mongodb-org-database.x86_64 0:5.0.29-1.el7 mongodb-org-database-tools-extra.x86_64 0:5.0.29-1.el7 mongodb-org-mongos.x86_64 0:5.0.29-1.el7 mongodb-org-server.x86_64 0:5.0.29-1.el7 mongodb-org-shell.x86_64 0:5.0.29-1.el7 mongodb-org-tools.x86_64 0:5.0.29-1.el7
Restart mongoDB daemon.
[root@centosmongo6 ~]# systemctl restart mongod
Example output:
[root@centosmongo6 ~]# systemctl restart mongod You have new mail in /var/spool/mail/root [root@centosmongo6 ~]# systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-09-30 17:58:10 CDT; 5s ago Docs: https://docs.mongodb.org/manual Main PID: 32364 (mongod) Tasks: 43 CGroup: /system.slice/mongod.service └─32364 /usr/bin/mongod -f /etc/mongod.conf Sep 30 17:58:10 centosmongo6 systemd[1]: Started MongoDB Database Server. Sep 30 17:58:10 centosmongo6 mongod[32364]: {"t":{"$date":"2024-09-30T22:58:10.197Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"-","msg":"Environment ...to false"} Hint: Some lines were ellipsized, use -l to show in full. [root@centosmongo6 ~]#
Check the mongoDB version
[root@centosmongo6 ~]# mongod --version db version v5.0.29 Build Info: { "version": "5.0.29", "gitVersion": "cd239f3b0c7796df9e576ae5a9efcf4e6960560c", "openSSLVersion": "OpenSSL 1.0.1e-fips 11 Feb 2013", "modules": [], "allocator": "tcmalloc", "environment": { "distmod": "rhel70", "distarch": "x86_64", "target_arch": "x86_64" } } [root@centosmongo6 ~]#
Change and Check the mongoDB compatibility mode.
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })' MongoDB shell version v5.0.29 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("8e28fb2e-b0e0-406c-8848-bbbdd5be6595") } MongoDB server version: 5.0.29 { "featureCompatibilityVersion" : { "version" : "4.4" }, "ok" : 1 }
To change the mongoDB compatibility mode, please use this command. It must be 5.0
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "5.0" })'
Example output:
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "5.0" })' MongoDB shell version v5.0.29 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("38eec720-4453-4ee6-b9ab-30de3a13e47e") } MongoDB server version: 5.0.29 { "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.
[root@centosmongo6 ~]# mongo -u opUserRW -p op42flow42 --authenticationDatabase=admin --eval 'db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })' MongoDB shell version v5.0.29 connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("a3340e2f-a89b-43bf-a5ee-69c3c3ff3b66") } MongoDB server version: 5.0.29 { "featureCompatibilityVersion" : { "version" : "5.0" }, "ok" : 1 }
Deleted the old mongoDB repo.
[root@centosmongo6 ~]# rm -f /etc/yum.repos.d/mongodb-org-5.0.repo
Create a new repo file.
[root@centosmongo6 ~]# vi /etc/yum.repos.d/mongodb-org-6.0.repo
Please insert this:
[mongodb-org-6.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
Install mongoDB
[root@centosmongo6 ~]# yum install -y mongodb-org
Example output:
... ... ... Running transaction Installing : mongodb-org-database-tools-extra-6.0.18-1.el7.x86_64 1/6 Installing : mongodb-org-tools-6.0.18-1.el7.x86_64 2/6 Installing : mongodb-org-server-6.0.18-1.el7.x86_64 3/6 Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service. Installing : mongodb-org-mongos-6.0.18-1.el7.x86_64 4/6 Installing : mongodb-org-database-6.0.18-1.el7.x86_64 5/6 Installing : mongodb-org-6.0.18-1.el7.x86_64 6/6 Verifying : mongodb-org-database-6.0.18-1.el7.x86_64 1/6 Verifying : mongodb-org-6.0.18-1.el7.x86_64 2/6 Verifying : mongodb-org-mongos-6.0.18-1.el7.x86_64 3/6 Verifying : mongodb-org-server-6.0.18-1.el7.x86_64 4/6 Verifying : mongodb-org-tools-6.0.18-1.el7.x86_64 5/6 Verifying : mongodb-org-database-tools-extra-6.0.18-1.el7.x86_64 6/6 Installed: mongodb-org.x86_64 0:6.0.18-1.el7 Dependency Installed: mongodb-org-database.x86_64 0:6.0.18-1.el7 mongodb-org-database-tools-extra.x86_64 0:6.0.18-1.el7 mongodb-org-mongos.x86_64 0:6.0.18-1.el7 mongodb-org-server.x86_64 0:6.0.18-1.el7 mongodb-org-tools.x86_64 0:6.0.18-1.el7 Complete!
Restart mongoDB daemon.
[root@centosmongo6 ~]# systemctl restart mongod
Example Output:
[root@centosmongo6 ~]# systemctl restart mongod [root@centosmongo6 ~]# systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-09-30 18:23:47 CDT; 5s ago Docs: https://docs.mongodb.org/manual Main PID: 34460 (mongod) Tasks: 31 CGroup: /system.slice/mongod.service └─34460 /usr/bin/mongod -f /etc/mongod.conf Sep 30 18:23:47 centosmongo6 systemd[1]: Started MongoDB Database Server. Sep 30 18:23:47 centosmongo6 mongod[34460]: {"t":{"$date":"2024-09-30T23:23:47.287Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"-","msg":"Environment ...to false"} Hint: Some lines were ellipsized, use -l to show in full.
Check the mongoDB version
[root@centosmongo6 ~]# mongod --version db version v6.0.18 Build Info: { "version": "6.0.18", "gitVersion": "2a2b949da51fa5d7402ffe31280067baf21bbbdd", "openSSLVersion": "OpenSSL 1.0.1e-fips 11 Feb 2013", "modules": [], "allocator": "tcmalloc", "environment": { "distmod": "rhel70", "distarch": "x86_64", "target_arch": "x86_64" } }
Change and Check the mongoDB compatibility mode.
# mongosh -u opUserRW -p op42flow42 --authenticationDatabase admin > db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 });
Example Output:
Deprecation warnings: - Using mongosh on the current operating system is deprecated, and support may be removed in a future release. See https://www.mongodb.com/docs/mongodb-shell/install/#supported-operating-systems for documentation on supported platforms. test> db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 }); { featureCompatibilityVersion: { version: '5.0' }, ok: 1 } test>
To change the mongoDB compatibility mode, please use this command. It must be 6.0
> db.adminCommand({ setFeatureCompatibilityVersion: "6.0" });
Example Output:
test> db.adminCommand({ setFeatureCompatibilityVersion: "6.0" }); { ok: 1 } test> db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 }); { featureCompatibilityVersion: { version: '6.0' }, ok: 1 } test>
Restart the mongoDB daemon.
[root@centosmongo6 ~]# systemctl restart mongod [root@centosmongo6 ~]# systemctl status mongod ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-09-30 18:43:08 CDT; 5s ago Docs: https://docs.mongodb.org/manual Main PID: 35835 (mongod) Tasks: 43 CGroup: /system.slice/mongod.service └─35835 /usr/bin/mongod -f /etc/mongod.conf Sep 30 18:43:08 centosmongo6 systemd[1]: Stopped MongoDB Database Server. Sep 30 18:43:08 centosmongo6 systemd[1]: Started MongoDB Database Server. Sep 30 18:43:08 centosmongo6 mongod[35835]: {"t":{"$date":"2024-09-30T23:43:08.420Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"-","msg":"Environment ...to false"} Hint: Some lines were ellipsized, use -l to show in full.
Services Restart
Now the MongoDB upgrade is complete, you can start all the NMIS and FirstWave daemons.
The following commands are used to complete this task
[root@centosmongo6 ~]# systemctl start nmis9d [root@centosmongo6 ~]# /usr/local/omk/bin/checkomkdaemons.sh start
You can now browse to your FirstWave instance with:
https://<yourserver>/omk
You will get a screen similar to the following which will give you a status on all installed modules: