sh.removeShardFromZone()
On this page
Definition
sh.removeShardFromZone(shard, zone)
Removes the association between a zone and a shard.
Important
mongosh Method
This page documents a
mongosh
method. This is not the documentation for database commands or language-specific drivers, such as Node.js.For the database command, see the
removeShardFromZone
command.For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.
For the legacy
mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release:This method has the following parameters:
ParameterTypeDescriptionstringThe name of the shard from which to remove the zone association.
stringThe name of the zone whose association with the shard you want to remove.
Only issue
sh.removeShardFromZone()
when connected to amongos
instance.
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.
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()
.
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 theshards
collection in theconfig
database, andfind
on thetags
collection in theconfig
database;
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).
The clusterAdmin
or clusterManager
built-in roles have
the appropriate permissions for issuing 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:
sh.removeShardFromZone("shard0000", "NYC")