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描述
namespacestring

The namespace of the sharded collection to associate with the zone.要与区域关联的分片集合的命名空间

The collection must be sharded for the operation to succeed.必须对集合进行分片,操作才能成功。

minimumdocument

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类型。

maximumdocument

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 a mongos 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数据库中的各个集合执行指定操作的用户:

    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(). clusterAdminclusterManager内置角色具有发出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. minmax必须精确匹配目标范围的边界。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()不会删除任何内容。

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()的最小值和最大值的精确匹配。

←  sh.removeTagRange()sh.help() →