MongoDB Documentation, Release 3.0.4 Create a New Oplog Use the create command to create a new oplog of a different size. Specify the size argument in bytes. A value of 2 * 1024 * 1024 * 1024 will create a new oplog that’s 2 gigabytes: db.runCommand( { create: "oplog.rs", capped: true , size: (2 * 1024 * 1024 * 1024) } ) Upon success, this command returns the following status: { "ok" : 1 } Insert the Last Entry of the Old Oplog into the New Oplog Insert the previously saved last entry from the old oplog into the new oplog. For example: db.oplog.rs.save( db.temp.findOne() ) To confirm the entry is in the new oplog, use the following operation: db.oplog.rs.find() Restart the Member Restart the mongod as a member of the replica set on its usual port. For example: db.shutdownServer() mongod --replSet rs0 --dbpath /srv/mongodb The replica set member will recover and “catch up” before it is eligible for election to primary. Repeat Process for all Members that may become Primary Repeat this procedure for all members you want to change the size of the oplog. Repeat the procedure for the primary as part of the following step. Change the Size of the Oplog on the Primary To finish the rolling maintenance operation, step down the primary with the rs.stepDown() method and repeat the oplog resizing procedure above. Replica sets allow a MongoDB deployment to remain available during the majority of a maintenance window. This document outlines the basic procedure for performing maintenance on each of the members of a replica set. Furthermore, this particular sequence strives to minimize the amount of time that the primary is unavailable and controlling the impact on the entire deployment. Use these steps as the basis for common replica set operations, particularly for procedures such as upgrading to the latest version of MongoDB (page 236) and changing the size of the oplog (page 628). For each member of a replica set, starting with a secondary member, perform the following sequence of events, ending with the primary: Perform Maintenance on Replica Set Members Overview Procedure • Restart the mongod instance as a standalone. • Perform the task on the standalone instance. • Restart the mongod instance as a member of the replica set. Chapter 9. Replication 630