Removing a Shard from a sharded cluster

Hi Everyone,

Here are some steps to remove a shard from a sharded cluster:

  • Connect to mongos
  • Authenticate using m103-admin
  • Run these commands:
   > use config
   > db.shards.find()
   { "_id" : "m103-repl", "host" : "m103-repl/,,", "state" : 1 }
   { "_id" : "m103-repl-2", "host" : "m103-repl-2/,,", "state" : 1 }

If you see your shards listed here, and you want to remove one shard suppose: m103-repl-2, then:

     > use admin
     > db.adminCommand( { removeShard: "m103-repl-2" } )

And I would encourage to look in the mongodb documentation for more information, here are some useful links:

Let me know if anyone has more doubts!