How does MongoDB distribute data across a cluster

家住魔仙堡 提交于 2019-12-31 07:26:06

问题


I've read about sharding a collection in MongoDB. MongoDB lets me shard a collection explicitly by calling shardCollection method. There I can choose whether I want it to be rangely shareded or hashingly sharded.

My question is, what would happen if I didn't call the shardCollection method, and I had say 100 nodes?

Would MongoDB keep the collections intact and distribute them across the cluster?

Would MongoDB keep all the collections in a single node?

Do I completely not understand how this works?


回答1:


A database can have a mixture of sharded and unsharded collections. Sharded collections are partitioned and distributed across shards in the cluster. As at MongoDB 3.4, each database has a primary shard where the unsharded collections are stored. If your deployment has a number of databases this may result in some distribution of unsharded collections, but there is no balancing activity for unsharded data. For more information on expected behaviours, see the Sharding section in the MongoDB manual.

If you are interested in distribution of unsharded collections within a sharded database, there is a relevant feature request you can watch/upvote in the MongoDB issue tracker: SERVER-939: Ability to distribute collections in a single DB.



来源:https://stackoverflow.com/questions/43521192/how-does-mongodb-distribute-data-across-a-cluster

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!