## Procedure 

• Restart the member in standalone mode. 

## Tip 

Always use rs.stepDown() to force the primary to become a secondary, before stopping the server. This facilitates a more efficient election process. 

• Recreate the oplog with the new size and with an old oplog entry as a seed. 

• Restart the mongod instance as a member of the replica set. 

Restart a Secondary in Standalone Mode on a Different Port Shut down the mongod instance for one of the non-primary members of your replica set. For example, to shut down, use the db.shutdownServer() method: 

db.shutdownServer() 

Restart this mongod as a standalone instance running on a different port and without the --replSet parameter. Use a command similar to the following: 

mongod --port 37017 --dbpath /srv/mongodb 

Create a Backup of the Oplog (Optional) Optionally, backup the existing oplog on the standalone instance, as in the following example: 

mongodump --db local --collection 'oplog.rs' --port 37017 

Recreate the Oplog with a New Size and a Seed Entry Save the last entry from the oplog. For example, connect to the instance using the mongo shell, and enter the following command to switch to the local database: 

use local 

In mongo shell scripts you can use the following operation to set the db object: 

db = db.getSiblingDB('local') 

Ensure that the temp temporary collection is empty by dropping the collection: 

db.temp.drop() 

Use the db.collection.save() method and a sort on reverse natural order to find the last entry and save it to a temporary collection: 

db.temp.save( db.oplog.rs.find( { }, { ts: 1, h: 1 } ).sort( {$natural : -1} ).limit(1 ).next() ) 

To see this oplog entry, use the following operation: 

db.temp.find() 

Remove the Existing Oplog Collection Drop the old oplog.rs collection in the local database. Use the fol- lowing command: 

db = db.getSiblingDB('local') db.oplog.rs.drop() 

This returns true in the shell. 

