Way to force deletion of a sherd?

When trying to import products.json into mongos (that is, m103-repl-2) I get this error:

error inserting documents: unable to initialize targeter… FailedToSatisfyReadPreference: Database m103 not found due to Could not find host matching read preference { mode: “primaryPreferred” } for set m103-repl

which is no doubt because of this (note the wrong ports on m103-repl, that RS is actually on 27001-003):

mongos> sh.status()
shards:
{ “_id” : “m103-repl”, “host” : “m103-repl/192.168.103.100:27011,m103:27012,m103:27013”, “state” : 1, “draining” : true }
{ “_id” : “m103-repl-2”, “host” : “m103-repl-2/192.168.103.100:27004,m103:27005,m103:27006”, “state” : 1 }

So I tried this:

mongos> db.adminCommand({removeShard:“m103-repl”})

And the response shows that, while there are no databases to move, it just sits there forever, draining.

{
“msg” : “draining ongoing”,
“state” : “ongoing”,
“remaining” : {
“chunks” : NumberLong(1),
“dbs” : NumberLong(0)
},
“note” : “you need to drop or movePrimary these databases”,
“dbsToMove” : ,

So I don’t see how I can recreate my shard on the correct ports, and thus do the import, without emptying all my /db folders and starting over. Is there a better option?

One other way I can think of is :slight_smile:

  1. Do movePrimary to move your primary shard from m103-repl to m103-repl-2. Here is the documentation link: https://docs.mongodb.com/manual/reference/command/movePrimary/
  2. Then remove Shard m103-repl
  3. Then add shard with ports 27001,27002,27003
  4. Then again do movePrimary to make m103-repl primary shard.
  5. Then try to import the data.

Kanika

I tried that but got an error to the effect that it could not find a node to read from in m103-repl. I shut down the various servers and emptied all the db directories and restarted everything. That was a last resort of course.