Lab Shard A Collection - Moving database to m103-repl

Hello,

Just incase you find that your mongoimport of the products.json goes into the 2nd shard.

db.databases.find().pretty() – Check that the database is on the right shard (m103-repl).

You may need to move the m103 database into m103-repl - basically move database m103 into the replica set m103-repl.

db.adminCommand({movePrimary: "m103", to: "m103-repl"} )

Not sure if it makes any difference to the final result - If it does, then these steps should be added to the lecture notes.

PS - May I say this is a very long lab … and I haven’t created even sharded my collection yet.

Thanks
Tried this but validation still failing

MongoDB Enterprise mongos> db.databases.find().pretty()
{ “_id” : “m103”, “primary” : “m103-repl-2”, “partitioned” : true }

MongoDB Enterprise mongos> db.adminCommand({movePrimary: “m103”, to: “m103-repl”} )
{
“primary” : “m103-repl:m103-repl/192.168.103.100:27001,192.168.103.100:27002,192.168.103.100:27003”,
“ok” : 1,
“operationTime” : Timestamp(1548491973, 8),
“$clusterTime” : {
“clusterTime” : Timestamp(1548491973, 8),
“signature” : {
“hash” : BinData(0,“0nT2k6UHF15c/H+CmOJH9gZJTu0=”),
“keyId” : NumberLong(“6649631447575429142”)
}
}
}
MongoDB Enterprise mongos> db.databases.find().pretty()
{ “_id” : “m103”, “primary” : “m103-repl”, “partitioned” : true }

vagrant@m103:/dataset$ validate_lab_shard_collection

Incorrect number of documents imported - make sure you import the entire
dataset.
vagrant@m103:/dataset$

How many documents do you have?

When you say how many documents i am not clear what you meant
As per instructions loaded one under /dataset
Looking at error insufficient docs loaded one more from handouts
Still same error in all cases

@Ramachandra_37567, the error message is Incorrect number of documents imported - make sure you import the entire dataset. So I want you to go in mongos and run the command db.products.count() to find out how may document you have in your collections. Make sure you use the appropriate database which is named m103 in this case.

And, the things in /dataset are not documents in Mongo’s terminology. It is a file.

Thanks for the reply
Yes i did that
vagrant@m103:/shared$ mongo --port 26000 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admiin”
MongoDB shell version v3.6.9
connecting to: mongodb://127.0.0.1:26000/
Implicit session: session { “id” : UUID(“558ff596-3cdf-4800-a099-4ff99ac9ea10”) }
MongoDB server version: 3.6.9
MongoDB Enterprise mongos> db
test
MongoDB Enterprise mongos> show dbs
admin 0.000GB
config 0.001GB
m103 0.033GB
MongoDB Enterprise mongos> use m103
switched to db m103
MongoDB Enterprise mongos> show collections
products
MongoDB Enterprise mongos> db.products.count()
516784

2019-01-26T12:36:54.824+0000 [######################…] m103.products 83.7MB/87.9MB (95.2%)
2019-01-26T12:36:57.655+0000 [########################] m103.products 87.9MB/87.9MB (100.0%)
2019-01-26T12:36:57.655+0000 imported 516784 documents
vagrant@m103:/dataset$ validate_lab_shard_collection

Incorrect number of documents imported - make sure you import the entire
dataset.

vagrant@m103:/dataset$ mongo --port 26000 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”
MongoDB shell version v3.6.9
connecting to: mongodb://127.0.0.1:26000/
Implicit session: session { “id” : UUID(“e89e3beb-9b20-43b0-b6ee-854138174d9b”) }
MongoDB server version: 3.6.9
MongoDB Enterprise mongos> db
test
MongoDB Enterprise mongos> show dbs
admin 0.000GB
config 0.001GB
m103 0.046GB
MongoDB Enterprise mongos> use m103
switched to db m103
MongoDB Enterprise mongos> show collections
products
MongoDB Enterprise mongos> db.products.count()
775174
MongoDB Enterprise mongos>

The count is high because i imported the next file also which is meant for next lab
Load with even single file under /dataset result was same

Sorry i meant file only-wrong terminology used

I would try to rerun mongoimport with –drop so that you do not end up with too many documents.

Thanks
This is completed
Repeated steps from import and it went fine

1 Like