Increase the size of oplog

To increase the size of oplog, perform the following steps:

1. If this is currently the primary, step it down and wait for the other servers to catchup.

2. Shut down the server

3. Start it up as a standalone server.

4. Temporarily store the last insert in the oplog in another collection:
use local
// op: “i” finds the last insert
var cursor ={“op” : “i”})
var lastInsert = cursor.sort({“$natural” : -1}).limit(1).next()

// make sure it was saved! It’s very important that you don’t lose this op

We could use the last update or delete, but $-operators cannot be inserted into a
5. Drop the current oplog:
6. Create a new oplog:
db.createCollection(“”, {“capped” : true, “size” : 10000})
7. Put the last op back in the oplog:
var temp = db.tempLastOp.findOne()

// make sure that this was actually inserted

Make sure that the last op was inserted into the oplog. If it was not, the server will
drop all of its data and resync when you add it back into the set.
8. Finally, restart the server as a member of the replica set. Remember that it only has
one op in the oplog to start out with, so you won’t be able to see its true oplog length
(how long it is in time) for a while. Also, it won’t be a very good sync source if other
members are behind.

MongoDB upgrade 2.6 to 3.0 (Non Sharded cluster)

Manual MongoDB upgrade 2.6.3 to 3.0.4 (Non Sharded cluster)
Upgrade plan:
1 Check current version and login to the database and Ops-Manager

2 Take backup of the current binary and database
3 Upgrade secondary members of the replica set.

Upgrade the secondary members of the set one at a time by shutting down the mongod and replacing the 2.6 binary with the 3.0 binary. After upgrading a mongod instance, wait for the member to recover to SECONDARY state before upgrading the next instance. To check the member’s state, issue rs.status() in the mongo shell.

3.1 Download 3.0 binaries
Copy downloaded 3.0 binaries from Beta
3.2 Shutdown database
use admin
3.3 Replace 2.6 binaries
Replace 2.6 binaries with 3.0 binaries

3.4 Start mongod service

4 Upgrade primary member
Step down the replica set primary.

Use rs.stepDown() in the mongo shell to step down the primary and force the set to failover. rs.stepDown() expedites the failover procedure and is preferable to shutting down the primary directly.

When rs.status() shows that the primary has stepped down and another member has assumed PRIMARY state, shut down the previous primary and replace the mongod binary with the 3.0 binary and start the new instance.

use admin
Replace 2.6 binaries with 3.0 binaries
start mongo

–Shutdown database
use admin
–Copy binary from the current backup
Replace 3.0 binaries with 2.6 binaries
–Start mongod service