removeShardFromZone
Definition
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:
- {
- removeShardFromZone: <string>,
- zone: <string>
- }
The command takes the following fields:
FieldTypeDescriptionremoveShardFromZone
stringThe name of the shard from which to remove association with the zone
.zone
stringThe 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 theconfig.shards
collection or theconfig
databasefind
on theconfig.tags
collection or theconfig
database
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
:
- admin = db.getSiblingDB("admin")
- admin.runCommand( { removeShardFromZone : "shard0000" , zone : "NYC" } )