Configuring a mongos instance
After configuring the configuration servers, we should bind them to the core module of clustering. The mongos
instance is responsible for binding all modules and parts together to make a complete sharding core.
This module is simple and lightweight, and we can host it on the same machine that hosts other modules, such as configuration servers. It doesn't need a separate directory to store data. The mongos
process uses port 27017
by default, but you can change the port using the configuration parameters.
To define the configuration servers, you can use the configuration file or command-line parameters. Create a new file using your text editor in the /etc/
directory and add the following configuring settings:
configdb = cfg1.sharding.com:27019, cfg2.sharding.com:27020 cfg3.sharding.com:27021
To execute and run the mongos
instance, you can simply use the following command:
mongos -f /etc/mongos.conf
After executing the command, you should see an output like the following...