sh.removeShardFromZone()

On this page本页内容

Definition定义

sh.removeShardFromZone(shard, zone)

Removes the association between a zone and a shard.删除分区和分片之间的关联。

Parameter参数Type类型Description描述
shardstring

The name of the shard from which to remove the zone association.要从中删除区域关联的分片的名称。

zonestring

The 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, and更新config数据库中的shards集合,以及
    • find on the tags collection in the config database;config数据库中的tags集合中查找

    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).其权限包括在群集资源上enableSharding用户(从版本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")
←  sh.removeShardTag()sh.reshardCollection() →