On this page本页内容
sh.
removeRangeFromZone
(namespace, minimum, maximum)¶New in version 3.4.版本3.4中的新功能。
Removes the association between a range of shard key values and a zone.
sh.removeRangeFromZone()
takes the following arguments:
namespace |
string | The namespace of the sharded collection to associate with the zone. The collection must be sharded for the operation to succeed. |
minimum |
document | The inclusive lower bound of the range of shard key values. Specify each field of the shard key in the form of |
maximum |
document | The exclusive upper bound of the range of shard key values. Specify each field of the shard key in the form of |
Use sh.removeRangeFromZone()
to remove the association between unused, out of date, or conflicting ranges and a zone.
If no range matches the minimum and maximum bounds passed to removeShardFromZone()
, nothing is removed.
Only issue sh.removeTagRange()
when connected to a mongos
instance.
sh.removeShardFromZone()
does not remove the zone associated to the specified range.
See the zone manual page for more information on zones in sharded clusters.
Removing the association between a range and a zone removes the constraints keeping chunks covered by the range on the shards inside that zone. During the next balancer round, the balancer may migrate chunks that were previously covered by the zone.
See the documentation for the sharded cluster balancer for more information on how migrations work in a sharded cluster.
For sharded clusters running with authentication, you must authenticate as either:
config
database:
or, alternatively
enableSharding
on the cluster resource (available starting in version 4.2.2, 4.0.14, 3.6.16).The clusterAdmin
or clusterManager
built-in roles have the appropriate permissions for issuing sh.removeRangeFromZone()
. See the documentation page for Role-Based Access Control for more information.
Given a sharded collection exampledb.collection
with a shard key of { a : 1 }
, the following operation removes the range with a lower bound of 1
and an upper bound of 10
:
The min
and max
must match exactly the bounds of the target range. The following operation attempts to remove the previously created range, but specifies { a : 0 }
as the min
bound:
While the range of { a : 0 }
and { a : 10 }
encompasses the existing range, it is not an exact match and therefore sh.removeRangeFromZone()
does not remove anything.
Given a sharded collection exampledb.collection
with a shard key of { a : 1, b : 1 }
, the following operation removes the range with a lower bound of { a : 1, b : 1}
and an upper bound of { a : 10, b : 10 }
:
Given the previous example, if there was an existing range with a lower bound of { a : 1, b : 5 }
and an upper bound of { a : 10, b : 1 }
, the operation would not remove that range, as it is not an exact match of the minimum and maximum passed to sh.removeRangeFromZone()
.