removeShardFromZone

On this page本页内容

Definition定义

removeShardFromZone

The removeShardFromZone administrative command removes the association between a shard and a zone.removeShardFromZone管理命令删除分片和区域之间的关联。

Syntax语法

You can only run removeShardFromZone on the admin database from a mongos instance.只能从mongos实例在admin数据库上运行removeShardFromZone

The removeShardFromZone command has the following syntax:removeShardFromZone命令具有以下语法:

db.adminCommand(
   {
     removeShardFromZone: <string>,
     zone: <string>
   }
)

The command takes the following fields:该命令接受以下字段:

Field字段Type类型Description描述
removeShardFromZonestring

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.与要删除的分片关联的区域的名称。

mongosh provides the helper method sh.removeShardFromZone().提供了助手方法sh.removeShardFromZone()

Behavior行为

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

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

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

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

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 removeShardFromZone. clusterAdminclusterManager内置角色具有发出removeShardFromZone的相应权限。See the Role-Based Access Control manual page for more information.有关详细信息,请参阅基于角色的访问控制手册页面。

Example示例

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

db.adminCommand( { removeShardFromZone : "shard0000" , zone : "NYC" } )
←  removeShardreshardCollection →