Navigation
This version will reach end of life on Feb 2018. To upgrade, go to the Learn more about upgrading your version of MongoDB.

sh.addShardTag()

On this page

Definition

sh.addShardTag(shard, tag)

Associates a shard with a tag or identifier. MongoDB uses these identifiers to direct chunks that fall within a tagged range to specific shards. sh.addTagRange() associates chunk ranges with tag ranges.

Parameter Type Description
shard string The name of the shard to which to give a specific tag.
tag string The name of the tag to add to the shard.

Only issue sh.addShardTag() when connected to a mongos instance.

Example

The following example adds three tags, NYC, LAX, and NRT, to three shards:

sh.addShardTag("shard0000", "NYC")
sh.addShardTag("shard0001", "LAX")
sh.addShardTag("shard0002", "NRT")