I have setup a shard cluster with 3 replica sets. Each replica set has 2 mongod instances. I have a separate config server and 1 mongos instance.
I wanted to try whether it’s possible to import documents to a particular/targeted shard, when the collection is not shard enabled. (for performance reasons) (As far as I know, we can’t control in which shard the collection will get saved when importing is done via mongos instance)
Hence, I imported the documents using below command, and it was successful (followed this);
mongoimport --db NormalTestDB --collection TestDams --host <replSetName>/<hostname1><:port>,<hostname2><:port> --jsonArray --file “<path_to_json>”
(I used a particular replica set name in <replSetName>
)
Now when I try this simple query db.TestDams.find().count()
in mongos shell (by connecting to NormalTestDB), it returns 0. But if I try the same query by directly connecting to the Primary of the relevant replicaSet, I get 14603.
Is there any way that I could sync? or is there a way to use mongoimport
targeting a particular shard??
(Please note that I want the collections to be in the same DB)