enableSharding
enableSharding
- The
enableSharding
command enables sharding on a per-databaselevel. TheenableSharding
command has the following syntax:
- { enableSharding: "<database name>" }
To run enableSharding
, use the db.runCommand( { <command> } )
method.
To run enableSharding
, connect to a mongos
instance and run the command in the admin
database.
mongos
uses"majority"
for theenableSharding
command and its helpersh.enableSharding()
.
Returns:A document that contains status of the operation.
Once you enabled sharding in a database, you can use theshardCollection
command to begin the process ofdistributing data among the shards.