Docs HomeMongoDB Manual

sh.removeShardFromZone()

On this page本页内容

Definition定义

sh.removeShardFromZone(shard, zone)

Removes the association between a zone and a shard.

Important

mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the removeShardFromZone command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

mongo shell v4.4

This method has the following parameters:此方法具有以下参数:

Parameter参数Type类型Description描述
shardstringThe name of the shard from which to remove the zone association. 要从中删除区域关联的分片的名称。
zonestringThe name of the zone whose association with the shard you want to remove. 与要删除的分片关联的区域的名称。

Only issue sh.removeShardFromZone() when connected to a mongos instance.仅在连接到mongos实例时发出sh.removeShardFromZone()

Behavior行为

sh.removeShardFromZone() does not remove ranges associated with the zone.不会删除与区域关联的范围。

To completely remove a zone from the cluster, you must run sh.removeShardFromZone() on each shard associated with the zone.要从集群中完全删除区域,必须对与该区域关联的每个分片运行sh.removeShardFromZone()

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().在运行sh.removeShardFromZone()之前,请使用updateZoneKeyRange删除与该区域关联的任何现有范围。

See the zone manual page for more information on zones in sharded clusters.有关分片集群中区域的更多信息,请参阅区域手册页面。

Balancer平衡器

Removing the association between a zone and a shard removes the constraints keeping chunks covered by the zone on the shard. 删除区域和分片之间的关联将删除分片上区域覆盖区块的约束。During the next balancer round, the balancer may migrate chunks that previously covered by the zone.在下一轮平衡器期间,平衡器可以迁移以前由区域覆盖的块。

See the sharded cluster balancer manual page for more information on how migrations work in a sharded cluster.有关迁移如何在分片集群中工作的更多信息,请参阅分片集群平衡器手册页面。

Security安全

For sharded clusters that enforce access control, you must authenticate either as:对于强制访问控制的分片集群,您必须按照以下方式之一进行身份验证:

  • a user whose privileges include:其权限包括:

    • update on the shards collection in the config database, andconfig数据库中的shards集合上的update,以及
    • find on the tags collection in the config database;config数据库中的tags集合上的find

    or, alternatively,或者,

  • a user whose privileges include enableSharding on the cluster resource (available starting in version 4.2.2, 4.0.14, 3.6.16).其权限包括在集群资源上启用分片的用户(从版本4.2.2、4.0.14、3.6.16开始可用)。

The clusterAdmin or clusterManager built-in roles have the appropriate permissions for issuing sh.removeShardFromZone(). clusterAdminclusterManager内置角色具有发出sh.removeShardFromZone()的适当权限。See the Role-Based Access Control manual page for more information.有关详细信息,请参阅基于角色的访问控制手册页面。

Example实例

The following example removes the association between shard0000 and the NYC zone:以下示例删除shard0000NYC区域之间的关联:

sh.removeShardFromZone("shard0000", "NYC")