Can't upload products.json into mongos

NEVERMIND! I found my answer… just issue the import command FROM VAGRANT and not from the mongos command line. Admin, it would be helpful to include that info in the instructions. I found this from the next video on chuncks.

M103 configDB: Database collection not found was not a helpful link. No solution from that info…

Now my issue …

I was following the Lab “Shard a Cluster” perfectly, then when I went to import products.json from my /dataset/products.json file, I get this error:

2019-12-21T22:40:23.264+0000 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:5
MongoDB Enterprise mongos>

When I run sh.status(), I get this output:
MongoDB Enterprise mongos> sh.status()
— Sharding Status —
sharding version: {
“_id” : 1,
“minCompatibleVersion” : 5,
“currentVersion” : 6,
“clusterId” : ObjectId(“5dfe705ab39f477a7a994301”)
{ “_id” : “m103-repl”, “host” : “m103-repl/,,m103:27003”, “state” : 1 }
{ “_id” : “m103-repl-2”, “host” : “m103-repl-2/,,”, “state” : 1 }
active mongoses:
“3.6.15” : 1
Currently enabled: yes
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
No recent migrations
{ “_id” : “config”, “primary” : “config”, “partitioned” : true }
shard key: { “_id” : 1 }
unique: false
balancing: true
m103-repl 1
{ “_id” : { “$minKey” : 1 } } -->> { “_id” : { “$maxKey” : 1 } } on : m103-repl Timestamp(1, 0)
{ “_id” : “m103”, “primary” : “m103-repl-2”, “partitioned” : true }
Can someone tell me why I can’t get the data uploaded?
Also, maybe related, when I issue “show dbs” command from mongos, I only get ‘admin’ and ‘config’, however, within config within databases, I get the following:
MongoDB Enterprise mongos> db.databases.find().pretty()
{ “_id” : “m103”, “primary” : “m103-repl-2”, “partitioned” : true }

Here are the 3 ways I’m trying to issue the import command in mongos:

  1. mongoimport --drop /dataset/products.json --port 26000 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin” --db m103 --collection products

  2. mongoimport --drop /dataset/products.json --port 26000 -u “m103-admin”
    -p “m103-pass” --authenticationDatabase “admin”
    –db m103 --collection products NOTE there are slashes at the end of each line

  3. mongoimport --file="/dataset/products.json" type=json --port=26000 -u=“m103-admin” -p=“m103-pass” --authenticationDatabase=“admin” --db=m103 --collection=products --db=m103 --ignoreBlanks

By the way, I’ve manually created the db ‘m103’ on the mongos, and I’ve inserted a test doc into a collection I created called ‘zz’, so I can issue commands, show dbs and show collecitons, and I see both the m103 db and the zz collection. But, I can’t import that json file.

Also, I have validated that products.json is really inside of my /dataset directory and I even placed a copy of it in /shared directory, just in case. I’ve also issued cmmd line ‘cat products.json’ to actually see the json file inside of it so it’s legit.

Any ideas?

Different problems too :wink:

Hi @Rufel_05530,

I’m sorry if you found this confusing. All the MongoDB server tools such as mongoimport and mongoexport are supposed to be run from the OS prompt.

It has been discussed in this video lecture - Chapter 1: The Mongod Server Tools Overview.

Hope it helps!

If you have any other query then please feel free to get back to us.

Shubham Ranjan
Curriculum Support Engineer