MongoDB Documentation, Release 3.0.4 Start the mongos Instances Tip Add Shards to the Cluster Optional 2. Add each shard to the cluster using the sh.addShard() method, as shown in the examples below. Issue sh.addShard() separately for each shard. If the shard is a replica set, specify the name of the replica set and specify a member of the set. In production deployments, all shards should be replica sets. 1. From a mongo shell, connect to the mongos instance. Issue a command using the following syntax: • cfg0.example.net • cfg1.example.net • cfg2.example.net Chapter 10. Sharding 692 mongo --host <hostname of machine running mongos> --port <port mongos listens on> For example, if a mongos is accessible at mongos0.example.net on port 27017 , issue the following command: mongo --host mongos0.example.net --port 27017 A shard can be a standalone mongod or a replica set . In a production environment, each shard should be a replica set. Use the procedure in Deploy a Replica Set (page 603) to deploy replica sets for each shard. If you start a mongos instance with a string that does not exactly match the string used by the other mongos instances in the cluster, the mongos return a Config Database String Error (page 735) error and refuse to start. Each mongos in a sharded cluster must use the same configDB string, with identical host names listed in identical order. You would issue the following command: mongos --configdb cfg0.example.net:27019,cfg1.example.net:27019,cfg2.example.net:27019 For example, to start a mongos that connects to config server instance running on the following hosts and on the default ports: mongos --configdb <config server hostnames> To start a mongos instance, issue a command using the following syntax: To avoid downtime, give each config server a logical DNS name (unrelated to the server’s physical or virtual host- name). Without logical DNS names, moving or renaming a config server requires shutting down every mongod and mongos instance in the sharded cluster. When you start the mongos instance, specify the hostnames of the three config servers, either in the configuration file or as command line parameters. The mongos instances are lightweight 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 .