Upgrading MongoDB replica set
The upgrade process comprises of following stages:
- Upgrade the secondary server .
- Change the secondary server storage engine to WiredTiger.
- Execute stage 2 and 3 for all the secondary members.
- Upgrade the primary server.
- Change the primary server storage engine to WiredTiger.
- For enhancing search BMC recommends that you use Full Text Search that is available by default.
To upgrade the secondary server
- Download the version 3.4 binaries ( http://www.mongodb.org/downloads )
- 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
- Replace the existing binaries with the version 3.4 mongod binaries.
- Restart the mongod instance.
- Windows: Go to Services and start Mongod service.
- Unix: Run the following command:
/etc/init.d/<mongod service name> start
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()- Change the secondary server storage engine to WiredTiger.
To upgrade the primary server
- 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. - 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() - Shut down the mongod instance.
- Replace the existing binaries with the version 3.4 mongod binaries.
- Restart the mongod instance.
- Change the primary server storage engine to WiredTiger.
To change the storage engine to WiredTiger
The WiredTiger setting can improve performance and reduce storage.
- Stop the mongod instance.
- Delete the content of the data directory. (dbpath in mongodb.config file)
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: ..
- Restart the member.
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*