MongoDB如何在整个集群中分配数据 [英] How does MongoDB distribute data across a cluster
问题描述
我已经读过有关在MongoDB中分片集合的信息. MongoDB让我可以通过调用shardCollection
方法显式地分片集合.在这里,我可以选择是否要对其进行远程共享或哈希分片.
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.
我的问题是,如果我不调用shardCollection
方法并且说100个节点,将会发生什么?
My question is, what would happen if I didn't call the shardCollection
method, and I had say 100 nodes?
MongoDB是否可以使集合完整无缺,并在整个集群中分布它们?
Would MongoDB keep the collections intact and distribute them across the cluster?
MongoDB会将所有集合保存在一个节点中吗?
Would MongoDB keep all the collections in a single node?
我完全不了解它是如何工作的吗?
Do I completely not understand how this works?
推荐答案
数据库可以包含分片和未分片集合的混合.分片集合在群集中的分片之间进行分区和分布.与MongoDB 3.4一样,每个数据库都有一个主分片,存储未分片的集合.如果您的部署中有许多数据库,这可能会导致未分片集合的某种分布,但是没有分片数据的平衡活动.有关预期行为的更多信息,请参阅MongoDB手册中的共享部分.
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.
如果您对在分片数据库中分配未分片的集合感兴趣,可以在MongoDB问题跟踪器中观看/更新相关的功能请求:
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.
这篇关于MongoDB如何在整个集群中分配数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!