Docs Menu

Sharding Reference

Name
Description

Returns the hashed value for the input.

Checks the cluster or database for inconsistent sharding metadata.

New in version 7.0.

Checks the collection for inconsistent sharding metadata.

New in version 7.0.

Stops an in-progress moveCollection operation.

New in version 8.0.

Aborts a resharding operation.

New in version 5.0.

Adds a shard to a sharded cluster.

This method aliases to sh.addShardToZone().

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

This method aliases to sh.updateZoneKeyRange().

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

Checks the cluster for inconsistent sharding metadata.

New in version 7.0.

Forces a resharding operation to block writes and complete.

New in version 5.0.

Disables automatic chunk merges for a namespace.

New in version 7.0.

Disables auto-splitting for the sharded cluster.

Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation.

Disable balancing on a single collection in a sharded database. Does not affect balancing of other collections in a sharded cluster.

Enables automatic chunk merges for a namespace.

New in version 7.0.

Enables auto-splitting for the sharded cluster.

Starting in MongoDB 6.0.3, automatic chunk splitting is not performed. This is because of balancing policy improvements. Auto-splitting commands still exist, but do not perform an operation.

Activates the sharded collection balancer process if previously disabled using sh.disableBalancing().

Creates a database.

Returns a boolean to report if the balancer is currently enabled.

Returns data distribution information for sharded collections. sh.getShardedDataDistribution() is a shell helper method for the $shardedDataDistribution aggregation pipeline stage.

Returns help text for the sh methods.

Returns a document describing the status of the balancer.

Returns whether a cluster has a config shard. If it does, sh.isConfigShardEnabled() also returns host and tag information.

Returns an array of documents describing the shards in a sharded cluster.

Migrates a chunk in a sharded cluster.

Moves a single unsharded collection to a different shard.

Removes an association between a range of shard keys and a zone. Supports configuring zones in sharded clusters.

This method aliases to sh.removeShardFromZone().

Removes the association between a shard and a zone. Use to manage zone sharding.

This method aliases to sh.removeRangeFromZone().

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

New in version 5.0.

Enables or disables the balancer which migrates chunks between shards.

Shards a collection and immediately redistributes the data using the provided shard key.

New in version 8.0.

Enables sharding for a collection.

Divides an existing chunk into two chunks using a specific value of the shard key as the dividing point.

Divides an existing chunk that contains a document matching a query into two approximately equal chunks.

Enables the AutoMerger.

New in version 7.0.

Enables the balancer and waits for balancing to start.

Reports on the status of a sharded cluster, as db.printShardingStatus().

Disables the AutoMerger.

New in version 7.0.

Disables the balancer and waits for any in progress balancing rounds to complete.

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.

Associates a range of shard keys to a zone. Supports configuring zones in sharded clusters.

Internal. Waits for the balancer state to change.

Internal. Waits until the balancer stops running.

Internal. Waits for a change in ping state from one of the mongos in the sharded cluster.

The following database commands support sharded clusters.

Name
Description

Stops an in-progress moveCollection operation.

New in version 8.0.

Aborts a resharding operation.

New in version 5.0.

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

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

Starts a balancer thread.

Returns information on the balancer status.

Stops the balancer thread.

Clears the jumbo flag for a chunk.

Cleans up a failed resharding operation.

New in version 5.0.

Forces a resharding operation to block writes and complete.

New in version 5.0.

Enables sharding on a specific database.

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

Internal command that reports on the state of a sharded cluster.

Verifies that a process is a mongos.

Returns a list of configured shards.

Internal command that migrates chunks between shards.

Moves a single unsharded collection to a different shard.

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

Command that migrates ranges between shards.

Provides the ability to combine chunks on a single shard.

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

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

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

New in version 5.0.

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

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

Creates a new chunk.

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

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

Operational Restrictions
Requirement for deploying a sharded cluster
Troubleshoot Sharded Clusters
Common strategies for troubleshooting sharded cluster deployments.
Config Database
Complete documentation of the content of the local database that MongoDB uses to store sharded cluster metadata.