Limited support This version of the product is in limited support. However, the documentation is available for your convenience. You will not be able to leave comments. Click here to view the documentation for the current version.

Upgrading MongoDB replica set


You can upgrade from MongoDB 3.0.xx replica set to 3.4.xx by upgrading the members individually while the other members are available.

The following diagram provides an overview of the upgrade process.

UpgradingMongoDBReplicaSet34.png


The upgrade process comprises of following stages:

  1. Upgrade the secondary server .
  2. Change the secondary server storage engine to WiredTiger.
  3. Execute stage 2 and 3 for all the secondary members.
  4. Upgrade the primary server.
  5. Change the primary server storage engine to WiredTiger.
  6. For enhancing search BMC recommends that you use Full Text Search that is available by default.

Note

Replica set failover is not instant and will render the set unavailable to accept writes until the failover process completes. This usually takes no more than 3-5 minutes. Thus, schedule the upgrade procedure during a scheduled maintenance window.

To upgrade the secondary server

  1. Download the version 3.4 binaries ( http://www.mongodb.org/downloads )
  2. Shut down the mongod instance.  
    • Windows: Go to Services and stop Mongod service.
    • Unix: Run the following command:
      /etc/init.d/<mongod service name> stop
  3. Replace the existing binaries with the version 3.4 mongod binaries.
  4. Restart the mongod instance. 
    • Windows: Go to  Services and start Mongod  service.
    • Unix: Run the following command:
      /etc/init.d/<mongod service name> start
  5. Allow the replica set member to recover the SECONDARY state before upgrading the next member. To verify the member’s state, execute the following command:
    rs.status()

    Click here to view an example output...

    "set" : "myitsocial"
    "date" : ISODate
    "myState" : 1
    "members" : [ 
       { 
         "_id" : 0
         "name" : "xx.xx.xx.xx:27017"
         "health" : 1
         "state" : 1
         "stateStr" : "PRIMARY"
         "uptime" : 303165
         "optime" : Timestamp(1407521114, 1)
         "optimeDate" : ISODate("2014-08-08T18:05:14Z")
         "self" : true 
       }, 
       { 
         "_id" : 1
         "name" : "xx.xx.xx.xx:27017"
         "health" : 1
         "state" : 2
         "stateStr" : "SECONDARY"
         "uptime" : 302985
         "optime" : Timestamp(1407521114, 1)
         "optimeDate" : ISODate("2014-08-08T18:05:14Z")
         "lastHeartbeat" : ISODate("2014-08-12T06:15:02Z")
         "lastHeartbeatRecv" : ISODate("2014-08-12T06:15:02Z")
         "pingMs" : 0
      "syncingTo" : "xx.xx.xx.xx:2701" 
       },
       { 
         "_id" : 2
         "name" : "xx.xx.xx.xx:27017"
         "health" : 1, "state" : 2
         "stateStr" : "SECONDARY"
         "uptime" : 302985
         "optime" : Timestamp(1407521114, 1)
         "optimeDate" : ISODate(" ")
         "lastHeartbeat" : ISODate(" ")
         "lastHeartbeatRecv" : ISODate(" Z")
         "pingMs" : 0
         "syncingTo" : "xx.xx.xx.xx:27017" 
       } 
    ], 
    "ok" : 1 
    }
  6. Change the secondary server storage engine to WiredTiger.

To upgrade the primary server

  1. Bring down the replica set primary server and force it to failover. Run the following command:
    rs.stepDown()
    Using the command expedites the failover and is preferable to shutting down the primary server directly.
  2. Allow the replica set primary server to step down and let another assume the PRIMARY state. 
     To verify the member’s state, execute the following command:
    rs.status()
  3. Shut down the mongod instance. 
  4. Replace the existing binaries with the version 3.4 mongod binaries.
  5. Restart the mongod instance.
  6. Change the primary server storage engine to WiredTiger.

To change the storage engine to WiredTiger

The WiredTiger setting can improve performance and reduce storage.

  1. Stop the mongod instance.
  2. Delete the content of the data directory. (dbpath in mongodb.config file)
  3. Edit you mongodb config file and add following line:

    storageEngine = wiredTiger

    If you are using mongodb config in YAML format (which wont have key = value format) you need to add

    Add the following:

    storage:

        engine: wiredTiger

        dbPath: ..

  4. Restart the member. 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*