## Start the mongos Instances 

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 . 

When you start the mongos instance, specify the hostnames of the three config servers, either in the configuration file or as command line parameters. 

## Tip 

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. 

To start a mongos instance, issue a command using the following syntax: 

mongos --configdb <config server hostnames> 

For example, to start a mongos that connects to config server instance running on the following hosts and on the default ports: 

• cfg0.example.net 

• cfg1.example.net 

• cfg2.example.net 

You would issue the following command: 

mongos --configdb cfg0.example.net:27019,cfg1.example.net:27019,cfg2.example.net:27019 

Each mongos in a sharded cluster must use the same configDB string, with identical host names listed in identical order. 

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. 

## Add Shards to the Cluster 

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. 

1. From a mongo shell, connect to the mongos instance. Issue a command using the following syntax: 

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 

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. 

## Optional 

