- Reference >
- Database Commands >
- Sharding Commands >
- removeShardFromZone
removeShardFromZone¶
On this page
Definition¶
-
removeShardFromZone¶ New in version 3.4.
The
removeShardFromZoneadministrative command removes the association between a shard and a zone.To run
removeShardFromZone, use thedb.runCommand( { <command> } )method.You must run
removeShardFromZoneon the admin database.The
removeShardFromZonecommand has the following syntax:The command takes the following fields:
Field Type Description removeShardFromZonestring The name of the shard from which to remove association with the zone.zonestring The name of the zone from which to remove association with the shard.Only issue
removeShardFromZonewhen connected to amongosinstance.The
mongoshell provides the helper methodsh.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.
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.
See the zone manual page for more information on zones in sharded clusters.
Security¶
For sharded clusters running with authentication, you must authenticate as a user whose privileges include:
updateon theconfig.shardscollection or theconfigdatabasefindon theconfig.tagscollection or theconfigdatabase
The clusterAdmin or clusterManager built-in roles have
the appropriate permissions for issuing removeShardFromZone. See
the Role-Based Access Control manual page for more
information.
Example¶
The following example removes the association between shard0000 and zone
NYC: