使用 YAML 配置文件为MongoDB Search和向量搜索部署配置 mongot。
提示
对于 Kubernetes Operator 部署的 MongoDB 控制器,您可以使用 MongoDBSearch 自定义资源来配置 mongot。有关更多信息,请参阅 MongoDBSearch。
以下示例显示了具有 MongoDB Community 的自管理 mongot 部署的所有可用设置的完整配置结构:
syncSource: replicaSet: <object> hostAndPort: <string or list of strings> x509: <object> caFile: <string> tlsCertificateKeyFile: <string> tlsCertificateKeyFilePasswordFile: <string> scramAuth: <object> username: <string> passwordFile: <string> authSource: <string> tls: <object> enabled: <boolean> caFile: <string> tlsCertificateKeyFile: <string> tlsCertificateKeyFilePasswordFile: <string> router: <object> hostAndPort: <string or list of strings> x509: <object> caFile: <string> tlsCertificateKeyFile: <string> tlsCertificateKeyFilePasswordFile: <string> scramAuth: <object> username: <string> passwordFile: <string> authSource: <string> tls: <object> enabled: <boolean> caFile: <string> tlsCertificateKeyFile: <string> tlsCertificateKeyFilePasswordFile: <string> replicationReader: readPreference: <string> tagSets: <string or list of strings> storage: <object> dataPath: <string> server: <object> grpc: <object> address: <string> tls: <object> mode: <string> certificateKeyFile: <string> certificateKeyFilePasswordFile: <string> caFile: <string> name: <string> metrics: <object> enabled: <boolean> address: <string> healthCheck: <object> address: <string> logging: <object> verbosity: <string> logPath: <string> embedding: providerEndpoint: <string> queryKeyFile: <string> indexingKeyFile: <string> isAutoEmbeddingViewWriter: <boolean> advancedConfigs: <object> indexing: <object> lucene: <object> refresh: <object> intervalMs: <int> mergePolicy: <object> tiered: <object> vectorMergePolicy: <object> mergeBudgetMb: <int> mergeScheduler: <object> concurrent: <object> maxThreadCount: <int> fieldLimit: <int> querying: <object> lucene: <object> maxClauseLimit: <int> vectorFloorSegmentMB: <double> replication: <object> mongodb: <object> numConcurrentInitialSyncs: <int> numConcurrentChangeStreams: <int> numIndexingThreads: <int> numConcurrentSynonymSyncs: <int> pauseAllInitialSyncs: <boolean> pauseInitialSyncOnIndexIds: <list of strings> changeStreamMaxTimeMs: <int> changeStreamCursorMaxTimeSec: <int> numChangeStreamDecodingThreads: <int> initialSync: <object> bufferless: <object> enableNaturalOrderScan: <boolean> diskMonitor: <object> pauseReplicationThreshold: <double> resumeReplicationThreshold: <double> crashThreshold: <double> pauseInitialSyncThreshold: <double> resumeInitialSyncThreshold: <double> autoEmbedding: <object> materializedView: <object> numConcurrentChangeStreams: <int> numIndexingThreads: <int> numEmbeddingThreads: <int> numConcurrentInitialSyncs: <int> matViewWriterMaxConnections: <int> mvWriteRateLimitRps: <int> embeddingProviderRpsLimit: <int> maxInFlightEmbeddingGetMores: <int> embeddingGetMoreBatchSize: <int> changeStreamMaxTimeMs: <int> changeStreamCursorMaxTimeSec: <int> numChangeStreamDecodingThreads: <int> requestRateLimitBackoffMs: <int> globalMemoryBudgetHeapPercent: <int> perBatchMemoryBudgetHeapPercent: <int> cursor: <object> idleCursorHandlingRateMs: <int> cursorIdleTimeMs: <int> ftdc: <object> enabled: <boolean> directorySizeMb: <int> fileSizeMb: <int> collectionPeriodMillis: <int>
所需设置
本节介绍所有 mongot 部署所需的设置。如果仅定义所需设置,则 mongot 会对所有可选设置使用默认值。
syncSource.replicaSet.hostAndPortType: string or List of strings
用于在
mongod连接字符串中构建种子列表的一个或多个托管和端口指定符。无论提供的指定符数量如何,mongot都会在副本集模式下建立连接,而不是独立运行的实例模式。
server.grpc.address类型:字符串
gRPC 监听服务器监听的地址。使用以下格式:
<host>:<port> 在自管理部署中,发送搜索和索引管理流量到
mongot的mongod进程必须能访问此地址。将其配置为与mongod用于mongotHost和searchIndexManagementHostAndPort设置的主机和端口匹配。对于单一主机开发,
localhost是最安全的默认设置。如果mongod和mongot在不同的主机上运行,请将server.grpc.address设置为mongod可以访问的接口。警告
根据您的系统拓扑结构,可能需要将
mongot查询服务器绑定到可从 MongoDB 集群访问的接口。虽然允许绑定到0.0.0.0IP解决,但这会将服务器暴露于所有公共网络,并带来未经授权访问权限的风险。为了增强安全性,请考虑将
server.grpc.address限制为在网络层受控制和保护的特定接口,例如localhost或其他可信内部地址。
可选设置
本节介绍 mongot 的可选和有条件必需的设置。如果您省略这些设置,mongot 将在适用时使用指定的默认。
副本集身份验证设置
syncSource.replicaSet.x509类型:对象
必要性:如果您不使用 ,则必须进行此操作。
syncSource.replicaSet.scramAuthX.509 证书设置,用于使
mongot向mongod进行身份验证。
syncSource.replicaSet.x509.caFile类型:字符串
必要性:如果使用
syncSource.replicaSet.x509,则为必需证书明局 (CA) 文件,其中包含用于验证
mongod提供的证书的可信证书。该文件必须包含 PEM 格式的 X.509 证书集合。
syncSource.replicaSet.x509.tlsCertificateKeyFile类型:字符串
必要性:如果使用
syncSource.replicaSet.x509,则为必需PEM 文件的路径,该文件包含 X.509 证书和私钥,用于使用
mongod对mongot进行身份验证。配置syncSource.replicaSet.x509时必须。
syncSource.replicaSet.x509.tlsCertificateKeyFilePasswordFile类型:字符串
必要性:可选
包含用于解密
syncSource.replicaSet.x509.tlsCertificateKeyFile中指定的证书密钥文件的密码的文件的路径。
syncSource.replicaSet.scramAuth.tls.enabled类型:布尔值
必要性:如果指定
syncSource.replicaSet.scramAuth.tls,则为必需启用 TLS 身份验证的标志。设置为
true以启用 TLS 身份验证。
syncSource.replicaSet.scramAuth.tls.caFile类型:字符串
必要性:可选
证书明局 (CA) 文件,其中包含用于验证
mongod提供的证书的可信证书。该文件必须包含 PEM 格式的 X.509 证书集合。
分片集群设置
syncSource.router.x509类型:对象
必要性:如果您不使用 ,则必须进行此操作。
syncSource.router.scramAuthX.509 证书设置,用于使
mongot向mongos进行身份验证。
syncSource.router.x509.caFile类型:字符串
必要性:如果使用
syncSource.router.x509,则为必需证书明局 (CA) 文件,其中包含用于验证
mongos提供的证书的可信证书。该文件必须包含 PEM 格式的 X.509 证书集合。
syncSource.router.x509.tlsCertificateKeyFile类型:字符串
必要性:如果使用
syncSource.router.x509,则为必需PEM 文件的路径,该文件包含 X.509 证书和私钥,用于使用
mongos对mongot进行身份验证。配置syncSource.router.x509时必须。
syncSource.router.x509.tlsCertificateKeyFilePasswordFile类型:字符串
必要性:可选
包含用于解密
syncSource.router.x509.tlsCertificateKeyFile中指定的证书密钥文件的密码的文件的路径。
syncSource.router.scramAuth.authSource类型:字符串
必要性:可选
与
mongot身份验证凭证关联的数据库名称。如果未指定,则authSource默认为admin。
syncSource.router.scramAuth.tls.enabled类型:布尔值
必要性:如果指定
syncSource.router.scramAuth.tls,则为必需启用 TLS 身份验证的标志。设置为
true以启用 TLS 身份验证。
syncSource.router.scramAuth.tls.caFile类型:字符串
必要性:可选
证书明局 (CA) 文件,其中包含用于验证
mongos提供的证书的可信证书。该文件必须包含 PEM 格式的 X.509 证书集合。
复制读取偏好(read preference)设置
syncSource.replicationReader类型:对象
控制
mongot在从副本集读取以进行复制时使用的读取偏好(read preference)。要按副本集节点标签过滤读取,请指定
syncSource.replicationReader.tagSets。
syncSource.replicationReader.readPreference类型:字符串
默认值:
secondaryPreferred读取偏好(read preference)
mongot用于复制操作。您可以指定以下值:primaryprimaryPreferredsecondarysecondaryPreferrednearest
注意
无论此设置如何,索引管理命令始终使用
primary读取偏好。
syncSource.replicationReader.tagSetsType: Array
用于筛选哪些副本集成员接收复制读取的标签集数组。如果
syncSource.replicationReader.readPreference为primary,则无法配置此设置。tagSets的每个元素都是一个由{ name: <name>, value: <value> }对象组成的数组,这些对象用于匹配副本集成员标签。mongot会按顺序评估这些标签集,并使用第一个匹配到成员的标签集。例如:tagSets: - [ { name: hostname, value: mongod1 }, { name: region, value: us-east-1 } ]
gRPC 服务器设置
需要 server.grpc.address 设置。所有其他 server.grpc 设置均为可选。
server.grpc.tls.mode类型:字符串
TLS mode for the gRPC server. Must be one of the following values:
"TLS""mTLS""disabled"
配置
server.grpc.tls时必需。
server.grpc.tls.certificateKeyFile类型:字符串
包含用于
mongot的有效 X.509 证书的 PEM 文件,使用 PKCS#8 私钥。mongod使用您使用--tlsCAFile选项指定的证书授权机构 (CA) 文件验证此证书。当server.grpc.tls.mode为"TLS"或"mTLS"时,此项为必填项。
server.grpc.tls.certificateKeyFilePasswordFile类型:字符串
包含用于解密
server.grpc.tls.certificateKeyFile中指定的证书密钥文件的密码的文件的路径。
server.grpc.tls.caFile类型:字符串
证书明局 (CA) 文件,其中包含用于验证
mongod提供的证书的可信证书。该文件必须包含 PEM 格式的 X.509 证书集合。当server.grpc.tls.mode为"mTLS"时必须。
server.name类型:字符串
用户提供的名称,用于标识
mongot实例。MongoDB 使用server.name通过$listSearchIndexes等程序化接口标识mongot主机。如果您省略此设置,MongoDB 将自动生成名称。
指标设置
健康检查设置
LoggingSettings
自动嵌入设置
基本设置
配置以下设置以启用自动嵌入。
注意
queryKeyFile和indexingKeyFile作为一对。如果您未配置任何文件,则mongot会记录警告并禁用自动嵌入。providerEndpoint是可选的。设置后,mongot会将其作为配置的嵌入服务终结点的覆盖。isAutoEmbeddingViewWriter如果省略,则默认为false。
AdvancedSettings
advancedConfigs.autoEmbedding.materializedView.numConcurrentChangeStreams类型:整数
必要性:可选
默认:主机 CPU 核心数的 2 倍
物化视图复制过程在任何时候可以有未完成的稳态变更流的最大数量。必须是正整数。
advancedConfigs.autoEmbedding.materializedView.numIndexingThreads类型:整数
必要性:可选
默认:主机的 CPU 核数,最小值为
1用于将嵌入数据写入物化视图索引的线程数。必须是正整数。
advancedConfigs.autoEmbedding.materializedView.numEmbeddingThreads类型:整数
必要性:可选
默认:主机的 CPU 核数,最小值为
1用于从嵌入提供商请求嵌入的线程数。必须是正整数。
advancedConfigs.autoEmbedding.materializedView.numConcurrentInitialSyncs类型:整数
必要性:可选
默认:
advancedConfigs.replication.mongodb.numConcurrentInitialSyncs的一半。如果结果小于1,则使用1。如果您也未设置advancedConfigs.replication.mongodb.numConcurrentInitialSyncs,则默认为1。可同时运行初始同步的自动嵌入索引的最大数量。限制并发性可以减少在初始构建过程中对源
mongod节点和嵌入提供商造成的负载。必须是正整数。
advancedConfigs.autoEmbedding.materializedView.matViewWriterMaxConnections类型:整数
必要性:可选
默认值:
4用于向物化视图集合写入的最大连接数。必须是不大于
16的正整数。
advancedConfigs.autoEmbedding.materializedView.mvWriteRateLimitRps类型:整数
必要性:可选
Default: No limit
此节点上物化视图集合的每秒批量写入提交次数上限。使用此设置可限制对源
mongod节点的写入吞吐量。必须是正整数。
advancedConfigs.autoEmbedding.materializedView.embeddingProviderRpsLimit类型:整数
必要性:可选
Default: No limit
该节点可以向嵌入提供商发送的每秒最大请求数。这是节点级别限制。必须是不大于
100的正整数。
advancedConfigs.autoEmbedding.materializedView.maxInFlightEmbeddingGetMores类型:整数
必要性:可选
默认值:
3Maximum number of embedding-provider
getMoreoperations that can be in flight concurrently for the materialized view.Lower values reduce concurrent provider and memory pressure but can reduce embedding throughput. Higher values can improve throughput but may increase resource usage. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.embeddingGetMoreBatchSize类型:整数
必要性:可选
默认值:
2000Number of documents returned in each embedding-provider
getMorebatch.Larger batches can improve throughput by reducing request overhead but might increase memory usage and request latency. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.changeStreamMaxTimeMs类型:整数
必要性:可选
默认值:
700Maximum time, in milliseconds, that a materialized-view change-stream request can run before it times out.
Lower values can improve responsiveness to stalled operations but might increase request and resume frequency. Higher values can reduce request churn but might delay stall detection. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.changeStreamCursorMaxTimeSec类型:整数
必要性:可选
默认值:
1200Maximum lifetime, in seconds, of a change-stream cursor used by materialized-view replication.
Higher values can reduce cursor recreation. Lower values can detect long-lived or stalled cursors sooner. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.numChangeStreamDecodingThreads类型:整数
必要性:可选
默认值:
3Number of threads used to decode change-stream events for the materialized view. Higher values can improve event-processing throughput but increase CPU usage. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.requestRateLimitBackoffMs类型:整数
必要性:可选
默认值:
250Backoff interval, in milliseconds, that
mongotapplies after embedding requests are rate-limited.Increasing this value reduces repeated requests and provider pressure during throttling but can increase embedding update latency. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.globalMemoryBudgetHeapPercent类型:整数
必要性:可选
默认值:
80Percentage of the
mongotheap that automated-embedding materialized-view processing can use globally.Lower values reserve more heap for other
mongotoperations but can reduce automated-embedding throughput. Higher values can increase throughput but reduce memory available to other operations. Must be a positive integer.
advancedConfigs.autoEmbedding.materializedView.perBatchMemoryBudgetHeapPercent类型:整数
必要性:可选
默认值:
40Percentage of the
mongotheap that a single automated-embedding batch can use.This setting limits the memory impact of an individual batch. Configure it consistently with
advancedConfigs.autoEmbedding.materializedView.globalMemoryBudgetHeapPercent. Must be a positive integer.
高级索引设置
advancedConfigs.indexing.lucene.refresh.intervalMs类型:整数
必要性:可选
默认值:
1000mongot在刷新索引以使最近索引的更改对查询可见之前等待的间隔(以毫秒为单位)。较低的值可以减少写入文档和查询文档之间的延迟,但以更频繁的刷新工作为费用。必须是正整数。
advancedConfigs.indexing.lucene.mergePolicy.tiered.vectorMergePolicy.mergeBudgetMb类型:整数
必要性:可选
默认:托管总内存的 10%
可用于向量索引段后台合并的内存预算(以兆字为单位)。更大的预算允许一次合并更多的段,这可以提高查询性能,但在合并过程中会使用更多内存。必须是正整数。
高级查询设置
高级复制设置
advancedConfigs.replication.mongodb.numConcurrentInitialSyncs类型:整数
必要性:可选
默认:主机 CPU 核心数和
2中的较小值可同时运行其初始同步的索引的最大数量。限制并发性可以减少在多个索引同时构建时对源
mongod节点造成的负载。必须是正整数。
advancedConfigs.replication.mongodb.numConcurrentChangeStreams类型:整数
必要性:可选
默认:主机 CPU 核心数的 2 倍
可同时向源
mongod节点发出未处理请求的稳定状态变更流的最大数量。此设置控制在初始同步完成后可同时拉取更新的索引数量。必须是正整数。
advancedConfigs.replication.mongodb.numIndexingThreads类型:整数
必要性:可选
默认:托管 CPU 核心数的一半,最少为
1用于将复制的文档和更改写入索引的线程数。较高的值可以提高索引吞吐量,但可能会增加 CPU 和内存使用量。该值必须是正整数。
advancedConfigs.replication.mongodb.numConcurrentSynonymSyncs类型:整数
必要性:可选
默认值:
2可同步并发的同义词源集合的最大数量。必须是正整数。
advancedConfigs.replication.mongodb.pauseAllInitialSyncs类型:布尔值
必要性:可选
默认值:
falseFlag that pauses all new initial-sync operations when set to
true. Use this setting to prevent additional index builds from increasing disk or resource usage during recovery or maintenance.This setting applies across the deployment and does not provide per-host control. To apply a change to this setting, perform a rolling restart of your
mongotinstances.
advancedConfigs.replication.mongodb.pauseInitialSyncOnIndexIdsType: Array of Strings
必要性:可选
默认:无
Index IDs for which
mongotpauses initial sync. Use this setting to defer selected index builds while allowing other indexes to continue synchronizing.Each value must identify a search index. This setting applies across the deployment rather than to an individual host. To apply a change to this setting, perform a rolling restart of your
mongotinstances.
advancedConfigs.replication.mongodb.changeStreamMaxTimeMs类型:整数
必要性:可选
默认值:
500Maximum time, in milliseconds, that
mongotallows an individual change-stream request to run before it times out.Lower values can cause
mongotto retry or resume change streams more frequently. Higher values can reduce request churn but may delay detection of stalled operations. Must be a positive integer.
advancedConfigs.replication.mongodb.changeStreamCursorMaxTimeSec类型:整数
必要性:可选
默认值:
900Maximum lifetime, in seconds, of a replication change-stream cursor.
Adjust this value only when tuning change-stream resource usage or cursor stability. Higher values can reduce cursor recreation. Lower values can detect long-lived or stalled cursors sooner. Must be a positive integer.
advancedConfigs.replication.mongodb.numChangeStreamDecodingThreads类型:整数
必要性:可选
默认值:
4Number of threads
mongotuses to decode replication change-stream events. Higher values can improve change-stream processing throughput but increase CPU usage. Must be a positive integer.
advancedConfigs.replication.initialSync.bufferless.enableNaturalOrderScan类型:布尔值
必要性:可选
默认值:
falseFlag that enables natural-order scans for bufferless initial sync when set to
true.Natural-order scans change how
mongotreads documents during initial sync. Evaluate the effect on initial-sync performance and source-node load before you enable this setting in production.
Advanced Disk Monitor Settings
The disk-monitor settings use a fraction of disk capacity. For example, 0.90 represents 90% disk usage. Configure the resume thresholds below their corresponding pause thresholds to prevent repeated pause and resume cycles.
注意
Changes to these settings take effect only after you restart mongot.
advancedConfigs.diskMonitor.pauseReplicationThreshold类型:double
必要性:可选
默认值:
0.90Disk-utilization threshold at which
mongotpauses replication. Pausing replication prevents additional replicated index data from increasing disk usage while the host is under disk pressure.
advancedConfigs.diskMonitor.resumeReplicationThreshold类型:double
必要性:可选
默认值:
0.85Disk-utilization threshold below which
mongotresumes replication after disk pressure causes replication to pause. Set this value lower thanadvancedConfigs.diskMonitor.pauseReplicationThreshold.
advancedConfigs.diskMonitor.crashThreshold类型:double
必要性:可选
默认值:
0.95Critical disk-utilization threshold at which
mongotcrashes to protect the host from disk exhaustion. Set this threshold as a last-resort safety limit above the pause thresholds.
Advanced Cursor Settings
advancedConfigs.cursor.idleCursorHandlingRateMs类型:整数
必要性:可选
默认值:
1800000Interval, in milliseconds, at which
mongotchecks for idle cursors. Lower values allowmongotto identify idle cursors sooner but increase cursor-management work. Must be a positive integer.
advancedConfigs.cursor.cursorIdleTimeMs类型:整数
必要性:可选
默认值:
3600000Duration, in milliseconds, that a cursor can remain idle before
mongottreats it as idle. Lower values allowmongotto reclaim cursor resources sooner but may affect clients that intentionally wait between requests. Must be a positive integer.
高级 FTDC 设置
advancedConfigs.ftdc.enabled类型:布尔值
必要性:可选
默认值:
true启用全时诊断数据采集 (FTDC)的标志。FTDC 诊断数据采集默认处于启用状态。当
false时,mongot在自启动时不会创建 FTDC 报告程序,因此不会采集诊断数据。
advancedConfigs.ftdc.directorySizeMb类型:整数
必要性:可选
默认值:
100FTDC 存档目录的最大总大小,以兆字为单位。必须大于等于
10并且大于advancedConfigs.ftdc.fileSizeMb。