On this page本页内容
A MongoDB sharded cluster consists of the following components:MongoDB分片集群由以下组件组成:
mongos
acts as a query router, providing an interface between client applications and the sharded cluster. mongos
充当查询路由器,在客户端应用程序和分片集群之间提供接口。mongos
can support hedged reads to minimize latencies.mongos
可以支持模糊读取以最小化延迟。In a production cluster, ensure that data is redundant and that your systems are highly available. 在生产集群中,确保数据是冗余的,并且系统是高可用的。Consider the following for a production sharded cluster deployment:对于生产分片集群部署,请考虑以下事项:
mongos
routersmongos
路由器Where possible, consider deploying one member of each replica set in a site suitable for being a disaster recovery location.如果可能,请考虑在适合作为灾难恢复位置的站点中部署每个副本集的一个成员。
Distributing replica set members across two data centers provides benefit over a single data center. 跨两个数据中心分发副本集成员比单个数据中心更具优势。In a two data center distribution,在两个数据中心的分布中,
If possible, distribute members across at least three data centers. For config server replica sets (CSRS), the best practice is to distribute across three (or more depending on the number of members) centers. 如果可能,将成员分布在至少三个数据中心。对于配置服务器副本集(CSR),最佳做法是跨三个(或更多,取决于成员数量)中心分发。If the cost of the third data center is prohibitive, one distribution possibility is to evenly distribute the data bearing members across the two data centers and store the remaining member in the cloud if your company policy allows.如果第三个数据中心的成本过高,一种分发可能性是在两个数据中心之间均匀地分发数据承载成员,并在公司政策允许的情况下将剩余成员存储在云中。
Sharding requires at least two shards to distribute sharded data. 分片需要至少两个分片来分发分片数据。Single shard sharded clusters may be useful if you plan on enabling sharding in the near future, but do not need to at the time of deployment.如果您计划在不久的将来启用分片,但在部署时不需要启用,那么单分片分片集群可能会很有用。
mongos
and Distributionmongos
的数量和分布Deploying multiple 部署多个mongos
routers supports high availability and scalability. mongos
路由器支持高可用性和可扩展性。A common pattern is to place a 一种常见的模式是在每个应用服务器上放置一个mongos
on each application server. mongos
。Deploying one 在每个应用服务器上部署一个mongos
router on each application server reduces network latency between the application and the router.mongos
路由器可以减少应用程序和路由器之间的网络延迟。
Alternatively, you can place a 或者,您可以将mongos
router on dedicated hosts. mongos
路由器放置在专用主机上。Large deployments benefit from this approach because it decouples the number of client application servers from the number of 大型部署受益于这种方法,因为它将客户机应用程序服务器的数量与mongos
instances. mongos
实例的数量分离。This gives greater control over the number of connections the 这样就可以更好地控制mongod
instances serve.mongod
实例所服务的连接数。
Installing 在自己的主机上安装mongos
instances on their own hosts allows these instances to use greater amounts of memory. mongos
实例可以让这些实例使用更多内存。Memory would not be shared with a 内存不会与mongod
instance. mongod
实例共享。It is possible to use primary shards to host 可以使用主分片来托管mongos
routers but be aware that memory contention may become an issue on large deployments.mongos
路由器,但请注意,在大型部署中,内存争用可能会成为一个问题。
There is no limit to the number of 部署中可以拥有的mongos
routers you can have in a deployment. mongos
路由器数量没有限制。However, as 但是,由于mongos
routers communicate frequently with your config servers, monitor config server performance closely as you increase the number of routers. mongos
路由器经常与配置服务器通信,因此在增加路由器数量时,应密切监视配置服务器的性能。If you see performance degradation, it may be beneficial to cap the number of 如果您发现性能下降,那么在部署中限制mongos
routers in your deployment.mongos
路由器的数量可能是有益的。
For testing and development, you can deploy a sharded cluster with a minimum number of components. 对于测试和开发,您可以使用最少数量的组件部署分片集群。These non-production clusters have the following components:这些非生产集群具有以下组件:
mongos
instance.mongos
的例子。Use the test cluster architecture for testing and development only.测试集群架构仅用于测试和开发。