=====Overview===== Upgrading in mongo is performed depending on the starting point. If you are like me and started with old release like 2.6, then you are screwed because you will have to pass through a lot of upgrades to reach the current one (4.3). So let's get going: =====Upgrade from 2.6 to 4.2===== In order to upgrade from 2.6 to 4.2 we have to do the following: - Upgrade binaries: 2.6 -> 3.0 -> 3.2 -> 3.4 -> 3.6 -> 4.0 -> 4.2 - Upgrade database features in versions: 3.4, 3.6, 4.0, 4.2 - Upgrade the authentication schema in: 3.6 - Upgrade the Storage engine in: 4.0 So let's get going: ====Upgrade to 3.0==== The upgrades until 3.4 are so called "drop-in" upgrades. Meaning exactly that: - Stop the server - Modify the yum configuration file - Upgrade the libraries - Start the server - Check the version ===Stop the server=== As I mentioned, stopping of the server can be done gracefully or killfully. Let's do it killfully (not recommended though) [root@localhost yum.repos.d]# ps -ef | grep mongo root 5275 1 0 07:20 ? 00:00:02 /bin/mongod -f /etc/mongod.conf --fork root 6258 4382 0 07:35 pts/0 00:00:00 grep --color=auto mongo [root@localhost yum.repos.d]# kill -9 5275 [root@localhost yum.repos.d]# ps -ef | grep mongo root 6267 4382 0 07:35 pts/0 00:00:00 grep --color=auto mongo ===Modify yum config file=== In order to upgrade the libraries, we have to add new entry in the /etc/yum.repod.d/mongodb.conf for the new repository: ******************************* [mongodb-org-3.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.0.asc Once it is added, we can upgrade to the new version: ===Upgrade the libraries=== [root@localhost yum.repos.d]# yum search mongo Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.vectranet.pl * extras: ftp.agh.edu.pl * updates: ftp.man.poznan.pl mongodb-org-2.6 | 2.5 kB 00:00:00 mongodb-org-3.0 | 2.5 kB 00:00:00 mongodb-org-3.0/primary_db | 94 kB 00:00:00 ============================================================================================================ N/S matched: mongo ============================================================================================================= google-noto-sans-mongolian-fonts.noarch : Sans Mongolian font mongodb-org.x86_64 : MongoDB open source document-oriented database system (metapackage) mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router mongodb-org-server.x86_64 : MongoDB database server mongodb-org-shell.x86_64 : MongoDB shell client mongodb-org-tools.x86_64 : MongoDB tools autocorr-mn.noarch : Mongolian auto-correction rules hunspell-mn.noarch : Mongolian hunspell dictionaries hyphen-mn.noarch : Mongolian hyphenation rules Name and summary matches only, use "search all" for everything. [root@localhost yum.repos.d]# yum install mongodb-org-server.x86_64 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.vectranet.pl * extras: ftp.agh.edu.pl * updates: ftp.man.poznan.pl Resolving Dependencies --> Running transaction check ---> Package mongodb-org-server.x86_64 0:2.6.15-1.el7 will be updated ---> Package mongodb-org-server.x86_64 0:3.0.22-1.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================================================================= Updating: mongodb-org-server x86_64 3.0.22-1.el7 mongodb-org-3.0 13 M Transaction Summary ============================================================================================================================================================================================================================================= Upgrade 1 Package Total download size: 13 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. warning: /var/cache/yum/x86_64/7/mongodb-org-3.0/packages/mongodb-org-server-3.0.22-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEY============================= ] 8.4 MB/s | 9.9 MB 00:00:00 ETA Public key for mongodb-org-server-3.0.22-1.el7.x86_64.rpm is not installed mongodb-org-server-3.0.22-1.el7.x86_64.rpm | 13 MB 00:00:01 Retrieving key from https://www.mongodb.org/static/pgp/server-3.0.asc Importing GPG key 0xEA312927: Userid : "MongoDB 3.0 Release Signing Key " Fingerprint: 42f3 e95a 2c4f 0827 9c49 60ad d68f a50f ea31 2927 From : https://www.mongodb.org/static/pgp/server-3.0.asc Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : mongodb-org-server-3.0.22-1.el7.x86_64 1/2 Cleanup : mongodb-org-server-2.6.15-1.el7.x86_64 2/2 Verifying : mongodb-org-server-3.0.22-1.el7.x86_64 1/2 Verifying : mongodb-org-server-2.6.15-1.el7.x86_64 2/2 Updated: mongodb-org-server.x86_64 0:3.0.22-1.el7 Complete! And voila, the mongo was upgraded from 2.6 -> 3.0. Now, let's verify if all was fine with the upgrade: ===Start the server=== [root@localhost yum.repos.d]# /bin/mongod -f /etc/mongod.conf --fork about to fork child process, waiting until server is ready for connections. forked process: 5275 child process started successfully, parent exiting [root@localhost yum.repos.d]# ===Check the version=== [root@localhost yum.repos.d]# mongo 192.168.0.172:27017 MongoDB shell version: 3.0.15 connecting to: 192.168.0.172:27017/test Server has startup warnings: 2019-09-10T07:20:25.663-0400 I STORAGE [initandlisten] 2019-09-10T07:20:25.663-0400 I STORAGE [initandlisten] ** WARNING: Readahead for /var/lib/mongo is set to 4096KB 2019-09-10T07:20:25.663-0400 I STORAGE [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less 2019-09-10T07:20:25.663-0400 I STORAGE [initandlisten] ** http://dochub.mongodb.org/core/readahead 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T07:20:25.958-0400 I CONTROL [initandlisten] rs0:PRIMARY> show dbs ExampleDB 0.078GB admin 0.078GB local 2.077GB test 0.078GB rs0:PRIMARY> db.version() 3.0.22 <- Very happy So let's continue then. ====Upgrade to 3.2==== One again: ===Stop the server=== P.S. THIS ISN'T RECOMMENDED WAY TO STOP IT, please addess "Stopping/Starting" section in the chapter for better way. I do it like that to save time, since I will need to change the IP and use localhost and bla bla bla... [root@localhost yum.repos.d]# ps -ef | grep mongo root 5275 1 0 07:20 ? 00:00:02 /bin/mongod -f /etc/mongod.conf --fork root 6258 4382 0 07:35 pts/0 00:00:00 grep --color=auto mongo [root@localhost yum.repos.d]# kill -9 5275 [root@localhost yum.repos.d]# ps -ef | grep mongo root 6267 4382 0 07:35 pts/0 00:00:00 grep --color=auto mongo ===Modify the yum config file=== ************************************ [mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.2/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc ===Upgrade the libraries=== [root@localhost yum.repos.d]# yum search mongo Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.vectranet.pl * extras: ftp.agh.edu.pl * updates: ftp.man.poznan.pl mongodb-org-3.0 | 2.5 kB 00:00:00 mongodb-org-3.2 | 2.5 kB 00:00:00 mongodb-org-3.2/primary_db | 94 kB 00:00:00 ============================================================================================================ N/S matched: mongo ============================================================================================================= google-noto-sans-mongolian-fonts.noarch : Sans Mongolian font mongodb-org.x86_64 : MongoDB open source document-oriented database system (metapackage) mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router mongodb-org-server.x86_64 : MongoDB database server mongodb-org-shell.x86_64 : MongoDB shell client mongodb-org-tools.x86_64 : MongoDB tools autocorr-mn.noarch : Mongolian auto-correction rules hunspell-mn.noarch : Mongolian hunspell dictionaries hyphen-mn.noarch : Mongolian hyphenation rules Name and summary matches only, use "search all" for everything. [root@localhost yum.repos.d]# yum install mongodb-org-server.x86_64 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.vectranet.pl * extras: ftp.agh.edu.pl * updates: ftp.man.poznan.pl Resolving Dependencies --> Running transaction check ---> Package mongodb-org-server.x86_64 0:3.0.15-1.el7 will be updated ---> Package mongodb-org-server.x86_64 0:3.2.22-1.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================================================================= Updating: mongodb-org-server x86_64 3.2.22-1.el7 mongodb-org-3.2 13 M Transaction Summary ============================================================================================================================================================================================================================================= Upgrade 1 Package Total download size: 13 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. warning: /var/cache/yum/x86_64/7/mongodb-org-3.2/packages/mongodb-org-server-3.2.22-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEY============================= ] 8.4 MB/s | 9.9 MB 00:00:00 ETA Public key for mongodb-org-server-3.2.22-1.el7.x86_64.rpm is not installed mongodb-org-server-3.2.22-1.el7.x86_64.rpm | 13 MB 00:00:01 Retrieving key from https://www.mongodb.org/static/pgp/server-3.2.asc Importing GPG key 0xEA312927: Userid : "MongoDB 3.2 Release Signing Key " Fingerprint: 42f3 e95a 2c4f 0827 9c49 60ad d68f a50f ea31 2927 From : https://www.mongodb.org/static/pgp/server-3.2.asc Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : mongodb-org-server-3.2.22-1.el7.x86_64 1/2 Cleanup : mongodb-org-server-3.0.15-1.el7.x86_64 2/2 Verifying : mongodb-org-server-3.2.22-1.el7.x86_64 1/2 Verifying : mongodb-org-server-3.0.15-1.el7.x86_64 2/2 Updated: mongodb-org-server.x86_64 0:3.2.22-1.el7 Complete! ===Start the server=== [root@localhost yum.repos.d]# /bin/mongod -f /etc/mongod.conf --fork about to fork child process, waiting until server is ready for connections. forked process: 6371 child process started successfully, parent exiting ===Check the version=== [root@localhost yum.repos.d]# mongo 192.168.0.172:27017 MongoDB shell version: 3.0.15 connecting to: 192.168.0.172:27017/test Server has startup warnings: 2019-09-10T07:37:19.381-0400 I STORAGE [initandlisten] 2019-09-10T07:37:19.381-0400 I STORAGE [initandlisten] ** WARNING: Readahead for /var/lib/mongo is set to 4096KB 2019-09-10T07:37:19.381-0400 I STORAGE [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less 2019-09-10T07:37:19.381-0400 I STORAGE [initandlisten] ** http://dochub.mongodb.org/core/readahead 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T07:37:19.548-0400 I CONTROL [initandlisten] rs0:PRIMARY> db.version() 3.2.22 rs0:PRIMARY> ====Upgrade to 3.4==== And again :) ===Shutdown server=== [root@localhost yum.repos.d]# ps -ef | grep mongo root 6371 1 0 07:37 ? 00:00:00 /bin/mongod -f /etc/mongod.conf --fork root 6559 4382 0 07:39 pts/0 00:00:00 grep --color=auto mongo [root@localhost yum.repos.d]# kill -9 6371 [root@localhost yum.repos.d]# ps -ef | grep mongo root 6567 4382 0 07:39 pts/0 00:00:00 grep --color=auto mongo ===Modify the yum config file=== ************************************************************************** [mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc ===Upgrade the libraries=== [root@localhost yum.repos.d]# yum search mongo Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.upjs.sk * extras: ftp.upjs.sk * updates: ftp.upjs.sk mongodb-org-3.0 | 2.5 kB 00:00:00 mongodb-org-3.2 | 2.5 kB 00:00:00 mongodb-org-3.4 | 2.5 kB 00:00:00 mongodb-org-3.4/primary_db | 92 kB 00:00:00 ============================================================================================================ N/S matched: mongo ============================================================================================================= google-noto-sans-mongolian-fonts.noarch : Sans Mongolian font mongodb-org.x86_64 : MongoDB open source document-oriented database system (metapackage) mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router mongodb-org-server.x86_64 : MongoDB database server mongodb-org-shell.x86_64 : MongoDB shell client mongodb-org-tools.x86_64 : MongoDB tools autocorr-mn.noarch : Mongolian auto-correction rules hunspell-mn.noarch : Mongolian hunspell dictionaries hyphen-mn.noarch : Mongolian hyphenation rules Name and summary matches only, use "search all" for everything. [root@localhost yum.repos.d]# yum install mongodb-org-server.x86_64 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.vectranet.pl * extras: ftp.agh.edu.pl * updates: ftp.man.poznan.pl Resolving Dependencies --> Running transaction check ---> Package mongodb-org-server.x86_64 0:3.2.22-1.el7 will be updated ---> Package mongodb-org-server.x86_64 0:3.4.22-1.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================================================================= Updating: mongodb-org-server x86_64 3.4.22-1.el7 mongodb-org-3.4 20 M Transaction Summary ============================================================================================================================================================================================================================================= Upgrade 1 Package Total download size: 20 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. warning: /var/cache/yum/x86_64/7/mongodb-org-3.4/packages/mongodb-org-server-3.4.22-1.el7.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID a15703c6: NOKEY=========================== ] 9.2 MB/s | 15 MB 00:00:00 ETA Public key for mongodb-org-server-3.4.22-1.el7.x86_64.rpm is not installed mongodb-org-server-3.4.22-1.el7.x86_64.rpm | 20 MB 00:00:01 Retrieving key from https://www.mongodb.org/static/pgp/server-3.4.asc Importing GPG key 0xA15703C6: Userid : "MongoDB 3.4 Release Signing Key " Fingerprint: 0c49 f373 0359 a145 1858 5931 bc71 1f9b a157 03c6 From : https://www.mongodb.org/static/pgp/server-3.4.asc Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : mongodb-org-server-3.4.22-1.el7.x86_64 1/2 Cleanup : mongodb-org-server-3.2.22-1.el7.x86_64 2/2 Verifying : mongodb-org-server-3.4.22-1.el7.x86_64 1/2 Verifying : mongodb-org-server-3.2.22-1.el7.x86_64 2/2 Updated: mongodb-org-server.x86_64 0:3.4.22-1.el7 Complete! ===Start the server=== [root@localhost yum.repos.d]# /bin/mongod -f /etc/mongod.conf --fork about to fork child process, waiting until server is ready for connections. forked process: 6649 child process started successfully, parent exiting [root@localhost yum.repos.d]# ===Verify the version=== [root@localhost yum.repos.d]# mongo 192.168.0.172:27017 MongoDB shell version: 3.0.15 connecting to: 192.168.0.172:27017/test Server has startup warnings: 2019-09-10T07:40:08.027-0400 I STORAGE [initandlisten] 2019-09-10T07:40:08.027-0400 I STORAGE [initandlisten] ** WARNING: Readahead for /var/lib/mongo is set to 4096KB 2019-09-10T07:40:08.027-0400 I STORAGE [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less 2019-09-10T07:40:08.027-0400 I STORAGE [initandlisten] ** http://dochub.mongodb.org/core/readahead 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T07:40:08.217-0400 I CONTROL [initandlisten] rs0:PRIMARY> db.version() 3.4.22 rs0:PRIMARY> Now I know that this was boring BUT, I wanted to reach at least up to 3.4 so I can show you what happens if you don't upgrade the datafiles as well. If you continue like that and upgrade to 3.6, without upgrading the datafiles, you will receive the following error: [root@localhost yum.repos.d]# /bin/mongod -f /etc/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 7100 ERROR: child process failed, exited with error number 62 That pretty much says, that there was a problem starting the server, but no what is THE PROBLEM :) You can find more info in the LOG file, whose location is configured in the main config file (e.g. /etc/mongod.conf) 2019-09-10T07:46:43.617-0400 F CONTROL [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details. 2019-09-10T07:46:43.617-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets... So in order to not encounter that (because if we encounter it we have to delete the 3.6, install 3.4 and do what we will do now :) ) We have to upgrade also the datafiles ===Upgrade datafiles=== It is done very easy. Just login on the server and execute: db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ) [root@localhost ~]# mongo MongoDB shell version: 3.0.15 connecting to: test Server has startup warnings: 2019-09-10T08:00:51.610-0400 I STORAGE [initandlisten] 2019-09-10T08:00:51.610-0400 I STORAGE [initandlisten] ** WARNING: Readahead for /var/lib/mongo is set to 4096KB 2019-09-10T08:00:51.610-0400 I STORAGE [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less 2019-09-10T08:00:51.610-0400 I STORAGE [initandlisten] ** http://dochub.mongodb.org/core/readahead 2019-09-10T08:00:51.762-0400 I CONTROL [initandlisten] 2019-09-10T08:00:51.762-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2019-09-10T08:00:51.762-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2019-09-10T08:00:51.762-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2019-09-10T08:00:51.762-0400 I CONTROL [initandlisten] 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T08:00:51.763-0400 I CONTROL [initandlisten] 2019-09-10T08:00:52.101-0400 I STORAGE [initandlisten] 2019-09-10T08:00:52.101-0400 I STORAGE [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset 2019-09-10T08:00:52.101-0400 I STORAGE [initandlisten] ** Restart with --replSet unless you are doing maintenance and no other clients are connected. 2019-09-10T08:00:52.101-0400 I STORAGE [initandlisten] ** The TTL collection monitor will not start because of this. 2019-09-10T08:00:52.101-0400 I STORAGE [initandlisten] > db.version() 3.4.22 > db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } ) { "ok" : 1 } > > > You can verify which is the current version of the datafiles using the following command: > db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) { "featureCompatibilityVersion" : "3.4", "ok" : 1 } And that is that, so let's continue to 3.6 and then I will skip it till 4.3 :) ====Upgrade to 3.6==== Remember that we should perform that step from now on :) ===Shutdown the server=== This time we will do it gracefully to see that I also have hearth :) [root@localhost ~]# mongo localhost:27017/admin --eval "db.shutdownServer()" MongoDB shell version: 3.0.15 connecting to: localhost:27017/admin 2019-09-10T09:17:37.121-0400 I NETWORK DBClientCursor::init call() failed server should be down... ===Modify yum config file=== *********************************************************** [mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc ===Upgrade the libraries=== [root@localhost ~]# yum search mongo Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.it4i.cz * extras: mirror.it4i.cz * updates: mirror.it4i.cz ============================================================================================================ N/S matched: mongo ============================================================================================================= google-noto-sans-mongolian-fonts.noarch : Sans Mongolian font mongodb-org.x86_64 : MongoDB open source document-oriented database system (metapackage) mongodb-org-mongos.x86_64 : MongoDB sharded cluster query router mongodb-org-server.x86_64 : MongoDB database server mongodb-org-shell.x86_64 : MongoDB shell client mongodb-org-tools.x86_64 : MongoDB tools autocorr-mn.noarch : Mongolian auto-correction rules hunspell-mn.noarch : Mongolian hunspell dictionaries hyphen-mn.noarch : Mongolian hyphenation rules Name and summary matches only, use "search all" for everything. [root@localhost ~]# yum install mongodb-org-server.x86_64 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.it4i.cz * extras: mirror.it4i.cz * updates: mirror.it4i.cz mongodb-org-3.0 | 2.5 kB 00:00:00 mongodb-org-3.2 | 2.5 kB 00:00:00 mongodb-org-3.4 | 2.5 kB 00:00:00 mongodb-org-3.6 | 2.5 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package mongodb-org-server.x86_64 0:3.4.22-1.el7 will be updated ---> Package mongodb-org-server.x86_64 0:3.6.14-1.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================================================================= Updating: mongodb-org-server x86_64 3.6.14-1.el7 mongodb-org-3.6 20 M Transaction Summary ============================================================================================================================================================================================================================================= Upgrade 1 Package Total download size: 20 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. mongodb-org-server-3.6.14-1.el7.x86_64.rpm | 20 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : mongodb-org-server-3.6.14-1.el7.x86_64 1/2 Cleanup : mongodb-org-server-3.4.22-1.el7.x86_64 2/2 Verifying : mongodb-org-server-3.6.14-1.el7.x86_64 1/2 Verifying : mongodb-org-server-3.4.22-1.el7.x86_64 2/2 Updated: mongodb-org-server.x86_64 0:3.6.14-1.el7 Complete! [root@localhost ~]# ===Start the server=== [root@localhost ~]# /bin/mongod -f /etc/mongod.conf --fork about to fork child process, waiting until server is ready for connections. forked process: 5010 child process started successfully, parent exiting [root@localhost ~]# ps -ef | grep mongo^C [root@localhost ~]# mongo MongoDB shell version: 3.0.15 connecting to: test Server has startup warnings: 2019-09-10T09:53:17.388-0400 I STORAGE [initandlisten] 2019-09-10T09:53:17.388-0400 I STORAGE [initandlisten] ** WARNING: Readahead for /var/lib/mongo is set to 4096KB 2019-09-10T09:53:17.388-0400 I STORAGE [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less 2019-09-10T09:53:17.388-0400 I STORAGE [initandlisten] ** http://dochub.mongodb.org/core/readahead 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2019-09-10T09:53:17.559-0400 I CONTROL [initandlisten] 2019-09-10T09:53:17.572-0400 I STORAGE [initandlisten] 2019-09-10T09:53:17.572-0400 I STORAGE [initandlisten] ** WARNING: This server is using MONGODB-CR, a deprecated authentication mechanism. 2019-09-10T09:53:17.573-0400 I STORAGE [initandlisten] ** Support will be dropped in a future release. 2019-09-10T09:53:17.573-0400 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/3.0-upgrade-to-scram-sha-1 2019-09-10T09:53:17.574-0400 I STORAGE [initandlisten] 2019-09-10T09:53:17.574-0400 I STORAGE [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset 2019-09-10T09:53:17.574-0400 I STORAGE [initandlisten] ** Restart with --replSet unless you are doing maintenance and no other clients are connected. 2019-09-10T09:53:17.574-0400 I STORAGE [initandlisten] ** The TTL collection monitor will not start because of this. 2019-09-10T09:53:17.574-0400 I STORAGE [initandlisten] > db.version() 3.6.14 > db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) { "featureCompatibilityVersion" : { "version" : "3.4" }, "ok" : 1 } <- Database features are still 3.4 ===Upgrade the database features=== > db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } ) { "ok" : 1 } > db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) { "featureCompatibilityVersion" : { "version" : "3.6" }, "ok" : 1 } > ====Upgrade to 4.0==== I know this is getting annoying, but there are other specifics actions which should be done when upgrading to 4.0: Authentication schema upgrade. In nutshell, the default authentication schema: Mongo-CR is removed in Mongo >= 4.X. Therefore we have to upgraded latest when we are Mongo 3.6. Therefore, we have to: * Enable authentication * Upgrade authentication schema Please follow the procedures for these two tasks in: [[mongo_usrs_roles| Users & Roles]] After you upgrade the autnetication schema, there is ALSO something specific when upgrading to 4.2 ====Upgrade to 4.2==== I know I am exhausting with that, but blame Mongo not me :) Since 4.2 the storage engine: MMAPv1 is depricated, therefore we have to change it, in 4.0, to the default for >=4.2: WiredTiger: The procedure for that can be found at: [[mongo_management| Management]]: Change storage engine After that change you can continue with the upgrade to 4.2 previous ones. > db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) { "featureCompatibilityVersion" : { "version" : "4.0" }, "ok" : 1 } > db.adminCommand( { setFeatureCompatibilityVersion: "4.2"} ) { "ok" : 1 } > db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) { "featureCompatibilityVersion" : { "version" : "4.2" }, "ok" : 1 } >