定义
removeShardFromZoneThe
removeShardFromZoneadministrative command removes the association between a shard and a zone.提示
In
mongosh, this command can also be run through thesh.removeShardFromZone()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
You can only run removeShardFromZone on the admin database from a mongos instance.
该命令具有以下语法:
db.adminCommand( { removeShardFromZone: <string>, zone: <string> } )
命令字段
该命令接受以下字段:
字段 | 类型 | 说明 |
|---|---|---|
字符串 | 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. |
mongosh provides the helper method sh.removeShardFromZone().
行为
removeShardFromZone 不会删除与区域关联的范围。
To completely remove a zone from the cluster, you must run 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 shard key ranges associated with the zone. Use updateZoneKeyRange to remove any existing ranges associated with the zone before running removeShardFromZone.
有关分片集群中区域的更多信息,请参阅区域手册页面。
安全性
对于强制执行访问控制的分片集群,您必须通过以下方式之一进行身份验证:
权限包括对
enableSharding集群 资源的 的用户。
The clusterAdmin or clusterManager built-in roles have the appropriate permissions for issuing removeShardFromZone. See the Role-Based Access Control manual page for more information.
例子
以下示例删除shard0000和区域NYC之间的关联:
db.adminCommand( { removeShardFromZone : "shard0000" , zone : "NYC" } )