对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

removeShardFromZone(数据库命令)

removeShardFromZone

The removeShardFromZone administrative command removes the association between a shard and a zone.

提示

In mongosh, this command can also be run through the sh.removeShardFromZone() helper method.

Helper methods are convenient for mongosh users, 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 部署的完全托管服务

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.

有关分片集群中区域的更多信息,请参阅区域手册页面。

对于强制执行访问控制的分片集群,您必须通过以下方式之一进行身份验证:

  • 权限包括以下内容的用户:

    • 针对updateconfig数据库的shardscollection,以及

    • 针对find config数据库中的tagscollection的 ;

    或者,或者,

  • 权限包括对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" } )