mongodb 分片集群可以只有一个分片吗?

Can a mongodb shard cluster have just one shard?

从技术上讲,是否支持从一个分片集群开始只有一个分片?所以我们可以随时准备添加额外的分片,同时在我们真正需要之前节省额外分片的成本?

更进一步,是否可以在一个实例上有一个分片 运行,而不必基于 3 个实例的副本集?

here 开始,分片为:

A database architecture that partitions data by key ranges and distributes the data among two or more database instances.

当您需要扩展时,分片将成为 replica set or a standalone mongod instance. It is possible for you to use a single machine by using different ports to establish distinct communication endpoints for the config, mongod and mongos processes on the single machine. Also, yes, you may add a shard

然而,提供分片的目的是为了支持水平缩放。此外,分片集群的要点是提供故障转移和冗余支持。通过在单个服务器上使用单个分片,您将失去扩展和故障转移的好处。

recommended production architecture包括:

  1. 每个分片集群在不同机器上的三个配置服务器。
  2. 两个或多个副本集作为分片。
  3. 一个或多个查询路由器(mongos);通常,每个应用程序服务器一个 mongos 实例。

仔细阅读文档中的 Sharded Cluster Requirements 部分,了解您的环境是否需要分片和分片集群,因为建立这样的架构很复杂。