MongoDB – Upgrade:

MongoDB versions being maintained by several business applications in the market are with 2.4, 2.6, 3.0, 3.4.

The requirements to upgrade your MongoDB to 3.4 version is as below:
1. First you must have current running version 2.6 to upgrade to 3.0
2. If you are running the version below 2.6 or if it is 2.4 version you first need to upgrade from 2.4 to
3. If you upgrade to 2.6 version once, then you cannot downgrade to any version below to that.

Upgrading Standalone mongod Instance to MongoDB 3.0

To upgrade from version 2.4 to 3.0, upgrade to version 2.6 first, and then upgrade from 2.6 to 3.0.

Upgrade Binaries

If you installed MongoDB from the MongoDB apt, yum, or zypper repositories, you should upgrade to 3.0 using your package manager.

Otherwise,manually upgrade MongoDB:

1. Download 3.0 binaries of the latest release in the 3.0 series from the MongoDB website.
2. Shutdown the mongod instance. Replace 2.6 binaries with the 3.0 mongod binary and restart
3. Change Storage Engine for Standalone to WiredTiger

–> If MongoDB is already running , then Export data using mongodump.
mongodump –out <exportDataDestination>
–> Create a data directory with read, write permission for the new mongod instance that will run with
the WiredTiger storage engine.
–> Start mongod with WiredTiger.
mongod –storageEnginewiredTiger –dbpath<newWiredTigerDBPath>
–> Upload the exported data using mongorestore.


Upgrade a ReplicaSet to 3.0


Before upgrading MongoDB 3.0, make sure the oplog entries made by earlier versions of 2.2.1 are overwritten by later versions. MongoDB 3.0 follow the Stricter validation of replica set configuration that may invalidate previously-valid replica set configuration which preventing replica sets from starting in MongoDB 3.0.

Rolling upgrade from MongoDB 2.6 to 3.0:

This will minimize downtime by upgrading the members individually where the other members are available.

1. Upgrade the secondary members one by one by shutting down the mongod and replacing the 2.6 binaries with the 3.0 binaries.Before upgrading the next instance wait until the current upgraded instance recover to SECONDARY State. Check the status using rs.status().
2. Step down the replica set primary using rs.stepDown() and set to failover the PRIMARY to shutdown
3. Upgrade the primary by replacing the mongod binaries with the 3.0 binaries and start the new instance.