在 MongoDB 中分片而不复制

Sharding In MongoDB without Replication

我想在 mongodb 中部署分片。而我只有 3 Ubuntu 个服务器。是否可以使用 3 个服务器(1 个用于配置,2 个用于分片)?

让我引用你能找到的内容 here

Sharding is the only solution for some classes of deployments. Use sharded clusters if:

  • your data set approaches or exceeds the storage capacity of a single MongoDB instance.
  • the size of your system’s active working set will soon exceed the capacity of your system’s maximum RAM.
  • a single MongoDB instance cannot meet the demands of your write operations, and all other approaches have not reduced contention.

If these attributes are not present in your system, sharding will only add complexity to your system without adding much benefit.


如果您想将分片用于学习或测试目的,那么您可以使用 minimal sharded clusters cluster

你需要

  • 一个配置服务器
  • 一个路由器(mongos 实例)
  • 1 个或更多分片

所以在你的情况下这并不容易,因为你想要有 2 个分片。所以你需要 4 台服务器。

不过,也许你可以尝试将配置和路由器放在同一台机器上。