sh.removeTagRange()
定义
sh.removeTagRange(namespace, minimum, maximum)
注意
此方法的别名为
sh.removeRangeFromZone()
。 MongoDB提供区域分片作为标签感知分片的后继方案。Removes a specified shard tag from a defined range of shard key values.
sh.removeTagRange()
takes the following arguments:Parameter类型说明namespace
字符串
要标记的collection的命名空间。
minimum
文档
The minimum value of the 片键 from the tag. Specify the minimum value in the form of
<fieldname>:<value>
. This value must be of the same BSON type or types as the shard key.maximum
文档
The maximum value of the shard key range from the tag. Specify the maximum value in the form of
<fieldname>:<value>
. This value must be of the same BSON type or types as the shard key.使用
sh.removeTagRange()
to ensure that unused or out of date ranges are removed and hence chunks are balanced as required.仅在连接到
mongos
实例时运行
sh.removeTagRange()
。
兼容性
此方法可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0、M2、M5 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
例子
Given a shard key of {state: 1, zip: 1}
, the following operation
removes an existing tag range covering zip codes in New York State:
sh.removeTagRange( "exampledb.collection", { state: "NY", zip: MinKey }, { state: "NY", zip: MaxKey } )