How to manage Mongos for a Cloud Manager managed cluster

MongoDB

#Cloud

In this blog post we will explore how to manage Mongos servers using Cloud Manager. Mongos (short for “MongoDB Shard”) is a routing service for MongoDB shard configurations that process queries from the application layer and determines the location of the data in the sharded cluster.

How to Add a Mongos server

For deployments under automation, it’s very easy to add a Mongos to your Sharded Cluster. Go to Deployments>Processes and click the wrench at the Sharded Cluster top level.

https://webassets.mongodb.com/_com_assets/blog/tblr/41.media.tumblr.com--4b85ea5bf0d3dda8baa51deb447453dc--tumblr_nzk828ZeL61sdaytmo1_1280.png

Next, scroll down to the MongoS settings. There you will see your current settings. Increase the # of Mongos processes to the desired number. For determining which host to deploy the new Mongos, here I chose Regular Expression and entered a string matching an existing host. Choose your desired port range for the Mongos. When you are finished click Apply.

https://webassets.mongodb.com/_com_assets/blog/tblr/40.media.tumblr.com--0733cef02762c36beadd0d520dbf9f74--tumblr_nzk828ZeL61sdaytmo5_1280.png

Next review your changes. Here you see that the number of Mongos is increasing from 3 to 4. Confirm the host, port, and other details and click Click & Confirm.

https://webassets.mongodb.com/_com_assets/blog/tblr/41.media.tumblr.com--234373d85609a80c8f6011375c730d1e--tumblr_nzk828ZeL61sdaytmo3_1280.png

How to Remove a Mongos server

Conversely, it’s also simple to remove a Mongos from your deployment if it’s under automation. From the Deployment>Processes view, change the filter to ‘Mongos’ as shown below. We must first Shutdown the process. Click the “…” menu for the target mongos and choose the Shutdown option. Review & deploy the change.

https://webassets.mongodb.com/_com_assets/blog/tblr/40.media.tumblr.com--4d9db66fcef39062d081919be5065164--tumblr_nzk828ZeL61sdaytmo4_1280.png

Once the target mongos is shut down go back to Deployment>Processes and select the ‘Mongos’ filter again. Click the “…” menu for the target mongos and this time choose ‘Remove from Cluster’

https://webassets.mongodb.com/_com_assets/blog/tblr/41.media.tumblr.com--e54ef630241a584582e44fcbbcb8fb4b--tumblr_nzk828ZeL61sdaytmo6_1280.png

Finally, review your changes. Confirm that the number of Mongos processes is reduced and that the target host and server looks correct. Confirm & Deploy to complete the operation.

https://webassets.mongodb.com/_com_assets/blog/tblr/41.media.tumblr.com--93df7b0354009b5035f8ce69c090bf98--tumblr_nzk828ZeL61sdaytmo2_1280.png