If we add any new data/collection to the existing(running) shard cluster. Is there any way that the data/collection gets sharded automatically.
If yes, How to achieve that?.
MongoDB: enable sharding automatically
mongodbsharding
Related Question
- Mongodb sharding – set shard size
- Mongodb – How to enable sharding for all databases/collections by default
- MongoDB – sharding an collection with data already in it
- MongoDB sharding multiple collections with the same shard key
- Mongodb – Sharding standalone MongoDB
- Mongodb – Config enable sharding collection in MongoDB cluster
Best Answer
No it is not possible to automatically shard the collection. This is what you have to do per collection.
Ref:
You will need to run
shardCollection
command in order to shard a new collection. The collection must have an index whose prefix is the shard key. The following operation enables sharding for the people collection in the records database and uses the zipcode field as the shard key:A database can have a mixture of sharded and unsharded collections. Sharded collections are partitioned and distributed across the shards in the cluster. Unsharded collections are stored on a primary shard. Each database has its own primary shard.