Database Manual / Reference / Database Commands

Sharding Commands

Note

For details on a specific command, including syntax and examples, click on the link to the command's reference page.

NameDescription

abortMoveCollection

Stops an in-progress moveCollection operation.

New in version 8.0.

abortReshardCollection

Aborts a resharding operation.

New in version 5.0.

abortUnshardCollection

Stops an in-progress unshardCollection operation.

New in version 8.0.

addShard

Adds a shard to a sharded cluster.

addShardToZone

Associates a shard with a zone. Supports configuring zones in sharded clusters.

analyzeShardKey

Calculates metrics for evaluating a shard key.

New in version 7.0.

balancerCollectionStatus

Returns information on whether the chunks of a sharded collection are balanced.

balancerStart

Starts a balancer thread.

balancerStatus

Returns information on the balancer status.

balancerStop

Stops the balancer thread.

checkMetadataConsistency

Performs a series of consistency checks on sharding metadata.

New in version 7.0.

clearJumboFlag

Clears the jumbo flag for a chunk.

cleanupReshardCollection

Cleans up a failed resharding operation.

New in version 5.0.

commitReshardCollection

Forces a resharding operation to block writes and complete.

New in version 5.0.

configureCollectionBalancing

Configures balancer settings on a sharded collection.

New in version 5.3.

configureQueryAnalyzer

Configures query sampling for a collection.

New in version 7.0.

enableSharding

Creates a database.

flushRouterConfig

Forces a mongod / mongos instance to update its cached routing metadata.

getShardMap

Returns the hostnames and connection strings for shards in the cluster and the config servers for your cluster.

isdbgrid

Verifies that a process is a mongos.

listShards

Returns a list of configured shards.

moveChunk

Internal command that migrates chunks between shards.

movePrimary

Reassigns the primary shard when removing a shard from a sharded cluster.

moveRange

Migrates ranges between shards.

mergeAllChunksOnShard

Squashes mergeable chunks for a given collection on a shard.

mergeChunks

Provides the ability to combine chunks on a single shard.

refineCollectionShardKey

Refines a collection's shard key by adding a suffix to the existing key.

removeShard

Starts the process of removing a shard from a sharded cluster.

removeShardFromZone

Removes the association between a shard and a zone. Supports configuring zones in sharded clusters.

reshardCollection

Initiates a resharding operation to change the shard key for a collection, changing the distribution of your data.

New in version 5.0.

setAllowMigrations

Prevents the start of new automatic migrations on a collection, prevents in-flight manual migrations from committing, and excludes the collection from new balancer rounds.

shardCollection

Enables the sharding functionality for a collection, allowing the collection to be sharded.

shardingState

Reports whether the mongod is a member of a sharded cluster.

split

Creates a new chunk.

transitionFromDedicatedConfigServer

Configures a dedicated config server to run as a config shard.

New in version 8.0.

transitionToDedicatedConfigServer

Configures a config shard to run as a dedicated config server.

New in version 8.0.

unsetSharding

Removed in MongoDB 5.0. Internal command that affects connections between instances in a MongoDB deployment.

unshardCollection

Unshards an existing sharded collection and moves the collection data onto a single shard. When you unshard a collection, the collection cannot be partitioned across multiple shards and the shard key is removed.

New in version 8.0.

updateZoneKeyRange

Adds or removes the association between a range of sharded data and a zone. Supports configuring zones in sharded clusters.