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

sh.removeShardFromZone()(mongosh方法)

sh.removeShardFromZone(shard, zone)

删除区域和分片之间的关联。

重要

mongosh 方法

This page documents a mongosh method. 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 a mongos instance.

此方法可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

重要

M0 和 Flex 集群不支持此命令。有关更多信息,请参阅不支持的命令。

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().

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

删除区域和分片之间的关联会删除在分片上保持该区域覆盖数据块的约束。在下一个负载均衡器回合中,负载均衡器可能会迁移该区域之前覆盖的数据块。

有关迁移如何在分片集群中工作的更多信息,请参阅分片集群负载均衡器手册页面。

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

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

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

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

    或者,

  • 权限包括对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.

以下示例删除shard0000NYC区域之间的关联:

sh.removeShardFromZone("shard0000", "NYC")
给本页内容打分