- 分片 >
- 集群组件
集群组件¶
On this page
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.元信息存储了 数据块 对分片的映射,参见 配置服务器.获得更多信息.
- Deploy Config Servers as a 3 member replica set
- Deploy each Shard as a 3 member replica set
- Deploy one or more mongos routers
每个路由都是 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.

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:
- A replica set config server with one member.
- At least one shard as a single-member replica set.
- One mongos instance.

警告
Use the test cluster architecture for testing and development only.
参见