Upgrade MongoDB cluster from 3.4 to 3.6 on Linux environment

This document using a "rolling" upgrade to minimize downtime by upgrading the members individually while the other members are available

  • Starting in MongoDB 3.6, mongod and mongos instances bind to localhost by default. Remote clients, including other members of the replica set, cannot connect to an instance bound only to localhost. To override and bind to other ip addresses, use the net.bindIp configuration file setting or the --bind_ip command-line option to specify a list of ip addresses.
  • The upgrade process will require that you specify the net.bindIp setting (or --bind_ip), if your replica set members are run on different hosts or if you wish remote clients to connect to your replica set.
  • Read Concern Majority:   Starting in MongoDB 3.6, MongoDB enables support for "majority" read concern by default. For MongoDB 3.6.1 - 3.6.x, you can disable read concern "majority" to prevent the storage cache pressure from immobilizing a deployment with a primary-secondary-arbiter (PSA) architecture. Disabling "majority" read concern also disables support for change streams

Pre-check:

  • Before starting the upgrade, ensure that no initial sync is in progress. Performing the upgrade while an initial sync is in progress will cause the initial sync to restart.
  • To ensure that all members of the replica set have featureCompatibilityVersion set to 3.4, connect to each replica set member and check the featureCompatibilityVersion:

Command: 

db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )


upgrade steps:

 Download 3.6 Binaries either Via Package Manager or Manually

 STEP-1: Upgrade secondary members of the replica set

  • Upgrade the secondary members of the replica set one at a time:
  • Shut down the mongod instance and replace the 3.4 binary with the 3.6 binary.
  • Restart the member.

STEP-2: Step down the replica set primary

Connect a mongo shell to the primary and use rs.stepDown() to step down the primary and force an election of a new primary.

Command:

rs.stepDown()

STEP-3: Upgrade the primary

When rs.status() shows that the primary has stepped down and another member has assumed PRIMARY state, upgrade the stepped-down primary:

  • Shut down the stepped-down primary and replace the mongod binary with the 3.6 binary.
  • Restart the member.

STEP-4: Enable backwards-incompatible 3.6 features

At this point, you can run the 3.6 binaries without the 3.6 features that are incompatible with 3.4.

To enable these 3.6 features, set the feature compatibility version (FCV) to 3.6.

On the primary, run the setFeatureCompatibilityVersion command in the admin database

Command:

db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )

Note: This command must perform writes to an internal system collection. If for any reason the command does not complete successfully, you can safely retry the command on the primary as the operation is idempotent.

TIP:

  • Enabling these backwards-incompatible features can complicate the downgrade process since you must remove any persisted backwards-incompatible features before you downgrade.
  • It is recommended that after upgrading, you allow your deployment to run without enabling these features for a burn-in period to ensure the likelihood of downgrade is minimal. 
  • When you are confident that the likelihood of downgrade is minimal, enable these features.
  • Ensure that no initial sync is in progress. Running setFeatureCompatibilityVersion command while an initial sync is in progress will cause the initial sync to restart.

IMPORTANT:

If your replica set members are run on different hosts or if you wish remote clients to connect to your instance, you must specify the net.bindIp setting (or --bind_ip).


Comments

Popular posts from this blog

Auditing in Oracle database

rs.stepDown() in MongoDB replication

Tuples in Python