Overview
The following sections describe deployment options for MongoDB Search on Atlas.
您可以使用不同的部署类型、云提供商和集群层来构建集群,以满足预生产或生产环境的需求。使用这些建议来选择部署类型、云提供商和地区以及用于执行向量搜索的集群和搜索层。
environment | 部署类型 | 集群层 | 云提供商地区 | 节点架构 |
|---|---|---|---|---|
测试查询 | Flex 或专用集群 | 免费集群、Flex 或更层级 | All | MongoDB and Search processes run on the same node. |
应用程序原型设计 | 专用集群,分片或非分片 |
| 所有 | MongoDB and Search processes run on the same node. |
生产 | 具有独立搜索节点(分片或非分片)的专用集群 |
| AWS and Azure in some regions or Google Cloud in all regions | MongoDB and Search processes run on different nodes. |
Community Edition | Self-managed deployment. You install and operate | N/A. You provide your own hardware or cloud instances. | N/A. You choose your own infrastructure. | MongoDB and Search processes run on either a single or separate self-managed hosts. |
以下各节描述了每个环境:
测试和原型环境
为了测试您的搜索查询和为您的应用程序创建原型,我们建议采用以下部分中描述的部署类型和节点架构。
此配置最适合以下用例:
要索引的总文档少于 2M
少于 10 GB 的索引数据
在 7 天内少于 10,000 次查询
如果使用量超过列出的值,请迁移至专用搜索节点。
以下各节更详细地描述了此节点架构。
- 部署类型
要在云中的集群上测试MongoDB搜索查询,您可以部署Flex 或专用集群。
To test MongoDB Search queries locally, create a local Atlas deployment using the Atlas CLI. This could be a single-node replica set hosted on your local computer. Local deployments are limited by the CPU, memory, and storage resources of your local machine. When your application is ready for production, migrate your local Atlas deployment to a production environment.
- Cluster Tiers
要测试MongoDB搜索查询,请使用免费集群(以前称为
M0)和 Flex 集群。For prototyping your application, use dedicated
M10,M20, and higher tier clusters or deploy dedicated Search Nodes for workload isolation. When your application is ready for production and to handle large datasets, scale to higher tiers.- 云提供商和地区
使用任何受支持的云提供商区域。
The cloud provider and region that you choose affect the configuration options available for the cluster tiers and the cost of running the cluster.
节点架构
对于测试和原型环境,我们建议采用MongoDB进程和MongoDB搜索进程在同一节点上运行的节点架构。在此部署模型的下图中, MongoDB Search mongot进程与 mongod 一起在Atlas 集群中的每个节点上运行,并且它们股票相同的资源。

默认下,当您创建第一个MongoDB Search索引时, Atlas会在运行 mongod进程的同一节点上启用MongoDB Search mongot进程。
要了解 MongoDB Search 如何在此架构上处理查询,请参阅 查询处理。
您可以在MongoDB Search索引中定义存储的源字段,以便 mongot进程可以在 mongot 上存储指定的字段。然后,您可以在MongoDB Search查询中使用 returnStoredSource 选项,直接从 mongot 检索匹配文档的检索字段,而不是在数据库中执行完整文档查找。
收益分析
When you enable MongoDB Search, you can easily build search on top of your data with an integrated, fully managed search engine that automatically syncs to your database. MongoDB Search provides a rich query language that uses MongoDB Search aggregation pipeline stages like $search and $searchMeta for full-text search and $vectorSearch for semantic search in conjunction with other MongoDB aggregation pipeline stages, and score-based results ranking.
根据为集群预配的资源,在同一节点上部署这两个进程可能比在单独的专用节点上运行搜索进程更具成本效益。
限制
You might experience resource contention between the database mongod and the search mongot processes. This could negatively impact the performance of your index and latency of your queries. To support production-ready applications and their search workloads migrate to dedicated Search Nodes.
成本
在集群上启用MongoDB Search 时,无需支付额外费用或收费。但是,您可能会发现大型索引集合或索引定义的集群资源利用率有所增加。
Considerations
由于 mongod 和 mongot 进程在同一节点上运行,因此在某些情况下,mongot 可能不可用。 下表描述了可能的原因:
原因 | 说明 |
|---|---|
集群层扩展 — 网络存储 | 当您向上或向下扩展集群时, Atlas会预配一个新实例。 实例准备就绪后, Atlas会附加网络存储并在新节点上启动 如果 |
集群层扩展 — 本地固态硬盘 | When you scale an Atlas cluster using local SSD, you can't retain storage and reattach it to the new nodes. Therefore, Atlas performs an initial sync to rebuild the search indexes. Search queries fail until the initial sync is complete. |
Lucene降级 | In rare cases where you require downgrading Lucene, you might not be able to read newer Lucene index formats. |
存储调整 | 您可以保留连接到Atlas 集群节点的网络存储。 这样,您就可以在不影响 但是,在某些区域、当集群使用本地 NVMe 磁盘或其他罕见情况下,可能无法保留网络存储。在这些情况下, Atlas会执行初始同步,搜索查询将失败,直到初始同步完成。 |
| 在 |
新的 | 当您向集群添加新节点时, Atlas会执行初始同步以创建搜索索引。 在初始同步完成之前,使用新 |
实例重启或替换 |
|
| 每当由于配置更改而导致 |
生产环境
对于您的生产就绪应用程序,我们建议使用以下各节中描述的部署类型和节点架构。
此配置最适合以下用例:
如果您选择将现有测试环境迁移到生产环境,请向集群添加专用搜索节点。要学习;了解更多信息,请参阅迁移到专用搜索节点。
如果您从头开始创建新的生产部署,请确保在MongoDB Search 可用的地区和分区中使用支持MongoDB Search 的
M10或更大层级的集群,并为您的环境添加专用的 Search Nodes。要学习;了解更多信息,请参阅添加专用搜索节点。
- 部署类型
对于生产就绪型应用程序,请使用
M10、M20和更高的专用集群层级。这些更高层级的集群可以处理大型数据集和生产工作负载。We recommend that you also deploy dedicated Search Nodes. If your search requirements increase, you can scale up your search deployment independently of scaling up the MongoDB nodes.
- 云提供商和地区
Use Search Nodes in all Google Cloud regions and in a subset of AWS and Azure regions. You must select a cloud provider and region where Search Nodes are available for your deployment.
All cluster tiers are available in supported cloud provider regions. The cloud provider and region that you choose affect the configuration options and search tiers available for the cluster and the cost of running the cluster.
节点架构
对于生产环境,我们建议采用一种节点架构,其中MongoDB进程和MongoDB搜索进程在单独的节点上运行。要部署单独的搜索节点,请参阅迁移到专用搜索节点。
在此部署模型的下图中, MongoDB Search mongot进程在专用搜索节点上运行,这些节点与运行 mongod进程的集群节点是分开的。

Atlas 为每个集群或集群上的每个分片部署搜索节点。例如,如果您为具有三个分片的集群部署两个搜索节点,则 Atlas 会部署六个搜索节点(每个分片两个)。您还可以配置搜索节点的数量,以及为每个搜索节点配置的资源量。
要了解 MongoDB Search 如何在此架构上处理查询,请参阅 查询处理。
您可以在MongoDB Search索引中定义存储的源字段,以便 mongot进程可以在 mongot 上存储指定的字段。然后,您可以在MongoDB Search查询中使用 returnStoredSource 选项,直接从 mongot 检索匹配文档的检索字段,而不是在数据库中执行完整文档查找。
收益分析
单独部署搜索节点具有以下优势:
- 高可用性
- 当您部署单独的搜索节点时,Atlas 会强制使用至少两个搜索节点,以确保在出现故障或中断时您的工作负载保持运行状态,将停机时间降至最低。
- 可扩展性
当您部署单独的搜索节点时,您可以在不依赖 MongoDB 集群的情况下独立扩展存储和计算能力。这使您可以独立于 MongoDB 扩展查询负载。
要扩展扩展搜索节点,请增加或减少搜索节点的数量。您可以预配最少 2 个、最多 32 个搜索节点。为了平衡查询负载, MongoDB Search 将搜索查询分布在所有可用的搜索节点上。
要垂直扩展搜索节点,请选择支持您全文工作负载的不同搜索层级、CPU、RAM和存储配置。
- 性能
在部署专用搜索节点时,您可以提高
mongod和mongot进程的性能和资源利用率,并消除这些进程之间的资源争用。专用搜索节点支持并发分段搜索,这允许MongoDB Search 同时搜索多个索引段。在某些情况下,使用并发分段搜索可缩短查询响应时间。
- 工作负载隔离
- 部署专用搜索节点不会直接影响到主数据库节点的数据传输。搜索节点与主数据库操作分开处理搜索查询,从而提供工作负载隔离性,而您只需为搜索节点和数据库节点之间的流量支付网络费用。
调整和扩展搜索节点大小的技巧
如要确定搜索节点的内存需求,请参考以下 Atlas 指标:
搜索索引的大小
搜索节点上的总 RAM
假设某个应用程序的搜索索引为 10GB,而搜索节点的总 RAM 为 4 GB。在这种情况下,如果其他进程使用了 1 GB RAM,而只有 3 GB 可用于索引数据,则剩余的 7 GB 索引数据(10 GB - 3 GB = 7 GB)将根据需要从磁盘分页读取。频繁从磁盘进行分页会导致页面错误、磁盘 I/O 和 CPU IOWait 增加,从而造成性能下降。
如果您使用具有更多 RAM 的更高搜索集群层(例如 8GB 或更多),这将允许 Atlas 从内存中提供搜索索引的大部分数据,最大限度地减少磁盘读取和页面错误,从而提高性能。
注意
The local SSDs used for Search Nodes require a 20% storage overhead to support index operations.
搜索节点成本
MongoDB supports separate Search Nodes on dedicated (M10 or higher) clusters. Search Nodes are deployed on compute-intensive instances with high-performance local storage. You must deploy a minimum of two nodes. You will be billed daily for hourly resource usage per node. To learn more, see Search Node Costs.
启用静态加密
默认下, MongoDB和搜索进程在同一节点上运行。在这种架构中,客户管理的加密适用于数据库数据,但不适应用搜索索引。
When you enable dedicated Search Nodes, search processes run on separate nodes. This allows you to enable Search Node Data Encryption, so you can encrypt both database data and search indexes with the same customer-managed keys for comprehensive encryption coverage.
注意
数据库节点和搜索节点使用不同的加密方法以及相同的客户托管密钥。数据库节点使用WiredTiger加密存储引擎,而搜索节点则在磁盘级别使用加密。
如要了解更多信息,请参阅启用搜索节点的客户密钥管理。
重要
KMS 提供商均可使用此功能,但搜索节点必须位于 AWS上。
添加专用搜索节点
向新集群添加专用搜索节点可以使您:
独立于数据库部署来更改搜索部署的大小和扩展。
消除在同一节点上运行 MongoDB 数据库和搜索进程的集群中可能出现的资源争用。
To deploy dedicated Search Nodes, you must have Project Owner access to the project.
要添加专用搜索节点:
Create your cluster as an
M10or higher tier in a cloud provider and region that supports node isolation. To learn more, see Create a Cluster.Dedicated Search Nodes are supported only for
M10and higher cluster tiers and in cloud provider regions that support node isolation.Enable Search Nodes for workload isolation and Configure Search Nodes.
迁移到专用Atlas Search节点
要从暂存迁移到生产并添加专用搜索节点,请对现有的暂存和原型部署进行以下更改:
If your deployment uses a Flex cluster, change the cluster tier to a higher tier. Dedicated Search Nodes are supported only for
M10and higher cluster tiers.Deploy your cluster in regions where Search Nodes are also available. Dedicated Search Nodes are available on a subset of the AWS and Azure regions and in all supported Google Cloud regions. If your existing cluster is hosted in regions where Search Nodes aren't available, migrate your cluster to regions where Search Nodes are available. To learn more, see Cloud Provider Regions that Support Node Isolation.
Enable Search Nodes for workload isolation and configure Search Nodes. To learn more, see Add Search Nodes.
部署专用搜索节点时,会执行以下操作顺序:
Atlas 在搜索节点上构建搜索索引,并从集群节点中移除这些索引。
Atlas 将搜索查询路由到搜索节点。
MongoDB Search 使用搜索索引为集群提供查询提供服务。
排除部署故障
Failed to Execute search Command 错误
如果您部署 mongot 以与 mongod 一起运行并且未配置搜索节点,则 mongot 可能会在以下任何事件中终止并返回 Failed to Execute search Command 错误:
扩展集群
节点故障转移
正在升级
mongot
如果您在专用搜索节点上部署 mongot,mongod 将使用代理仅将搜索查询路由到 mongot 进程处于活动状态的健康节点。
MongoDB Community Edition
If you run MongoDB Search on MongoDB Community Edition or another self-managed deployment, Atlas does not manage mongot for you. Instead, you install, configure, and operate mongot yourself. The following sections summarize the available architecture patterns and sizing options. For complete deployment and sizing guidance, see MongoDB Search and MongoDB Vector Search on Self-Managed Deployments and Introduction to mongot Deployment Sizing.
架构模式
As with MongoDB Search on Atlas, self-managed deployments use one of the same two architecture patterns: co-located or dedicated. The only exception is that on self-managed deployments, you provision and manage the hosts yourself.
大小调整
Unlike Atlas, self-managed deployments have no predefined cluster or search tiers. You provision your own hardware or cloud instances. To choose a starting configuration and refine it based on your workload, see Introduction to mongot Deployment Sizing.