How to drain a MongoDB Shard
use dbversity db.dbfry.ensureIndex( { user_id : 1 }, { unique : true }) sh.enableSharding(“dbversity”) sh.shardCollection(“dbversity.dbfry”, {“user_id”:1}) sh.startBalancer() sh.getBalancerState() sh.isBalancerRunning() use dbversity for(var i = 1; i <= 100000 ; i++){db.dbfry.insert({“user_id” : i , “name” : “bulk-inserts”, ” Iteration: ” :…
How to remove a shard from the MongoDB sharded cluster
Removes a shard from a sharded cluster. When you run removeShard, MongoDB first moves the shard’s chunks to other shards in the cluster. Then MongoDB removes the shard. [root@dbversity bin]# ./mongo –port 10000 MongoDB shell version: 2.4.11 connecting to: 127.0.0.1:10000/test…