Database Reference
In-Depth Information
Managing a mongos instance
Now it's time to add shards and split the entire dataset into smaller pieces. For production
use, each shard should be a replica set network, but for the development and testing envir-
onment, you can simply add a single
mongod
instance to the cluster. In previous chapters,
we learned how to set up and configure a replica set from scratch.
To control and manage the
mongos
instance, we can simply use the
mongo
shell to con-
nect to the
mongos
and execute commands. To connect to the
mongos
instance, you use
the following command:
mongo --host <mongos hostname> --port <mongos port>
For instance, our
mongos
address is
mongos1.sharding.com
and the port is
27017
.
This is depicted in the following screenshot:
After connecting to the
mongos
instance, we have a command environment, and we can
use it to add, remove, or modify shards, or even get the status of the entire sharding net-
work.
Using the following command, you can get the status of the sharding network:
sh.status()
The following screenshot illustrates the output of this command: