How to Perform MongoDB Upgrade for High Availability from 3.6 to 4.2

MongoD

At FileCloud, we’re always working to make sure our systems are upgraded to the highest possible standard.

With our 21.1 update, FileCloud MongoDB has been upgraded from 3.6 to 4.2.

For standalone installations, the script will automatically upgrade the version, as it includes compatibility checks and issues. Prior to web node upgrades, the MongoDB cluster will need to be upgraded manually.

Below are the steps to upgrade MongoDB Servers in Linux:

Step 1: Set Feature Compatibility to 3.6

mongo –host {IP address of Primary}  –eval “db.adminCommand( { setFeatureCompatibilityVersion: ‘3.6’ } )”

Step 2: Upgrade Secondary Nodes to 4.0

In Linux versions, you can use the command filecloudcp -m40 which should help you upgrade the MongoDB from 3.6 to 4.0

Step 3: Stepdown current primary as secondary

rs.stepDown()

Step 4: Upgrade the last server to 4.0

Step 5: Set Feature Compatibility to 4.0 in the current Primary Server

mongo –host {IP address of Primary} “db.adminCommand( { setFeatureCompatibilityVersion: ‘4.0’ } )”

Step 6: Upgrade Secondary Nodes from 4.0 to 4.2 one by one using the below commands:

filecloudcp -m42

Step 7: Stepdown current primary as secondary

rs.stepDown()

Step 8: Run command in Step 6 to upgrade all the MongoDB servers to 4.2

Step 9: Set Feature Compatibility to 4.2 in the current Primary Server

mongo –host {IP address of Primary} “db.adminCommand( { setFeatureCompatibilityVersion: ‘4.2’ } )”

After upgrading the MongoDB servers, you can run the command filecloudcp -u on all the web servers which should help you to upgrade the FileCloud webservers to the latest version.

Below are the steps to upgrade MongoDB Servers in Windows:

Download the file https://patch.codelathe.com/tonidocloud/live/scripts/fc/filecloudcp.ps1 and place it under Xampp\htdocs\resources\tools

Step 1: Set Feature Compatibility to 3.6

mongo –host {IP address of Primary}  –eval “db.adminCommand( { setFeatureCompatibilityVersion: ‘3.6’ } )”

Step 2: Upgrade Secondary Nodes to 4.0

In Linux versions, you can use the command Xampp\htdocs\resources\tools\filecloudcp -m40 which should help you upgrade the MongoDB from 3.6 to 4.0

Step 3: Stepdown current primary as secondary

rs.stepDown()

Step 4: Upgrade the last server to 4.0

Step 5: Set Feature Compatibility to 4.0 in the current Primary Server

mongo –host {IP address of Primary} “db.adminCommand( { setFeatureCompatibilityVersion: ‘4.0’ } )”

Step 6: Upgrade Secondary Nodes from 4.0 to 4.2 one by one using the below commands:

Xampp\htdocs\resources\tools\filecloudcp -m42

Step 7: Stepdown current primary as secondary

rs.stepDown()

Step 8: Run command in Step 6 to upgrade all the MongoDB servers to 4.2

Step 9: Set Feature Compatibility to 4.2 in the current Primary Server

mongo –host {IP address of Primary} “db.adminCommand( { setFeatureCompatibilityVersion: ‘4.2’ } )”

After upgrading the MongoDB servers, you can run the command filecloudcp -u on all the web servers which will help you to upgrade the FileCloud webservers to the latest version.

In case of any issues with the upgrade, please feel free to open a ticket with our support team at support@codelathe.com

Article written by Nandakumar Chitrasuresh