Created
July 28, 2014 01:39
-
-
Save butlern/760d24ae2519dd835b8a to your computer and use it in GitHub Desktop.
change-oplog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printjson("Getting db object local") | |
db = db.getSiblingDB('local') | |
printjson("Dropping local.temp") | |
db.temp.drop() | |
printjson("Saving last oplog entry into local.temp") | |
db.temp.save( db.oplog.rs.find( { }, { ts: 1, h: 1 } ).sort( {$natural : -1} ).limit(1).next() ) | |
printjson("Printing last oplog entry saved into local.temp") | |
cursor = db.temp.find() | |
if ( cursor.hasNext() ){ | |
printjson( cursor.next() ); | |
} | |
printjson("Dropping existing oplog, *crosses fingers*") | |
db.oplog.rs.drop() | |
printjson("Creating new oplog") | |
db.runCommand( { create: "oplog.rs", capped: true, size: (3 * 1024 * 1024 * 1024) } ) | |
printjson("Inserting last oplog entry into new oplog") | |
db.oplog.rs.save( db.temp.findOne() ) | |
printjson("Ensuring new oplog has entry") | |
cursor2 = db.oplog.rs.find() | |
if ( cursor2.hasNext() ){ | |
printjson( cursor2.next() ); | |
} | |
printjson("Everything looks groovy, shutdown temp server and start it back up on normal port with replset info") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment