I Wrote
db.runCommand({enablesharding : "database"})
db.runCommand({shardcollection : "database.coll_1",key : {_id :"hashed"}})
And how to check is collection sahrded or not? Maybe exist some function that I do not know. Plese help me!
I Use the following :
use dbname
db.colname.getShardDistribution()
Outputs the sharding distribution if it's sharded, and Collection dbname.colname is not sharded
if it's not.
Check this for more details.
I also use @Scott's comment aswell (use databaseName; db.collectionName.stats().sharded
) but i prefer the getShardDistribution
, it's cleaner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With