sh.removeRangeFromZone()
On this page本页内容
Definition定义
sh.removeRangeFromZone(namespace, minimum, maximum)
-
Removes the association between a range of shard key values and a zone.删除一系列分片键值和区域之间的关联。sh.removeRangeFromZone()
takes the following arguments:采用以下参数:Parameter参数Type类型Description描述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以<fieldname> : <value>
.<fieldname> : <value>
的形式指定分片键的每个字段。The value must be of the same BSON type or types as the shard key.该值必须与分片键具有相同的BSON类型。maximum
document The exclusive upper bound of the range of shard key values.分片键值范围的独占上限。
Specify each field of the shard key in the form of以<fieldname> : <value>
.<fieldname> : <value>
的形式指定分片键的每个字段。The value must be of the same BSON type or types as the shard key.该值必须与分片键具有相同的BSON类型。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 amongos
instance.mongos
实例时发出sh.removeTagRange()
。
Behavior行为
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.有关分片集群中区域的更多信息,请参阅区域手册页面。
Balancer平衡器
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.有关迁移如何在分片集群中工作的更多信息,请参阅分片集群均衡器的文档。
Security安全
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 theconfig.shards
collectionconfig.shards
集合上的find
find
,update
, andremove
on theconfig.tags
collection;config.tags
集合上的find
、update
和remove
;
or, alternatively或者a user whose privileges include其权限包括在集群资源上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.有关详细信息,请参阅基于角色的访问控制的文档页。
Example实例
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 }
指定为min
绑定:
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()
不会删除任何内容。
Compound Shard Key复合分片键
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()
的最小值和最大值不完全匹配。