Database Manual / Sharding / Data Partitioning

Moveable Collections可移动集合

New in version 8.0.在版本8.0中新增。

Starting in MongoDB 8.0, you can move an unsharded collection to a different shard using the moveCollection command.从MongoDB 8.0开始,您可以使用moveCollection命令将未分片的集合移动到其他分片。

Use Cases用例

Moving unsharded collections to any shard can:将未分片的集合移动到任何分片可以:

  • Optimize performance on larger, complex workloads.优化更大、更复杂工作负载的性能。
  • Achieve better resource utilization.实现更好的资源利用。
  • More evenly distribute data across shards.在分片之间更均匀地分布数据。

Consider the following scenarios:考虑以下情况:

  • A company runs an e-commerce platform with several unsharded collections, such as products, orders, and users on a single shard. 一家公司运营着一个电子商务平台,在单个分片上有几个未分片的集合,如productsusersusersThe orders collection begins to grow significantly larger than the others, which causes performance issues on the shard. orders集合开始比其他集合大得多,这导致了分片上的性能问题。To improve performance and balance the load across the cluster, the administrator can use the moveCollection command to move the smaller products and users collections to a different shard.为了提高性能并平衡整个集群的负载,管理员可以使用moveCollection命令将较小的productsusers集合移动到不同的分片。
  • A global application stores user data in three separate unsharded collections for users located in North America, Europe, and Asia on one shard. To reduce latency for users, an administrator can move these collections to a shard located in each respective region in the same cluster.一个全局应用程序将位于北美、欧洲和亚洲的用户数据存储在一个分片上的三个单独的未分片集合中。为了减少用户的延迟,管理员可以将这些集合移动到位于同一集群中每个相应区域的分片中。
  • An application frequently performs $lookup operations between two unsharded collections, orders and customers, that reside on different shards. 应用程序经常在驻留在不同分片上的两个未分片集合(orderscustomers)之间执行$lookup操作。To improve query performance, a database administrator can move both collections to the same shard.为了提高查询性能,数据库管理员可以将两个集合移动到同一个分片。

Get Started开始使用

Access Control访问控制

To move unsharded collections on a deployment that enforces authentication, you must authenticate as a user with at least the enableSharding role.要在强制身份验证的部署上移动未记录的集合,您必须以至少具有enableSharding角色的用户身份进行身份验证。

Learn More了解更多