Lab - Configure a Sharded Cluster

I tried to delete the previous sharding from mongos but it’s not deleted,
whenever I execute command sh.status(), it’s showing following two shards.
{ “_id” : “m103-example”, “host” : “m103-example/,m103:27012,m103:27013”, “state” : 1, “draining” : true }
{ “_id” : “m103-repl”, “host” : “m103-repl/,m103:27002,m103:27003”, “state” : 1 }

how to delete these shards permanently so that I can add the shard again. validation command giving me following error
vagrant@m103:~/shard_conf$ validate_lab_first_sharded_cluster
Mongos not configured correctly - make sure you have only added one shard to
your cluster.

Hey @Milind_19368,

When you have only one sharded cluster, you can’t easily remove it using sh.removeShard(), it’s a long-winded process.

In your scenario, the best thing to do is to:

  1. shutdown all three config servers
  2. shutdown mongos
  3. delete all the directories for mongos and config servers
  4. make any adjustments you want to make
  5. restart/rebuild the config servers and mongos

But issue here is not removing last shard
Hi Milind_19368
What command you ran to remove shard and on which DB
Please check this link

Removing a Shard from a sharded cluster

Good point @Ramachandra_37567 :slight_smile:, but @Milind_19368 has already run the correct command that’s why draining = true. Once this is complete, he might want also be looking to delete the last remaining shard in which case he’ll be in the situation I mentioned.

Plus, the config servers may still have metadata/traces of what was removed so it might be better to start from scratch. Just in case the validator is checking the config servers too.

I think there is an option to remove last shard if he gets the error “Can’t remove last shard”
use config
In case none of the alternatives work best thing is to redo from scratch

Not the best thing to do here because this is a system collection maintained internally. If you do this, other config collections will become out of sync.
It was also mentioned in the lecture not to touch the collections in the config db, and the documentation supports this:


Thanks !! problem solved after removing csrs node and repl node and restarted all