mongodb分片_MongoDB中的分片

mongodb分片

MongoDB中的分片 (Sharding in MongoDB)

Sharding is the mechanism of storing data across multiple machines. The basic principle of this feature of MongoDB is to support the data growth which is expected any application. Because, at one point of time the accessibility of any application will definitely result in increase of the data growth and it would be difficult to accommodate such a growth of data.

分片是跨多台机器存储数据的机制。 MongoDB此功能的基本原理是支持任何应用程序期望的数据增长。 因为,在某个时间点,任何应用程序的可访问性肯定会导致数据增长,并且很难适应这种数据增长。

Considering the data growth which is really difficult to manage in a single system, it is an ideal way to have a cluster containing the replica set of the data. Hence, a horizontal scaling of the data is required and sharding does this in MongoDB. Sharding in simple just adds more machines to handle the sudden or rapid growth of data in an application.

考虑到实际上很难在单个系统中管理的数据增长,拥有包含数据副本集的集群是一种理想的方式。 因此,需要对数据进行水平缩放,而分片在MongoDB中完成。 简单分片只会增加更多机器来处理应用程序中数据的突然或快速增长。

Need for Sharding in MongoDB :

在MongoDB中需要分片:

  1. Vertical scaling is too scaling

    垂直缩放太缩放
  2. In data backup process all the data will be written to the master nodes.

    在数据备份过程中,所有数据将被写入主节点。
  3. Space in local disk may not be huge enough to handle the data growth.

    本地磁盘中的空间可能不足以处理数据增长。

The below figure shows the conceptual diagram of how the sharding works in a mongodb environment.

下图显示了在mongodb环境中分片如何工作的概念图。

mongodb分片_MongoDB中的分片



Let us see the details pertaining to the components shown in the above figure.

让我们看一下与上图中显示的组件有关的细节。

应用 (Application)

Application which is making use of the mongodb and needs to cluster the data across multiple servers.

正在使用mongodb且需要在多个服务器之间集群数据的应用程序。



碎片 (Shards)

Shards are used to store the actual data. In any production environment each shard will be a separate replica set.

分片用于存储实际数据。 在任何生产环境中,每个分片都是单独的副本集。



组态 (Configuration)

Configuration is nothing but the configured mongodb servers that stores the cluster's metadata. Basically these configuration servers contains mapping of the cluster's data set to the shards. The query router will chose the specific shard based on the metadata for any target operations. In any production environment there will be actually 3 configuration servers.

配置不过是配置好的存储集群元数据的mongodb服务器。 基本上,这些配置服务器包含集群数据集到分片的映射。 查询路由器将基于元数据为任何目标操作选择特定的分片。 在任何生产环境中,实际上将有3个配置服务器。

Refer to the below URL to refer to the detailed steps to configure the shared cluster from the mongodb docs official site:

请参考下面的URL,以从mongodb docs官方网站上参考配置共享集群的详细步骤:

https://docs.mongodb.com/v3.0/tutorial/deploy-shard-cluster/ https://docs.mongodb.com/v3.0/tutorial/deploy-shard-cluster/

翻译自: https://www.studytonight.com/mongodb/sharding-in-mongodb

mongodb分片