removeShardFromZone

Definition

  • removeShardFromZone

New in version 3.4.

The removeShardFromZone administrative command removes theassociation between a shard and a zone.

To run removeShardFromZone, use the db.runCommand( { <command> } ) method.

You must run removeShardFromZone on the admin database.

The removeShardFromZone command has the following syntax:

  1. {
  2. removeShardFromZone: <string>,
  3. zone: <string>
  4. }

The command takes the following fields:

FieldTypeDescriptionremoveShardFromZonestringThe name of the shard from which to remove association with the zone.zonestringThe name of the zone from which to remove association with the shard.

Only issue removeShardFromZone when connected to amongos instance.

The mongo shell provides the helper methodsh.removeShardFromZone()

Behavior

removeShardFromZone does not remove ranges associated with thezone.

To completely remove a zone from the cluster, you must runremoveShardFromZone on each shard associated with the zone.

If the shard specified is the last shard associated with the zone, you mustensure there are no remaining shard key ranges associated with the zone. UseupdateZoneKeyRange to remove any existing ranges associated withthe zone before running removeShardFromZone.

See the zone manual page for more information on zonesin sharded clusters.

Security

For sharded clusters running with authentication, youmust authenticate as a user whose privileges include:

  • update on the config.shards collection or the configdatabase
  • find on the config.tags collection or the configdatabase

The clusterAdmin or clusterManager built-in roles havethe appropriate permissions for issuing removeShardFromZone. Seethe Role-Based Access Control manual page for moreinformation.

Example

The following example removes the association between shard0000 and zoneNYC:

  1. admin = db.getSiblingDB("admin")
  2. admin.runCommand( { removeShardFromZone : "shard0000" , zone : "NYC" } )