Lab - Shard a Collection, [FAIL] "The dataset is imported to m103.products"

I imported m103.products with the following statement:

bash-4.4# mongoimport --host “csrs/localhost:27004” --db=“m103” --collection=“products” -u “m103-admin” -p “m103-pass” --drop --file /dataset/products.json --authenticationDatabase “admin”

The import seemed successful. After import, I log in ‘mongos’, ‘show dbs’ can see ‘m103’, but ‘show collections’ command gave me an empty output. After I run ‘sh.enableSharding(“m103”)’, ‘show collections’ command successfully showed ‘products’ collection. The rest statements seemed OK. However when I click “RUN test” button, I receive the following error:

"[FAIL] “The dataset is imported to m103.products”

Then I figured out the correct way to import the collection following the Lab instruction of “use mongos as the target for mongoimport”. It means that I need to import the correction into ‘mongos’ instead of ‘replica set’ on port 27004.

My question here is what the difference is and what is wrong if I imported the collection into the ‘replica set’ instead of ‘mongos’? I must miss a concept. Please help.


Hi @Qi.Chen - below are the steps in order to import a collection to a cluster:

  1. Import a collection of data on to the cluster
  2. Enable sharding on the m103 database
  3. Choose a shard key for the m103.products collection.
  4. Create an index on your shard key and shard the collection

I did use --host option while import and the lab went fine for me previously.