Created
May 21, 2012 12:44
-
-
Save azat/2762148 to your computer and use it in GitHub Desktop.
mongodb manually unshard
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
// set | |
var collection = ; | |
var db = ; | |
var fromHost = ; | |
// unshard | |
db = db.getMongo().getDB(db); | |
var collection = db.getCollection(collection); | |
var m = new Mongo(fromHost); | |
var remoteCollection = m.getDB(db).getCollection(collection); | |
var i = 0; | |
collection.find().forEach(function(row) { | |
remoteCollection.insert(row); | |
collection.remove({_id: row._id}); | |
if ((++i % 50000) == 0) { | |
print("Updated: " + i); | |
} | |
}); | |
print("Updated: " + i); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this method, mongodb will not balance while you're inserting in another collection?