New in version 3.4: Associates a shard with a zone. MongoDB associates this shard with the given zone. Chunks that are covered by the zone are assigned to shards associated with the zone.
Parameter Type Description
string The name of the shard to which to associate the
string The name of the zone to associate with the
sh.addShardToZone()when connected to a
You can associate a zone with multiple shards, and a shard can associate with multiple zones.
See the zone manual page for more information on zones in sharded clusters.
The following example adds three zones,
associating each to a shard:
sh.addShardToZone("shard0000", "JFK") sh.addShardToZone("shard0001", "LAX") sh.addShardToZone("shard0002", "NRT")
A shard can associate with multiple zones. The following example associates
shard0000 associates with both the
LGA zone and the
JFK zone. In a
balanced cluster, MongoDB routes reads and writes covered by either zone to