Skip to content

Instantly share code, notes, and snippets.

@dbmurphy
Last active August 29, 2015 14:07
Show Gist options
  • Save dbmurphy/f2619088bd853f3f883e to your computer and use it in GitHub Desktop.
Save dbmurphy/f2619088bd853f3f883e to your computer and use it in GitHub Desktop.
Move Chunk (assumes) 2.4+
function MoveChunk(chunk,count){
good_shards=["shard4","shard5","shard6","shard7"];
printjson(chunk);
moveObject= { moveChunk : chunk.ns, find: chunk.min , to : good_shards[count % good_shards.length], __waitForDelete:false,__secondaryThrottle:true}
printjson(moveObject);
printjson("++++++++++++++++++++++");
printjson(db.adminCommand(moveObject));
printjson("++++++++++++++++++++++");
}
count=0;
db.getSiblingDB('config').chunks.find({ns:"somedb.somecollection",shard:"shard3"}).skip(22).limit(25).forEach(
function(chunk)){
print("->>>>>>>> Processing chunk "+count+"/25 <--------------");
MoveChunk(chunk,count);
count+=1;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment