Uhmmm the problem with cloneCollection is that you have to run in the server (or replica) where you want to store the collection, so, I should run this command from a primary replica of one no-primary shard, and not over mongos, right?.
What I did was,
I've created a collection over test database throw mongos. this collection was stored in primary shard, that's ok.
So I connect to another primary replica of other shard which is not primary shard, and I ran this command.
testset3:PRIMARY> db.runCommand({cloneCollection:"test.users",from:"primary.replica.primary.shard:10000",query:{},copyIndexes:false})
{ "ok" : 1 }
It cloned all the users collection in the shar3. Then when I did an explain in mongos this is what happened
mongos> db.users.find().explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 1,
"nscanned" : 1,
"nscannedObjectsAllPlans" : 1,
"nscannedAllPlans" : 1,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
},
"server" : "chewbacca:10000",
"millis" : 0
}
It still search the collection in primary shard, and if I remove this collections, mongos does not know that this collection is in another shard.
Is there a way to tell a mongos that this collections is in another shard which is not the primary shard without change the primary shard??