定义
sh.removeShardFromZone(shard, zone)删除区域和分片之间的关联。
重要
mongosh 方法
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.有关数据库命令,请参阅
removeShardFromZone命令。如需了解 MongoDB API 驱动程序,请参阅特定语言的 MongoDB 驱动程序文档。
此方法具有以下参数:
Parameter类型说明字符串
The name of the shard from which to remove the zone association.
字符串
The name of the zone whose association with the shard you want to remove.
Only issue
sh.removeShardFromZone()when connected to amongosinstance.
兼容性
此方法可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
重要
M0 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
行为
sh.removeShardFromZone() 不会删除与区域关联的范围。
To completely remove a zone from the cluster, you must run sh.removeShardFromZone() on each shard associated with the zone.
If the shard specified is the last shard associated with the zone, you must ensure there are no remaining ranges associated with the zone. Use updateZoneKeyRange to remove any existing ranges associated to the zone before running sh.removeShardFromZone().
有关分片集群中区域的更多信息,请参阅区域手册页面。
平衡器
删除区域和分片之间的关联会删除在分片上保持该区域覆盖数据块的约束。在下一个负载均衡器回合中,负载均衡器可能会迁移该区域之前覆盖的数据块。
有关迁移如何在分片集群中工作的更多信息,请参阅分片集群负载均衡器手册页面。
安全性
对于强制执行访问控制的分片集群,您必须通过以下方式之一进行身份验证:
权限包括对
enableSharding集群 资源的 的用户。
The clusterAdmin or clusterManager built-in roles have the appropriate permissions for issuing sh.removeShardFromZone(). See the Role-Based Access Control manual page for more information.
例子
以下示例删除shard0000和NYC区域之间的关联:
sh.removeShardFromZone("shard0000", "NYC")