Book Image

MongoDB High Availability

By : Afshin Mehrabani
Book Image

MongoDB High Availability

By: Afshin Mehrabani

Overview of this book

Table of Contents (17 chapters)
MongoDB High Availability
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 environment, 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 connect 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 network.

Using the following command, you can get the status of the sharding network:

sh...