翻译或纠错本页面

集群组件

A MongoDB sharded cluster consists of the following components:

  • shard: Each shard contains a subset of the sharded data. Each shard can be deployed as a replica set.
  • 分片是存储了一个集合部分数据的MongoDB实例,每个分片是单独的 mongod 或者是 replica set .在生产环境中,所有的分片都应该是复制集.参见 分片 获得更多信息.

  • config servers: Config servers store metadata and configuration settings for the cluster. As of MongoDB 3.4, config servers must be deployed as a replica set (CSRS).

Production Configuration

每个:ref:配置服务器 <sharding-config-server>`都是存储了集群元信息的 :program:`mongod.元信息存储了 数据块 对分片的映射,参见 配置服务器.获得更多信息.

每个路由都是 mongos ,它将读写请求分发到分片中.应用并不直接访问分片.参见 mongos 获得更多信息.

MongoDB中分片的基本单位是集合,对每个开启了分片的集合,都可以设置一个 shard key .

You can deploy a mongos router on each application server to ensure each server has consistent access to the sharded cluster. Alternatively, deploy a group of mongos routers and use a proxy or load balancer between the application and the mongos group. In these deployments, you must configure the load balancer for client affinity such that every connection from a single client reaches the same mongos.

Diagram of a sample sharded cluster for production purposes.  Contains exactly 3 config servers, 2 or more ``mongos`` query routers, and at least 2 shards. The shards are replica sets.

Development Configuration

For testing and development, you can deploy a sharded cluster with a minimum number of components. These non-production clusters have the following components:

Diagram of a sample sharded cluster for testing/development purposes only.  Contains only 1 config server, 1 ``mongos`` router, and at least 1 shard. The shard can be either a replica set or a standalone ``mongod`` instance.

警告

Use the test cluster architecture for testing and development only.

←   分片 分片  →