Docs HomeMongoDB Manual

sh.removeTagRange()

On this page本页内容

Definition定义

sh.removeTagRange(namespace, minimum, maximum, tag)

Changed in version 3.4.3.4版更改。This method aliases to sh.removeRangeFromZone() in MongoDB 3.4. 此方法别名为MongoDB 3.4中的sh.removeRangeFromZone()The functionality specified below still applies to MongoDB 3.2. MongoDB 3.4 provides Zone sharding as the successor to tag-aware sharding.下面指定的功能仍然适用于MongoDB 3.2。MongoDB 3.4提供了区域分片作为标记感知分片的继承。

Removes a specified shard tag from a defined range of shard key values. 从定义的分片键值范围中删除指定的分片标记。sh.removeTagRange() takes the following arguments:采用以下参数:

Parameter参数Type类型Description描述
namespacestringThe namespace of the sharded collection to tag.要标记的分片集合的命名空间
minimumdocumentThe minimum value of the shard key from the tag. 标记中分片键的最小值。Specify the minimum value in the form of <fieldname>:<value>. <fieldname>:<value>的形式指定最小值。 This value must be of the same BSON type or types as the shard key.该值必须与分片键具有相同的BSON类型。
maximumdocumentThe maximum value of the shard key range from the tag. 从标记开始的分片关键帧范围的最大值。Specify the maximum value in the form of <fieldname>:<value>. <fieldname>:<value>的形式指定最大值。This value must be of the same BSON type or types as the shard key.该值必须与分片键具有相同的BSON类型。
tagstringThe name of the tag attached to the range specified by the minimum and maximum arguments to.附加到的minimummaximum参数指定的范围的标记的名称。

Use sh.removeShardTag() to ensure that unused or out of date ranges are removed and hence chunks are balanced as required.使用sh.removeShardTag()确保删除未使用或过期的范围,从而根据需要平衡块。

Only issue sh.removeTagRange() when connected to a mongos instance.仅在连接到mongos实例时发出sh.removeTagRange()

Example实例

Given a shard key of {state: 1, zip: 1}, the following operation removes an existing tag range covering zip codes in New York State:给定{state: 1, zip: 1}的分片键,以下操作将删除覆盖纽约州邮政编码的现有标记范围:

sh.removeTagRange( "exampledb.collection",
{ state: "NY", zip: MinKey },
{ state: "NY", zip: MaxKey },
"NY"
)