Preparing the environment
Before jumping into configuring and setting up the cluster network, we have to check some parameters and prepare the environment.
To enable sharding for a database or collection, we have to configure some configuration servers that hold the cluster network metadata and shards information. Other parts of the cluster network use these configuration servers to get information about other shards.
In production, it's recommended to have exactly three configuration servers on different machines. The reason for establishing each shard on a different server is to improve the safety of data and nodes. If one of the machines crashes, the whole cluster won't be unavailable.
For the testing and developing environment, you can host all the configuration servers on a single server. Besides, we have two more parts for our cluster network, shards and mongos
, or query routers. Query routers are the interface for all clients. All read/write requests are routed to this module. The query...