On this page本页内容
sh.removeRangeFromZone(namespace, minimum, maximum)
Removes the association between a range of shard key values and a zone.删除分片键值范围和区域之间的关联。
sh.removeRangeFromZone()
takes the following arguments:采用以下参数:
namespace | string |
|
minimum | document |
|
maximum | document |
|
Use 使用sh.removeRangeFromZone()
to remove the association between unused, out of date, or conflicting ranges and a zone.sh.removeRangeFromZone()
删除未使用、过期或冲突范围与区域之间的关联。
If no range matches the minimum and maximum bounds passed to 如果没有范围与传递给removeShardFromZone()
, nothing is removed.removeShardFromZone()
的最小和最大边界匹配,则不会删除任何内容。
Only issue 仅在连接到sh.removeTagRange()
when connected to a mongos
instance.mongos
实例时发出sh.removeTagRange()
。
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:对于使用身份验证运行的分片群集,必须使用以下身份验证:
a user whose privileges include the specified actions on various collections in the 其权限包括对config
database:config
数据库中的各个集合执行指定操作的用户:
find
on the config.shards
collectionconfig.shards
集合中查找find
, update
, and remove
on the config.tags
collection;config.tags
集合中查找、更新和删除;or, alternatively或者,作为替代
enableSharding
on the cluster resource (available starting in version 4.2.2, 4.0.14, 3.6.16).enableSharding
的用户(从版本4.2.2、4.0.14、3.6.16开始可用)。The clusterAdmin
or clusterManager
built-in roles have the appropriate permissions for issuing sh.removeRangeFromZone()
. clusterAdmin
或clusterManager
内置角色具有发出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
:exampledb.collection
,其分片键为{a:1}
,以下操作将删除下限为1
、上限为10
的范围:
sh.removeRangeFromZone( "exampledb.collection", { a : 1 }, { a : 10 } )
The min
and max
must match exactly the bounds of the target range. min
和max
必须精确匹配目标范围的边界。The following operation attempts to remove the previously created range, but specifies 以下操作尝试删除以前创建的范围,但将{ a : 0 }
as the min
bound:{a:0}
指定为最小界限:
admin = db.getSiblingDB("admin") admin.runCommand( { updateZoneKeyRange : "exampledb.collection", min : { a : 0 }, max : { a : 10 }, zone : null } )
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.{a:0}
和{a:10}
的范围包含现有范围,但它不是完全匹配的,因此sh.removeRangeFromZone()
不会删除任何内容。
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 }
:exampledb.collection
,其分片键为{a:1, b:1}
,以下操作将删除下限为{a:1, b:1}
、上限为{a:10, b:10}
的范围:
sh.removeRangeFromZone( "exampledb.collection", { a : 1, b : 1 }, { 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()
.{a:1,b:5}
、上限为{a:10,b:1}
的现有范围,则操作不会删除该范围,因为它不是传递给sh.removeRangeFromZone()
的最小值和最大值的精确匹配。