To simulate the process of production deployment of MongoDB, I used Vagrant to create a couples of VMs, and exprienced the journey of deployment mongo step by step as follow mentioned.
Mongo Shard Concepts
Before dived into the code, we can review the concepts related to Mongo Shard, it needs 3 components logically at least.
a) Config Server
The config server processes are mongod instances that store the cluster’s metadata. You designate a mongod as a config server using the –configsvr option. Each config server stores a complete copy of the cluster’s metadata.
b) Query Server
The query server are lightweight mongos instances and do not require data directories. You can run a mongos instance on a system that runs other cluster components, such as on an application server or a server running a mongod process. By default, a mongos instance runs on port 27017.