Database Manual / Self-Managed Deployments / Administration / Configuration & Maintenance

MongoDB Server Parameters for a Self-Managed Deployment自我管理部署的MongoDB服务器参数

Note

Starting in MongoDB 8.0, LDAP authentication and authorization is deprecated. LDAP is available and will continue to operate without changes throughout the lifetime of MongoDB 8. LDAP will be removed in a future major release.从MongoDB 8.0开始,LDAP身份验证和授权被弃用。LDAP是可用的,并将在MongoDB 8的整个生命周期内继续运行而不做任何更改。LDAP将在未来的主要版本中删除。

For details, see LDAP Deprecation.有关详细信息,请参阅LDAP弃用

Synopsis剧情简介

MongoDB provides a number of configuration options that you can set using:MongoDB提供了许多配置选项,您可以使用以下选项进行设置:

  • the setParameter command:setParameter命令:

    db.adminCommand( { setParameter: 1, <parameter>: <value>  } )
  • the setParameter configuration setting:setParameter配置设置:

    setParameter:
    <parameter1>: <value1>
    ...
  • the --setParameter command-line option for mongod and mongos:mongodmongos--setParameter命令行选项:

    mongod --setParameter <parameter>=<value>
    mongos --setParameter <parameter>=<value>

For additional configuration options, see Self-Managed Configuration File Options, mongod and mongos.有关其他配置选项,请参阅自我管理配置文件选项mongodmongos

Parameters参数

Authentication Parameters身份验证参数

allowRolesFromX509Certificates

Available for both mongod and mongos.适用于mongodmongos

Default: true

A boolean flag that allows or disallows the retrieval of authorization roles from client X.509 certificates.一个布尔标志,允许或不允许从客户端X.509证书中检索授权角色。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

authenticationMechanisms

Available for both mongod and mongos.适用于mongodmongos

Specifies the list of authentication mechanisms the server accepts. Set this to one or more of the following values. If you specify multiple values, use a comma-separated list and no spaces. 指定服务器接受的身份验证机制列表。将其设置为以下一个或多个值。如果指定了多个值,请使用逗号分隔的列表,不要使用空格。For descriptions of the authentication mechanisms, see Authentication on Self-Managed Deployments.有关身份验证机制的描述,请参阅自我管理部署上的身份验证

ValueDescription描述
SCRAM-SHA-1RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.代表使用SHA-1哈希函数的标准Salted Challenge Response认证机制。
SCRAM-SHA-256RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.代表使用SHA-256哈希函数的标准Salted Challenge Response认证机制。
MONGODB-X509MongoDB TLS/SSL certificate authentication.MongoDB TLS/SSL证书身份验证。
GSSAPI (Kerberos)External authentication using Kerberos. This mechanism is available only in MongoDB Enterprise.使用Kerberos的外部身份验证。此机制仅在MongoDB Enterprise中可用。
PLAIN (LDAP SASL)External authentication using LDAP. You can also use PLAIN for authenticating in-database users. 使用LDAP进行外部身份验证。您还可以使用PLAIN对数据库中的用户进行身份验证。PLAIN transmits passwords in plain text. This mechanism is available only in MongoDB Enterprise.PLAIN以纯文本形式传输密码。此机制仅在MongoDB Enterprise中可用。
MONGODB-OIDCOpenID Connect is an authentication layer built on top of OAuth2. This mechanism is available only in MongoDB Enterprise.OpenID Connect是建立在OAuth2之上的身份验证层。此机制仅在MongoDB企业版中可用。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, to specify both PLAIN and SCRAM-SHA-256 as the authentication mechanisms, use the following command:例如,要指定PLAINSCRAM-SHA-256作为身份验证机制,请使用以下命令:

mongod --setParameter authenticationMechanisms=PLAIN,SCRAM-SHA-256 --auth
authFailedDelayMs

Available for both mongod and mongos.适用于mongodmongos

Default: 0

Note

Enterprise Feature企业特性

Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。

The number of milliseconds to wait before informing clients that their authentication attempt has failed. This parameter may be in the range 0 to 5000, inclusive.在通知客户端其身份验证尝试失败之前等待的毫秒数。此参数的范围可以是05000,包括05000

Setting this parameter makes brute-force login attacks on a database more time-consuming. However, clients waiting for a response from the MongoDB server still consume server resources, and this may adversely impact benign login attempts if the server is denying access to many other clients simultaneously.设置此参数会使数据库上的暴力登录攻击更加耗时。然而,等待MongoDB服务器响应的客户端仍然会消耗服务器资源,如果服务器同时拒绝访问许多其他客户端,这可能会对良性登录尝试产生不利影响。

awsSTSRetryCount

Changed in version 7.0.在版本7.0中的更改。 (Also starting in 6.0.7 and 5.0.18)(同样从6.0.7和5.0.18开始)

In previous versions, AWS IAM authentication retried only when the server returned an HTTP 500 error.在以前的版本中,AWS IAM身份验证仅在服务器返回HTTP 500错误时重试。

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 2

For MongoDB deployments using AWS IAM credentials or AWS IAM environment variables.对于使用AWS IAM凭据AWS IAM环境变量的MongoDB部署。

Maximum number of AWS IAM authentication retries after a connection failure.连接失败后AWS IAM身份验证重试的最大次数。

The following example sets awsSTSRetryCount to 15 retries:以下示例将awsSTSRetryCount设置为15次重试:

mongod --setParameter awsSTSRetryCount=15

Alternatively, the following examples uses the setParameter command within mongosh:或者,以下示例使用mongosh中的setParameter命令:

db.adminCommand( { setParameter: 1, awsSTSRetryCount: 15 } )
clusterAuthMode

Available for both mongod and mongos.适用于mongodmongos

Set the clusterAuthMode to either sendX509 or x509. clusterAuthMode设置为sendX509x509Useful during rolling upgrade to use x509 for membership authentication to minimize downtime.滚动升级期间,使用x509进行成员身份验证以最大限度地减少停机时间非常有用。

For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodmongos以用于TLS/SSL客户端的TLS/SSL

This parameter is only available at runtime. To set the parameter, use the setParameter command.此参数仅在运行时可用。要设置参数,请使用setParameter命令。

db.adminCommand( { setParameter: 1, clusterAuthMode: "sendX509" } )
enableLocalhostAuthBypass

Available for both mongod and mongos.适用于mongodmongos

Default: true

Specify 0 or false to disable localhost authentication bypass. Enabled by default.指定0false以禁用本地主机身份验证绕过。默认情况下启用。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

See Localhost Exception in Self-Managed Deployments for more information.有关详细信息,请参阅自我管理部署中的本地主机异常

enforceUserClusterSeparation

Available for both mongod and mongos.适用于mongodmongos

Set to false to disable the O/OU/DC check when clusterAuthMode is keyFile in your configuration file. 设置为false可在配置文件中clusterAuthModekeyFile时禁用O/OU/DC检查。This allows clients possessing member certificates to authenticate as users stored in the $external database. 这允许拥有成员证书的客户端作为存储在$external数据库中的用户进行身份验证。The server won't start if clusterAuthMode isn't keyFile in your configuration file.如果clusterAuthMode不是配置文件中的keyFile,服务器将不会启动。

To set the enforceUserClusterSeparation parameter to false, run the following command during startup:要将enforceUserClusterSeparation参数设置为false,请在启动过程中运行以下命令:

mongod --setParameter enforceUserClusterSeparation=false
JWKSMinimumQuiescePeriodSecs

Available for both mongod and mongos.适用于mongodmongos

Default: 60 seconds (1 minute)

Specifies the minimum time period that must pass between subsequent fetches of a given IdP's JWKSetURI endpoint. 指定给定IdP的JWKSetURI端点的后续提取之间必须经过的最小时间段。If an RSA public key is changed multiple times within the quiesce period, that key may not work as expected for up to a minute unless the quiesce period is manually reduced. If this parameter is set to zero, there is no quiesce period and the key can be refreshed repeatedly.如果RSA公钥在静默期内多次更改,则该键可能无法按预期工作长达一分钟,除非手动缩短静默期。如果此参数设置为零,则没有停顿期,键可以重复刷新。

This parameter is available at both startup and runtime. To set the parameter, use the setParameter setting.此参数在启动和运行时都可用。要设置参数,请使用setParameter设置。

KeysRotationIntervalSec

Available for both mongod and mongos.适用于mongodmongos

Default: 7776000 seconds (90 days)

Specifies the number of seconds for which an HMAC signing key is valid before rotating to the next one. This parameter is intended primarily to facilitate authentication testing.指定HMAC签名键在旋转到下一个键之前的有效秒数。此参数主要用于促进身份验证测试。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

ldapConnectionPoolHostRefreshIntervalMillis

Available for mongod only.仅适用于mongod

Default: 60000

The number of milliseconds in-between health checks of the pooled LDAP connections.池化LDAP连接的运行状况检查之间的毫秒数。

You can only set ldapConnectionPoolHostRefreshIntervalMillis during start-up, and cannot change this setting with the setParameter database command.您只能在启动期间设置ldapConnectionPoolHostRefreshIntervalMillis,并且不能使用setParameter数据库命令更改此设置。

ldapConnectionPoolIdleHostTimeoutSecs

Available for mongod only.仅适用于mongod

Default: 300

The maximum number of seconds that the pooled connections to an LDAP server can remain idle before being closed.与LDAP服务器的池连接在关闭之前可以保持空闲的最大秒数。

You can only set ldapConnectionPoolIdleHostTimeoutSecs during start-up, and cannot change this setting with the setParameter database command.您只能在启动期间设置ldapConnectionPoolIdleHostTimeoutSecs,并且不能使用setParameter数据库命令更改此设置。

ldapConnectionPoolMaximumConnectionsInProgressPerHost

Available for mongod only.仅适用于mongod

Changed starting in MongoDB versions 5.0.9 and 6.0.0从MongoDB 5.0.9和6.0.0版本开始更改 Changed default value to 2. In previous versions, the default is unset.将默认值更改为2。在以前的版本中,默认设置为未设置。

Default: 2

The maximum number of in-progress connect operations to each LDAP server.每个LDAP服务器正在进行的连接操作的最大数量。

You can only set ldapConnectionPoolMaximumConnectionsInProgressPerHost during start-up, and cannot change this setting with the setParameter database command.您只能在启动期间设置ldapConnectionPoolMaximumConnectionsInProgressPerHost,并且不能使用setParameter数据库命令更改此设置。

ldapConnectionPoolMaximumConnectionsPerHost

Available for mongod only.仅适用于mongod

Changed starting in MongoDB versions 5.0.9 and 6.0.0从MongoDB 5.0.9和6.0.0版本开始更改 Changed default value to 2147483647. In previous versions, the default is unset.已将默认值更改为2147483647。在以前的版本中,默认设置为未设置。

Default: 2147483647

The maximum number of connections to keep open to each LDAP server.对每个LDAP服务器保持打开的最大连接数。

You can only set ldapConnectionPoolMaximumConnectionsPerHost during start-up, and cannot change this setting during run time with the setParameter database command.您只能在启动期间设置ldapConnectionPoolMaximumConnectionsPerHost,并且不能在运行时使用setParameter数据库命令更改此设置。

ldapConnectionPoolMinimumConnectionsPerHost

Available for mongod only.仅适用于mongod

Default: 1

The minimum number of connections to keep open to each LDAP server.对每个LDAP服务器保持打开状态的最小连接数。

You can only set ldapConnectionPoolMinimumConnectionsPerHost during start-up, and cannot change this setting during run time with the setParameter database command.您只能在启动期间设置ldapConnectionPoolMinimumConnectionsPerHost,并且不能在运行时使用setParameter数据库命令更改此设置。

ldapConnectionPoolUseLatencyForHostPriority

Available for mongod only.仅适用于mongod

Default: true

A boolean that determines whether the LDAP connection pool (see ldapUseConnectionPool) should use latency of the LDAP servers to determine the connection order (from lowest latency to highest).一个布尔值,用于确定LDAP连接池(请参阅ldapUseConnectionPool)是否应使用LDAP服务器的延迟来确定连接顺序(从最低延迟到最高延迟)。

You can only set ldapConnectionPoolUseLatencyForHostPriority during start-up, and cannot change this setting during run time with the setParameter database command.您只能在启动期间设置ldapConnectionPoolUseLatencyForHostPriority,并且不能在运行时使用setParameter数据库命令更改此设置。

ldapForceMultiThreadMode

Available for both mongod and mongos.适用于mongodmongos

Default: false

Enables the performance of concurrent LDAP operations.启用并发LDAP操作的性能。

Note

Only if you are certain that your instance of libldap is safe to use in this mode, enable this flag. You may experience crashes of the MongoDB process if the libldap version you are using is not thread safe.只有当您确信libldap实例在此模式下使用是安全的时,才启用此标志。如果您使用的libldap版本不是线程安全的,您可能会遇到MongoDB进程崩溃的情况。

You must use ldapForceMultiThreadMode to use LDAP connection pool. To enable LDAP connection pool, set ldapForceMultiThreadMode and ldapUseConnectionPool to true.您必须使用ldapForceMultiThreadMode才能使用LDAP连接池。要启用LDAP连接池,请将ldapForceMultiThreadModeldapUseConnectionPool设置为true

Tip

If you have any concerns regarding your MongoDB version, OS version or libldap version, please contact MongoDB Support.如果您对MongoDB版本、操作系统版本或libldap版本有任何疑问,请联系MongoDB支持。

ldapQueryPassword

Available for mongod only.仅适用于mongod

Type: string

The password used to bind to an LDAP server. You must use ldapQueryUser with this parameter.用于绑定到LDAP服务器的密码。您必须将ldapQueryUser与此参数一起使用。

If not set, mongod or mongos does not attempt to bind to the LDAP server.如果未设置,mongodmongos不会尝试绑定到LDAP服务器。

ldapQueryUser

Available for mongod only.仅适用于mongod

Type: string

The user that binds to an LDAP server. You must use ldapQueryPassword with this parameter.绑定到LDAP服务器的用户。您必须将ldapQueryPassword与此参数一起使用。

If not set, mongod or mongos does not attempt to bind to the LDAP server.如果未设置,mongodmongos不会尝试绑定到LDAP服务器。

ldapRetryCount

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 0

For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。

Number of operation retries by the server LDAP manager after a network error.网络错误后服务器LDAP管理器重试操作的次数。

For example, the following sets ldapRetryCount to 3 seconds:例如,以下将ldapRetryCount设置为3秒:

mongod --ldapRetryCount=3

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, ldapRetryCount: 3 } )
ldapShouldRefreshUserCacheEntries

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

Available for mongod only.仅适用于mongod

Type: boolean

Default: true

For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。

Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on ldapShouldRefreshUserCacheEntries:从MongoDB 5.2开始,从LDAP服务器检索到的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries

You can only set ldapShouldRefreshUserCacheEntries during startup in the configuration file or with the --setParameter option on the command line. 您只能在启动期间在配置文件中或使用命令行上的--setParameter选项设置ldapShouldRefreshUserCacheEntriesFor example, the following disables ldapShouldRefreshUserCacheEntries:例如,以下内容禁用ldapShouldRefreshUserCacheEntries

mongod --setParameter ldapShouldRefreshUserCacheEntries=false
ldapUseConnectionPool

Available for both mongod and mongos.适用于mongodmongos

Specifies whether MongoDB should use connection pooling when connecting to the LDAP server for authentication/authorization.指定MongoDB在连接到LDAP服务器进行身份验证/授权时是否应使用连接池。

MongoDB uses the following default values:MongoDB使用以下默认值:

  • true on Windows.
  • true on Linux where MongoDB Enterprise binaries are linked against libldap_r.在Linux上为true,MongoDB Enterprise二进制文件与libldap_r链接。
  • false on Linux where MongoDB Enterprise binaries are linked against libldap.在Linux上为false,其中MongoDB Enterprise二进制文件与libldap链接。

You can only set ldapUseConnectionPool during start-up, and cannot change this setting with the setParameter database command.您只能在启动期间设置ldapUseConnectionPool,不能使用setParameter数据库命令更改此设置。

ldapUserCacheInvalidationInterval

Changed in version 5.2.在版本5.2中的更改。

Available for mongod only.仅适用于mongod

Default: 30 seconds

Note

Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on ldapShouldRefreshUserCacheEntries:从MongoDB 5.2开始,从LDAP服务器检索到的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries

For use with MongoDB deployments using LDAP Authorization on Self-Managed Deployments.用于在自我管理部署上使用LDAP授权的MongoDB部署。

The interval (in seconds) that the mongod instance waits between external user cache flushes. mongod实例在外部用户缓存刷新之间等待的时间间隔(秒)。After MongoDB flushes the external user cache, MongoDB reacquires authorization data from the LDAP server the next time an LDAP-authorized user issues an operation.MongoDB刷新外部用户缓存后,下次LDAP授权用户发出操作时,MongoDB会从LDAP服务器重新获取授权数据。

Increasing the value specified increases the amount of time MongoDB and the LDAP server can be out of sync, but reduces the load on the LDAP server. Conversely, decreasing the value specified decreases the time MongoDB and the LDAP server can be out of sync while increasing the load on the LDAP server.增加指定的值会增加MongoDB和LDAP服务器不同步的时间,但会减少LDAP服务器的负载。相反,减小指定的值可以减少MongoDB和LDAP服务器不同步的时间,同时增加LDAP服务器的负载。

ldapUserCacheRefreshInterval

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 30 seconds

Note

Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on ldapShouldRefreshUserCacheEntries:从MongoDB 5.2开始,从LDAP服务器检索到的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries

For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。

The interval in seconds that mongod waits before refreshing the cached user information from the LDAP server.mongod在从LDAP服务器刷新缓存的用户信息之前等待的时间间隔(秒)。

The maximum interval is 86,400 seconds (24 hours).最长间隔为86400秒(24小时)。

For example, the following sets ldapUserCacheRefreshInterval to 4000 seconds:例如,以下将ldapUserCacheRefreshInterval设置为4000秒:

mongod --setParameter ldapUserCacheRefreshInterval=4000

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, ldapUserCacheRefreshInterval: 4000 } )
ldapUserCacheStalenessInterval

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 90 seconds

For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。

The interval in seconds that mongod retains the cached LDAP user information after the last cache refresh.上次缓存刷新后mongod保留缓存的LDAP用户信息的间隔(秒)。

If more than ldapUserCacheStalenessInterval seconds elapse without a successful refresh of the user information from the LDAP server, then mongod:如果超过ldapUserCacheStalenessInterval秒后,LDAP服务器上的用户信息仍未成功刷新,则mongod

  • Invalidates the cached LDAP user information.使缓存的LDAP用户信息无效。
  • Is unable to authenticate new sessions for LDAP users until mongod connects to the LDAP server and authorizes the LDAP user.mongod连接到LDAP服务器并授权LDAP用户之前,无法对LDAP用户的新会话进行身份验证。
  • Authorizes any existing sessions that use previously authenticated LDAP users if mongod is unable to connect to the LDAP server. 如果mongod无法连接到LDAP服务器,则授权使用以前经过身份验证的LDAP用户的任何现有会话。When mongod reconnects to the LDAP server, mongod ensures the LDAP users are correctly authorized.mongod重新连接到LDAP服务器时,mongod会确保LDAP用户得到正确授权。

The maximum interval is 86,400 seconds (24 hours).最长间隔为86400秒(24小时)。

For example, the following sets ldapUserCacheStalenessInterval to 4000 seconds:例如,以下将ldapUserCacheStalenessInterval设置为4000秒:

mongod --setParameter ldapUserCacheStalenessInterval=4000

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, ldapUserCacheStalenessInterval: 4000 } )
maxValidateMemoryUsageMB

Available for mongod only.仅适用于mongod

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

Default: 200

The maximum memory usage limit in megabytes for the validate command. validate命令的最大内存使用限制(MB)。If the limit is exceeded, validate returns as many results as possible and warns that not all corruption might be reported because of the limit.如果超过限制,validate将返回尽可能多的结果,并警告说,由于限制,可能不会报告所有损坏。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
ocspEnabled

Available for both mongod and mongos.适用于mongodmongos

Available on Linux and macOS.适用于Linux和macOS。

Default: true

The flag that enables or disables OCSP.启用或禁用OCSP的标志。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, the following disables OCSP:例如,以下内容禁用OCSP:

mongod --setParameter ocspEnabled=false ...

Starting in MongoDB 6.0, if ocspEnabled is set to true during initial sync, all nodes must be able to reach the OCSP responder.从MongoDB 6.0开始,如果在初始同步期间ocspEnabled设置为true,则所有节点都必须能够访问OCSP响应器。

If a member fails in the STARTUP2 state, set tlsOCSPVerifyTimeoutSecs to a value that is less than 5.如果成员在STARTUP2状态下失败,请将tlsOCSPVerifyTimeoutSecs设置为小于5的值。

ocspStaplingRefreshPeriodSecs

Available for both mongod and mongos.适用于mongodmongos

Available on Linux.在Linux上可用。

The number of seconds to wait before refreshing the stapled OCSP status response. Specify a number greater than or equal to 1.刷新装订好的OCSP状态响应之前等待的秒数。指定一个大于或等于1的数字。

You can only set ocspStaplingRefreshPeriodSecs during startup in the configuration file or with the --setParameter option on the command line. 您只能在启动期间在配置文件中或使用命令行上的--setParameter选项设置ocspStaplingRefreshPeriodSecsFor example, the following sets the parameter to 3600 seconds:例如,以下将参数设置为3600秒:

mongod --setParameter ocspStaplingRefreshPeriodSecs=3600 ...

Starting in MongoDB 5.0, the rotateCertificates command and db.rotateCertificates() method will also refresh any stapled OCSP responses.从MongoDB 5.0开始,rotateCertificates命令和db.rotateCertificates()方法也将刷新任何装订的OCSP响应。

oidcIdentityProviders

Available for mongod only.仅适用于mongod

Changed in version 8.0.在版本8.0中的更改。 (Also available in 7.3 and 7.0)

Use this parameter to specify identity provider (IDP) configurations when using OpenID Connect Authentication.使用OpenID连接身份验证时,使用此参数指定身份提供程序(IDP)配置。

oidcIdentityProviders accepts an array of zero or more identity provider (IDP) configurations. 接受零个或多个身份提供者(IDP)配置的数组。An empty array (default) indicates no OpenID Connect support is enabled.空数组(默认)表示未启用OpenID Connect支持。

When more than one IDP is defined, oidcIdentityProviders uses the matchPattern field to select an IDP. Array order determines the priority and the first IDP is always selected.当定义了多个IDP时,oidcIdentityProvider使用matchPattern字段选择一个IDP。数组顺序决定了优先级,并且始终选择第一个IDP。

Starting in MongoDB 8.0, when multiple identity providers (IDP) are defined, the oidcIdentityProviders parameter accepts duplicate issuer values as long as the audience value is unique for each issuer. This is also available in versions 7.3 and 7.0.从MongoDB 8.0开始,当定义了多个身份提供者(IDP)时,oidcIdentityProviders参数接受重复的issuer值,只要每个issueraudience值都是唯一的。这在7.3和7.0版本中也可用。

oidcIdentityProviders Fields

Field字段Necessity必要性Type类型Description描述
issuerRequired必需string字符串

The issuer URI of the IDP that the server should accept tokens from. This must match the iss field in any JWT used for authentication.服务器应从中接受令牌的IDP的颁发者URI。这必须与用于身份验证的任何JWT中的iss字段匹配。

Starting in MongoDB 8.0, when multiple identity providers (IDP) are defined, the oidcIdentityProviders parameter accepts duplicate issuer values as long as the audience value is unique for each issuer. 从MongoDB 8.0开始,当定义了多个身份提供者(IDP)时,oidcIdentityProviders参数接受重复的issuer值,只要每个issueraudience值都是唯一的。This is also available in versions 7.3 and 7.0.这在7.3和7.0版本中也可用。

If you specify an unreachable issuer URI, MongoDB:如果您指定了一个无法访问的颁发者URI,MongoDB:

  1. Logs a warning.
  2. Continues server startup, which allows you to update the issuer URI.继续服务器启动,这允许您更新颁发者URI。
  3. Reattempts issuer contact. If MongoDB reaches the issuer URI and validates the access token, authentication succeeds. If the issuer URI remains unreachable, authentication fails.重新尝试与发卡行联系。如果MongoDB到达颁发者URI并验证访问令牌,则身份验证成功。如果颁发者URI仍然无法访问,则身份验证失败。

Changed in version 8.0.在版本8.0中的更改。 (Also available in 7.3 and 7.0)

authNamePrefixRequired必需string字符串

Unique prefix applied to each generated UserName and RoleName used in authorization. authNamePrefix can only contain the following characters:应用于授权中使用的每个生成的用户名和角色名的唯一前缀。authNamePrefix只能包含以下字符:

  • alphanumeric characters (combination of a to z and 0 to 9)字母数字字符(az09的组合)
  • hyphens (-)
  • underscores (_)
matchPatternConditionalstring字符串

Regex pattern used to determine which IDP should be used. matchPattern matches against usernames. Array order determines the priority and the first IDP is always selected.用于确定应使用哪个IDP的正则表达式模式。matchPattern与用户名匹配。数组顺序决定了优先级,并且始终选择第一个IDP。

matchPattern is required in some configurations, depending on how the user sets supportsHumanFlows:在某些配置中是必需的,具体取决于用户设置supportsHumanFlows的方式:

  • When only one IdP has supportsHumanFlows set to true (the default), matchPatterns is optional.当只有一个IdP将supportsHumanFlows设置为true(默认值)时,matchPatterns是可选的。
  • When multiple IdP's have supportsHumanFlows set to true (the default), each of these requires matchPatterns.当多个IdP将supportsHumanFlows设置为true(默认值)时,每个IdP都需要matchPatterns
  • matchPatterns is optional for any IdP where supportsHumanFlows is set to false.matchPatterns对于supportsHumanFlows设置为false的任何IdP都是可选的。

This is not a security mechanism. matchPattern serves only as an advisory to clients. MongoDB accepts tokens issued by the IDP whose principal names do not match this pattern.这不是一种安全机制。matchPattern仅作为对客户的建议。MongoDB接受IDP颁发的令牌,其主体名称与此模式不匹配。

clientIdConditionalstring字符串

ID provided by the IDP to identify the client that receives the access tokens.IDP提供的ID,用于标识接收访问令牌的客户端。

Required when supportsHumanFlows is set to true (the default).supportsHumanFlows设置为true(默认值)时需要。

audienceRequired必需string字符串

Specifies the application or service that the access token is intended for.指定访问令牌要用于的应用程序或服务。

Starting in MongoDB 7.0, only one audience oidcIdentityProviders field can be specified for OIDC access tokens. audience fields with empty arrays or arrays of multiple strings are invalid.从MongoDB 7.0开始,只能为OIDC访问令牌指定一个audience(受众)oidcIdentityProviders字段。具有空数组或多个字符串数组的audience字段无效。

When more than one IDP is defined, this must be a unique value for each configuration that shares an issuer.当定义了多个IDP时,对于共享issuer(发行者)的每个配置,这必须是一个唯一的值。

requestScopesOptional可选array[ string ]Permissions and access levels that MongoDB requests from the IDP.MongoDB向IDP请求的权限和访问级别。
principalNameOptional可选string字符串

The claim to be extracted from the access token containing MongoDB user identifiers.从包含MongoDB用户标识符的访问令牌中提取的声明。

The default value is sub (stands for subject).默认值为sub(代表subject)。

useAuthorizationClaimOptional可选boolean布尔值

Determines if the authorizationClaim is required. The default value is true.确定是否需要authorizationClaim。默认值为true

If the useAuthorizationClaim field is set to true, the server requires an authorizationClaim for the identity provider's config. This is the default behavior.如果useAuthorizationClaim字段设置为true,则服务器需要身份提供者的配置的authorizationClaim。这是默认行为。

If the useAuthorizationClaim field is set to false, the authorizationClaim field is optional (and ignored if provided). Instead, the server does the following:如果useAuthorizationClaim字段设置为false,则authorizationClaim字段是可选的(如果提供,则忽略)。相反,服务器会执行以下操作:

  • Searches the token for a claim whose name is listed in the principalNameClaim field. This is typically named sub. For example:在令牌中搜索其名称列在principalNameClaim字段中的声明。这通常被称为sub。例如:

    sub: "spencer.jackson@example.com"

  • Constructs the internal username by concatenating the authNamePrefix, a forward slash (/), and the contents of the claim identified by principalNameClaim within the access token. For example, with a authNamePrefix field value of "mdbinc", the internal username is:通过连接authNamePrefix、正斜杠(/)和访问令牌中由principalNameClaim标识的声明内容来构造内部用户名。例如,如果authNamePrefix字段值为“mdbinc”,则内部用户名为:

    mdbinc/spencer.jackson@example.com

  • Looks for the user with this username and authorizes the client with the roles:查找具有此用户名的用户,并使用以下角色授权客户端:

    { user: "mdbinc/spencer.jackson@example.com",
    db: "$external" }

New in version 7.2.在版本7.2中新增。 (Also available in 7.0.5)

authorizationClaimConditionalstring字符串

Required, unless useAuthorizationClaim is set to false.必需,除非useAuthorizationClaim设置为false

Claim extracted from access token that contains MongoDB role names.从包含MongoDB角色名称的访问令牌中提取的声明。

logClaimsOptional可选array[ string ]List of access token claims to include in log and audit messages upon authentication completion.身份验证完成后要包含在日志和审核消息中的访问令牌声明列表。
JWKSPollSecsOptional可选integer整数

Frequency, in seconds, to request an updated JSON Web Key Set (JWKS) from the IDP. A setting of 0 disables polling.从IDP请求更新的JSON Web键集(JWKS)的频率(秒)。设置为0将禁用轮询。

When more than one IDP is defined, this must be the same value for each configuration that shares an issuer.当定义了多个IDP时,共享issuer(发行者)的每个配置的IDP值必须相同。

supportsHumanFlowsOptional可选bool

Whether the OIDC provider supports human or machine workflows. This affects the clientId and matchPattern fields.OIDC提供商是否支持人工或机器工作流程。这会影响clientIdmatchPattern字段。

You may find it useful to set this field to false with machine workload IdP's to allow them to omit the clientId when it's unneeded.您可能会发现,使用机器工作负载IdP将此字段设置为false很有用,这样它们就可以在不需要时省略clientId

Default: true.

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

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

opensslCipherConfig

Available for both mongod and mongos.适用于mongodmongos

Available on Linux only仅在Linux上可用

With the use of native TLS/SSL libraries, the parameter opensslCipherConfig is supported for Linux/BSD and no longer supported in Windows and macOS.通过使用本机TLS/SSL库,参数opensslCipherConfig在Linux/BSD中受支持,在Windows和macOS中不再受支持。

Specify the cipher string for OpenSSL when using TLS/SSL encryption. For a list of cipher strings, see https://www.openssl.org/docs/man1.1.1/man1/ciphers.html. 使用TLS/SSL加密时,指定OpenSSL的密码字符串。有关密码字符串的列表,请参阅https://www.openssl.org/docs/man1.1.1/man1/ciphers.htmlMultiple cipher strings can be provided as a colon-separated list.多个密码字符串可以以冒号分隔的列表形式提供。

Note

This parameter is only for use with TLS 1.2 or earlier. To specify cipher suites for use with TLS 1.3, use the opensslCipherSuiteConfig parameter.此参数仅适用于TLS 1.2或更早版本。要指定与TLS 1.3一起使用的密码套件,请使用opensslCipherSuiteConfig参数。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

The use of TLS options is preferred over SSL options. TLS选项的使用优于SSL选项。The TLS options have the same functionality as the SSL options. TLS选项与SSL选项具有相同的功能。The following example configures a mongod with a opensslCipherConfig cipher string of 'HIGH:!EXPORT:!aNULL@STRENGTH':以下示例使用opensslCipherConfig密码字符串'HIGH:!EXPORT:!aNULL@STRENGTH'配置mongod

mongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL@STRENGTH' --tlsMode requireTLS --tlsCertificateKeyFile Certs/server.pem
opensslCipherSuiteConfig

Available for both mongod and mongos.适用于mongodmongos

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

Available on Linux only仅在Linux上可用

Specify the list of supported cipher suites OpenSSL should permit when using TLS 1.3 encryption.指定使用TLS 1.3加密时OpenSSL应允许的受支持密码套件列表。

For a list of cipher suites for use with TLS 1.3, see https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_cipher_list.html. Multiple cipher suites can be provided as a colon-separated list.有关与TLS 1.3一起使用的密码套件列表,请参阅https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_cipher_list.html。多个密码套件可以以冒号分隔的列表形式提供。

Note

This parameter is only for use with TLS 1.3. To specify cipher strings for use with TLS 1.2 or earlier, use the opensslCipherConfig parameter.此参数仅适用于TLS 1.3。要指定与TLS 1.2或更早版本一起使用的密码字符串,请使用opensslCipherConfig参数。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, the following configures a mongod with a opensslCipherSuiteConfig cipher suite of 'TLS_AES_256_GCM_SHA384' for use with TLS 1.3:例如,以下内容将mongod配置为opensslCipherSuiteConfig密码套件'TLS_AES_256_GCM_SHA384',以与TLS 1.3一起使用:

mongod --setParameter opensslCipherSuiteConfig='TLS_AES_256_GCM_SHA384' --tlsMode requireTLS --tlsCertificateKeyFile Certs/server.pem
opensslDiffieHellmanParameters

Available for both mongod and mongos.适用于mongodmongos

Available on Linux only仅在Linux上可用

Specify the path to the PEM file that contains the OpenSSL Diffie-Hellman parameters when using TLS 1.2 or previous. 使用TLS 1.2或更早版本时,指定包含OpenSSL Diffie-Hellman参数的PEM文件的路径。Specifying the OpenSSL Diffie-Hellman parameters enables support for Ephemeral Diffie-Hellman (DHE) cipher suites during TLS/SSL encryption.指定OpenSSL Diffie-Hellman参数可以在TLS/SSL加密期间支持Ephemeral Diffie-Hellman(DHE)密码套件。

This parameter is not supported for use with TLS 1.3.TLS 1.3不支持使用此参数。

Ephemeral Diffie-Hellman (DHE) cipher suites (and Ephemeral Elliptic Curve Diffie-Hellman (ECDHE) cipher suites) provide Forward Secrecy. 瞬时Diffie-Hellman(DHE)密码套件(和瞬时椭圆曲线Diffie-Hell(ECDHE)密码套件)提供前向保密Forward Secrecy cipher suites create an ephemeral session key that is protected by the server's private key but never transmitted. 前向保密密码套件创建了一个受服务器私钥保护但从不传输的临时会话键。This ensures that even if a server's private key is compromised, you cannot decrypt past sessions with the compromised key.这确保了即使服务器的私钥被泄露,您也无法使用泄露的键解密过去的会话。

Note

If opensslDiffieHellmanParameters is unset but ECDHE is enabled, MongoDB enables DHE using the ffdhe3072 Diffie-Hellman parameter, as defined in RFC-7919#appendix-A.2. 如果未设置opensslDiffieHellmanParameters,但启用了ECDHE,则MongoDB将使用RFC-7919#appendix-A.2中定义的ffdhe3072 Diffie-Hellman参数启用DHE。The ffdhe3072 is a strong parameter (specifically, size is greater than 1024). Strong parameters are not supported with Java 6 and 7 unless extended support has been purchased from Oracle.ffdhe3072是一个强参数(具体来说,大小大于1024)。除非从Oracle购买了扩展支持,否则Java 6和7不支持强参数。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

If for performance reasons, you need to disable support for DHE cipher suites, use the opensslCipherConfig parameter:如果出于性能原因,您需要禁用对DHE密码套件的支持,请使用opensslCipherConfig参数:

mongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL:!DHE:!kDHE@STRENGTH' ...
pessimisticConnectivityCheckForAcceptedConnections

Available on Linux only仅在Linux上可用

Type: boolean

Default: false

When set to true, instructs the server to check the connectivity of accepted connections before processing them and to immediately discard connections that the client terminates.当设置为true时,指示服务器在处理已接受的连接之前检查其连接,并立即丢弃客户端终止的连接。

Consider enabling this parameter on smaller instance types. You can use it when you want to trade a small amount of latency on new connection establishment for reduced server work when processing new connections that have already been closed on the client side.考虑在较小的实例类型上启用此参数。当您想在处理客户端已关闭的新连接时,以新连接建立的少量延迟换取减少的服务器工作时,可以使用它。

saslauthdPath

Available for both mongod and mongos.适用于mongodmongos

Note

Available only in MongoDB Enterprise (except MongoDB Enterprise for Windows).仅在MongoDB Enterprise中可用(适用于Windows的MongoDB Enterprise除外)。

Specify the path to the Unix Domain Socket of the saslauthd instance to use for proxy authentication.指定用于代理身份验证的saslausted实例的Unix域套接字的路径。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

saslHostName

Available for both mongod and mongos.适用于mongodmongos

saslHostName overrides MongoDB's default hostname detection for the purpose of configuring SASL and Kerberos authentication.覆盖MongoDB的默认主机名检测,以配置SASL和Kerberos身份验证。

saslHostName does not affect the hostname of the mongod or mongos instance for any purpose beyond the configuration of SASL and Kerberos.saslHostName不会出于SASL和Kerberos配置之外的任何目的影响mongodmongos实例的主机名。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

Note

saslHostName supports Kerberos authentication and is only included in MongoDB Enterprise. For more information, see the following:支持Kerberos身份验证,仅包含在MongoDB Enterprise中。有关更多信息,请参阅以下内容:

saslServiceName

Available for both mongod and mongos.适用于mongodmongos

Allows users to override the default Kerberos service name component of the Kerberos principal name, on a per-instance basis. If unspecified, the default value is mongodb.允许用户在每个实例的基础上覆盖Kerberos主体名称的默认Kerberos服务名称组件。如果未指定,默认值为mongodb

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

saslServiceName is only available in MongoDB Enterprise.仅在MongoDB企业版中可用。

Important

Ensure that your driver supports alternate service names.确保驱动程序支持备用服务名称。

scramIterationCount

Available for both mongod and mongos.适用于mongodmongos

Default: 10000

Changes the number of hashing iterations used for all new SCRAM-SHA-1 passwords. More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts. 更改用于所有新SCRAM-SHA-1密码的哈希迭代次数。更多的迭代增加了客户端向MongoDB进行身份验证所需的时间,但使密码不易受到暴力破解的影响。The default value is ideal for most common use cases and requirements.默认值非常适合最常见的用例和需求。

If you modify this value, it does not change the iteration count for existing passwords. The scramIterationCount value must be 5000 or greater.如果修改此值,则不会更改现有密码的迭代计数。scramIterationCount值必须为5000或更大。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the scramIterationCount to 12000.例如,下面将scramIterationCount设置为12000

mongod --setParameter scramIterationCount=12000

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, scramIterationCount: 12000 } )
scramSHA256IterationCount

Available for both mongod and mongos.适用于mongodmongos

Default: 15000

Changes the number of hashing iterations used for all new SCRAM-SHA-256 passwords. More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts. The default value is ideal for most common use cases and requirements.更改用于所有新SCRAM-SHA-256密码的哈希迭代次数。更多的迭代增加了客户端向MongoDB进行身份验证所需的时间,但使密码不易受到暴力破解的影响。默认值非常适合最常见的用例和需求。

If you modify this value, it does not change iteration count for existing passwords. The scramSHA256IterationCount value must be 5000 or greater.如果修改此值,则不会更改现有密码的迭代计数。scramSHA256IterationCount值必须大于等于5000

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the scramSHA256IterationCount to 20000.例如,以下将scramSHA256IterationCount设置为20000

mongod --setParameter scramSHA256IterationCount=20000

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, scramSHA256IterationCount: 20000 } )
sslMode

Available for both mongod and mongos.适用于mongodmongos

Set the net.ssl.mode to either preferSSL or requireSSL. Useful during rolling upgrade to TLS/SSL to minimize downtime.net.ssl.mode设置为preferSSLrequireSSL。在滚动升级到TLS/SSL期间非常有用,可以最大限度地减少停机时间。

For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodmongos以用于TLS/SSL客户端的TLS/SSL配置

This parameter is only available at runtime. To set the parameter, use the setParameter command.此参数仅在运行时可用。要设置参数,请使用setParameter命令。

db.adminCommand( { setParameter: 1, sslMode: "preferSSL" } )

Tip

tlsMode

tlsClusterAuthX509Override

Available for both mongod and mongos.适用于mongodmongos

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

Overrides the clusterAuthX509 configuration options.覆盖clusterAuthX509配置选项。

setParameter:
tlsClusterAuthX509Override: "{ attributes: 'O=MongoDB, OU=MongoDB Server' }"

The parameter supports attributes and extensionValue overrides.该参数支持attributesextensionValue重写。

When the server authenticates connections from members, it analyzes the X.509 certificate to determine whether it belongs to a cluster member. 当服务器对来自成员的连接进行身份验证时,它会分析X.509证书以确定它是否属于集群成员。If the server uses the attributes setting or the attributes field on the tlsClusterAuthX509Override parameter, it checks the Distinguished Name (DN) values of the certificate. 如果服务器使用tlsClusterAuthX509Override参数上的attributes设置或attributes字段,它将检查证书的可分辨名称(DN)值。If the extensionValue setting or the extensionValue field of the tlsClusterAuthX509Override parameter is set, it checks the extension values of the certificate. 如果设置了tlsClusterAuthX509Override参数的extensionValue设置或extensionValue字段,它将检查证书的扩展值。If it finds a match, it authorizes the connection as a peer.如果它找到匹配项,它将以对等身份授权连接。

Use this parameter to rotate certificates when the new certificates have different attributes or extension values.当新证书具有不同的属性或扩展名值时,使用此参数轮换证书。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

tlsMode

Available for both mongod and mongos.适用于mongodmongos

Set to either:

  • preferTLS
  • requireTLS

The tlsMode parameter is useful during rolling upgrade to TLS/SSL to minimize downtime.tlsMode参数在滚动升级到TLS/SSL期间非常有用,可以最大限度地减少停机时间。

This parameter is only available at runtime. To set the parameter, use the setParameter command.此参数仅在运行时可用。要设置参数,请使用setParameter命令。

db.adminCommand( { setParameter: 1, tlsMode: "preferTLS" } )

For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodmongos以用于TLS/SSL客户端的TLS/SSL配置

Tip

sslMode

tlsOCSPStaplingTimeoutSecs

Available for both mongod and mongos.适用于mongodmongos

Available for Linux.适用于Linux。

The maximum number of seconds the mongod / mongos instance should wait to receive the OCSP status response for its certificates.mongod/mongos实例应等待接收其证书的OCSP状态响应的最大秒数。

Specify an integer greater than or equal to (>=) 1. If unset, tlsOCSPStaplingTimeoutSecs uses the tlsOCSPVerifyTimeoutSecs value.指定一个大于或等于(>=)1的整数。如果未设置,tlsOCSPStaplingTimeoutSecs将使用tlsOCSPVerifyTimeoutSecs值。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, the following sets the tlsOCSPStaplingTimeoutSecs to 20 seconds:例如,以下将tlsOCSPStaplingTimeoutSecs设置为20秒:

mongod --setParameter tlsOCSPStaplingTimeoutSecs=20 ...
tlsOCSPVerifyTimeoutSecs

Available for both mongod and mongos.适用于mongodmongos

Available for Linux and Windows.

Default: 5

The maximum number of seconds that the mongod / mongos should wait for the OCSP response when verifying server certificates.mongod/mongos在验证服务器证书时等待OCSP响应的最大秒数。

Specify an integer greater than or equal to (>=) 1.指定一个大于或等于(>=)1的整数。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, the following sets the tlsOCSPVerifyTimeoutSecs to 20 seconds:例如,以下将tlsOCSPVerifyTimeoutSecs设置为20秒:

mongod --setParameter tlsOCSPVerifyTimeoutSecs=20 ...
tlsUseSystemCA

Available for mongod only.仅适用于mongod

Type: boolean

Default: false

Specifies whether MongoDB loads TLS certificates that are already available to the operating system's certificate authority.指定MongoDB是否加载操作系统证书颁发机构已经可用的TLS证书。

Important

When starting a mongod instance with TLS/SSL enabled, you must specify a value for the --tlsCAFile flag, the net.tls.CAFile configuration option, or the tlsUseSystemCA parameter.

--tlsCAFile, tls.CAFile, and tlsUseSystemCA are all mutually exclusive.--tlsCAFiletls.CAFfiletlsUseSystemCA都是互斥的。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, to set tlsUseSystemCA to true:例如,要将tlsUseSystemCA设置为true

mongod --setParameter tlsUseSystemCA=true

For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodmongos以用于TLS/SSL客户端的TLS/SSL配置

tlsWithholdClientCertificate

Available for both mongod and mongos.适用于mongodmongos

Default: false

A TLS certificate is set for a mongod or mongos either by the --tlsClusterFile option or by the --tlsCertificateKeyFile option when --tlsClusterFile is not set. 通过--tlsClusterFile选项或未设置--tlsClusterFile时的--tlsCertificateKeyFile选项为mongodmongos设置TLS证书。If the TLS certificate is set, by default, the instance sends the certificate when initiating intra-cluster communications with other mongod or mongos instances in the deployment. 如果设置了TLS证书,默认情况下,实例在与部署中的其他mongodmongos实例发起集群内通信时会发送证书。Set tlsWithholdClientCertificate to 1 or true to direct the instance to withhold sending its TLS certificate during these communications. tlsWithholdClientCertificate设置为1true,以指示实例在这些通信期间拒绝发送其TLS证书。Use this option with --tlsAllowConnectionsWithoutCertificates (to allow inbound connections without certificates) on all members of the deployment. 在部署的所有成员上,将此选项与--tlsAllowConnectionsWithoutCertificates一起使用(以允许没有证书的入站连接)。tlsWithholdClientCertificate is mutually exclusive with --clusterAuthMode x509.tlsWithholdClientCertificate--clusterAuthMode x509互斥。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

tlsX509ClusterAuthDNOverride

Available for both mongod and mongos.适用于mongodmongos

An alternative Distinguished Name (DN) that the instance can also use to identify members of the deployment.实例还可以用来标识部署成员的另一个可分辨名称(DN)。

For a MongoDB deployment that uses X.509 certificates for clusterAuthMode, deployment members identify each other using X.509 certificates ( net.tls.clusterFile, if specified, and net.tls.certificateKeyFile) during intra-cluster communications. 对于使用X.509证书进行clusterAuthMode的MongoDB部署,部署成员在集群内通信期间使用X.509证书(如果指定了net.tls.clusterFilenet.tls.certificateKeyFile)相互标识。For members of the same deployment, the DN from their certificates must have the same Organization attributes (O's), the Organizational Unit attributes (OU's), and the Domain Components (DC's).对于同一部署的成员,其证书中的DN必须具有相同的组织属性(O)、组织单位属性(OU)和域组件(DC)。

If tlsX509ClusterAuthDNOverride is set for a member, the member can also use the override value when comparing the DN components (O's, OU's, and DC's) of the presented certificates. 如果为成员设置了tlsX509ClusterAuthDNOverride,则该成员在比较所提供证书的DN组件(OOUDC)时也可以使用重写值。That is the member checks the presented certificates against its net.tls.clusterFile/net.tls.certificateKeyFile. 即成员根据其net.tls.clusterFile/net.tls.certificateKeyFile检查所提供的证书。If the DN does not match, the member checks the presented certificate against the tlsX509ClusterAuthDNOverride value.如果DN不匹配,成员将根据tlsX509ClusterAuthDNOverride值检查提供的证书。

Note

If set, you must set this parameter on all members of the deployment.如果已设置,则必须在部署的所有成员上设置此参数。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

You can use this parameter for a rolling update of certificates to new certificates that contain a new DN value. 您可以使用此参数将证书滚动更新为包含新DN值的新证书。See Rotate X.509 Certificates without clusterAuthX509 Attributes on Self-Managed Clusters.请参阅在自管理群集上旋转不带clusterAuthX509属性的X.509证书

For more information about membership certificate requirements, see Member Certificate Requirements for details.有关会员证书要求的更多信息,请参阅会员证书要求以了解详细信息。

tlsX509ExpirationWarningThresholdDays

Available for both mongod and mongos.适用于mongodmongos

Default : 30

mongod / mongos logs a warning on connection if the presented X.509 certificate expires within 30 days of the mongod/mongos system clock. 如果所提供的X.509证书在mongod/mongos系统时钟后30天内到期,mongod/mongos会在连接时记录警告。Use the tlsX509ExpirationWarningThresholdDays parameter to control the certificate expiration warning threshold:使用tlsX509ExpirationWarningThresholdDays参数控制证书过期警告阈值:

  • Increase the parameter value to trigger warnings farther ahead of the certificate expiration date.增加参数值以在证书到期日期之前触发警告。
  • Decrease the parameter value to trigger warnings closer to the certificate expiration date.减小参数值以在证书到期日期附近触发警告。
  • Set the parameter to 0 to disable the warning.将参数设置为0以禁用警告。

This parameter has a minimum value of 0.此参数的最小值为0

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For more information on X.509 certificate validity, see RFC 5280 4.1.2.5.有关X.509证书有效性的更多信息,请参阅RFC 5280 4.1.2.5

userCacheInvalidationIntervalSecs

Available for mongos only.仅适用于mongos

Default: 30

On a mongos instance, specifies the interval (in seconds) at which the mongos instance checks to determine whether the in-memory cache of user objects has stale data, and if so, clears the cache. mongos实例上,指定mongos实例检查的间隔(以秒为单位),以确定用户对象的内存缓存是否有过时数据,如果有,则清除缓存。If there are no changes to user objects, mongos will not clear the cache.如果用户对象没有变化,mongos将不会清除缓存。

This parameter has a minimum value of 1 second and a maximum value of 86400 seconds (24 hours).此参数的最小值为1秒,最大值为86400秒(24小时)。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

General Parameters通用参数

allowDiskUseByDefault

Available for mongod only.仅适用于mongod

Default: True

Starting in MongoDB 6.0, pipeline stages that require more than 100 megabytes of memory to execute write temporary files to disk by default. These temporary files last for the duration of the pipeline execution and can influence storage space on your instance. 从MongoDB 6.0开始,默认情况下,需要超过100兆字节内存来执行将临时文件写入磁盘的流水线阶段。这些临时文件在管道执行期间持续存在,并可能影响实例上的存储空间。In earlier versions of MongoDB, you must pass { allowDiskUse: true } to individual find and aggregate commands to enable this behavior.在早期版本的MongoDB中,您必须将{ allowDiskUse: true }传递给单个findaggregate命令以启用此行为。

Individual find and aggregate commands can override the allowDiskUseByDefault parameter by either:单个findaggregate命令可以通过以下任一方式覆盖allowDiskUseByDefault参数:

  • Using { allowDiskUse: true } to allow writing temporary files out to disk when allowDiskUseByDefault is set to falseallowDiskUseByDefault设置为false时,使用{allowDiskUse:true}允许将临时文件写入磁盘
  • Using { allowDiskUse: false } to prohibit writing temporary files out to disk when allowDiskUseByDefault is set to trueallowDiskUseByDefault设置为true时,使用{allowDiskUse:false}禁止将临时文件写入磁盘

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
mongod --setParameter allowDiskUseByDefault=false

allowDiskUseByDefault only works on mongod not mongos. mongod起作用,对mongos不起作用。mongos never writes temporary files to disk. 从不将临时文件写入磁盘。Use the setParameter command in a mongosh session that is connected to a running mongod to change the value of the parameter while the server is running:在连接到正在运行的mongodmongosh会话中使用setParameter命令,在服务器运行时更改参数的值:

db.adminCommand(
{
setParameter: 1,
allowDiskUseByDefault: false
}
)
connPoolMaxConnsPerHost

Available for both mongod and mongos.适用于mongodmongos

Default: 200

Sets the maximum size of the legacy connection pools for outgoing connections to other mongod instances in the global connection pool. 为全局连接池中其他mongod实例的传出连接设置旧连接池的最大大小。The size of a pool does not prevent the creation of additional connections, but does prevent a connection pool from retaining connections in excess of the value of connPoolMaxConnsPerHost.池的大小不会阻止创建其他连接,但会阻止连接池保留超过connPoolMaxConnsPerHost值的连接。

Note

The parameter is separate from the connections in TaskExecutor pools. See ShardingTaskExecutorPoolMaxSize.该参数与TaskExecutor池中的连接是分开的。请参阅ShardingTaskExecutorPoolMaxSize

Only adjust this setting if your driver does not pool connections and you're using authentication in the context of a sharded cluster.仅当驱动程序没有池连接并且您在分片集群的上下文中使用身份验证时,才调整此设置。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

mongod --setParameter connPoolMaxConnsPerHost=250
connPoolMaxInUseConnsPerHost

Available for both mongod and mongos.适用于mongodmongos

Sets the maximum number of in-use connections at any given time for for outgoing connections to other mongod instances in the legacy global connection pool.设置在任何给定时间与遗留全局连接池中其他mongod实例的传出连接的最大使用中连接数。

By default, the parameter is unset.默认情况下,该参数未设置。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

mongod --setParameter connPoolMaxInUseConnsPerHost=100
cursorTimeoutMillis

Available for both mongod and mongos.适用于mongodmongos

Default: 600000 (10 minutes)

Sets the expiration threshold in milliseconds for idle cursors before MongoDB removes them; specifically, MongoDB removes cursors that have been idle for the specified cursorTimeoutMillis.设置MongoDB删除空闲游标之前的过期阈值(以毫秒为单位);具体来说,MongoDB会删除指定cursorTimeoutMillis的空闲游标。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the cursorTimeoutMillis to 300000 milliseconds (5 minutes).例如,下面将cursorTimeoutMillis设置为300000毫秒(5分钟)。

mongod --setParameter cursorTimeoutMillis=300000

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, cursorTimeoutMillis: 300000 } )

Setting cursorTimeoutMillis to less than or equal to 0 results in all cursors being immediately eligible for timeout. cursorTimeoutMillis设置为小于或等于0会导致所有游标立即符合超时条件。Generally, the timeout value should be greater than the average amount of time for a query to return results. 通常,超时值应大于查询返回结果的平均时间。Use tools like the cursor.explain() cursor modifier to analyze the average query time and select an appropriate timeout period.使用cursor.explain()游标修饰符等工具分析平均查询时间并选择适当的超时时间。

Warning

MongoDB cleans up orphaned cursors after the cursorTimeoutMillis threshold only if they are not tied to sessions.MongoDB仅在孤立游标未绑定到会话的情况下,才会在cursorTimeoutMillis阈值后清理孤立游标。

MongoDB cleans up cursors linked to sessions with the localLogicalSessionTimeoutMinutes lifecycle, regardless of the cursorTimeoutMillis value. MongoDB使用localLogicalSessionTimeoutMinutes生命周期清理链接到会话的游标,而不管cursorTimeoutMillis值如何。To handle long idle periods, use Mongo.startSession() and refresh the session using the refreshSessions command. 要处理长时间的空闲期,请使用Mongo.startSession()并使用refreshSessions命令刷新会话。For details, see Refresh a Cursor with refreshSessions.有关详细信息,请参阅使用refreshSessions刷新游标

fassertOnLockTimeoutForStepUpDown

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

Available for both mongod and mongos.适用于mongodmongos

Default: 15 seconds

Allows a server that receives a request to step up or step down, to terminate if it is unable to comply (for example due to faulty server disks) within the timeout. This enables a cluster to successfully elect a new primary node and thus continue to be available.允许接收到升级或降级请求的服务器在超时内无法遵守(例如由于服务器磁盘故障)时终止。这使集群能够成功选择新的主节点,从而继续可用。

fassertOnLockTimeoutForStepUpDown defaults to 15 seconds. 默认为15秒。To disable nodes from fasserting, set fassertOnLockTimeoutForStepUpDown=0.要禁用节点插入,请将fassertOnLockTimeoutForStepUpDown设置为0。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example disables nodes from fasserting:以下示例禁止插入节点:

mongod --setParameter fassertOnLockTimeoutForStepUpDown=0
globalConnPoolIdleTimeoutMinutes

Available for both mongod and mongos.适用于mongodmongos

Sets the time limit that connection in the legacy global connection pool can remain idle before being closed.设置旧全局连接池中的连接在关闭前可以保持空闲的时间限制。

By default, the parameter is unset.默认情况下,该参数未设置。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

mongos --setParameter globalConnPoolIdleTimeoutMinutes=10
httpVerboseLogging

Available for both mongod and mongos.适用于mongodmongos

Adds more verbose tracing for curl on Linux and macOS. Has no affect on Windows.在Linux和macOS上为curl添加了更详细的跟踪。对Windows没有影响。

By default, the parameter is unset.默认情况下,该参数未设置。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
mongos --setParameter httpVerboseLogging=true
indexBuildMinAvailableDiskSpaceMB

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

Available for mongod only.仅适用于mongod

Default: 500 MB

Sets the minimum available disk space in megabytes required for index builds.设置索引构建所需的最小可用磁盘空间(MB)。

Must be greater than or equal to 0 MB, and less than or equal to 8 TB. 0 disables the minimum disk space requirement.必须大于或等于0 MB,小于或等于8 TB。0禁用最小磁盘空间要求。

A new index build cannot be started and a current index build is cancelled if the available disk space is below indexBuildMinAvailableDiskSpaceMB.如果可用磁盘空间低于indexBuildMinAvailableDiskSpaceMB,则无法启动新的索引生成,并取消当前的索引生成。

Warning

If you increase indexBuildMinAvailableDiskSpaceMB, ensure your server has enough available disk space. 如果增加indexBuildMinAvailableDiskSpaceMB,请确保服务器有足够的可用磁盘空间。Also, if you set indexBuildMinAvailableDiskSpaceMB too high, you might needlessly prevent index builds when there is enough available disk space and indexBuildMinAvailableDiskSpaceMB could be set lower.此外,如果将indexBuildMinAvailableDiskSpaceMB设置得太高,当有足够的可用磁盘空间时,可能会不必要地阻止索引构建,而indexBuildMinAvailableDiskSpaceMB可以设置得更低。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets indexBuildMinAvailableDiskSpaceMB to 650 MB:以下示例将indexBuildMinAvailableDiskSpaceMB设置为650 MB:

db.adminCommand( { setParameter: 1, indexBuildMinAvailableDiskSpaceMB: 650 } )

You can also set indexBuildMinAvailableDiskSpaceMB at startup. For example:您还可以在启动时设置indexBuildMinAvailableDiskSpaceMB。例如:

mongod --setParameter indexBuildMinAvailableDiskSpaceMB=650
indexMaxNumGeneratedKeysPerDocument

Available for both mongod and mongos.适用于mongodmongos

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

Default: 100000

Limits the maximum number of keys generated for a document to prevent out of memory errors. It is possible to raise the limit, but if an operation requires more keys than the indexMaxNumGeneratedKeysPerDocument parameter specifies, the operation will fail.限制为文档生成的最大键数,以防止内存不足错误。可以提高限制,但如果操作需要的键数超过indexMaxNumGeneratedKeysPerDocument参数指定的键数,则操作将失败。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

ingressAdmissionControllerTicketPoolSize

Available for mongod only.仅适用于mongod

Default: 1000000

Controls the maximum number of operations admitted concurrently to the ingress queue. 控制入口队列同时允许的最大操作数。The default value of 1000000 represents the numerical equivalent of unbounded, which admits all incoming operations up to the default maximum connections that MongoDB allows.默认值1000000表示无界的数值等效值,它允许所有传入操作达到MongoDB允许的默认最大连接数。

Increasing this value while there are operations waiting on the queue unblocks as many operations as the new pool size permits. Decreasing this value does not block any currently executing operations, but incoming controllable operations are blocked until there are tickets available.在队列上有操作等待时增加此值,可以在新池大小允许的情况下取消阻止尽可能多的操作。减小此值不会阻止任何当前正在执行的操作,但会阻止传入的可控操作,直到有可用的票证为止。

mongod --setParameter ingressAdmissionControllerTicketPoolSize=100000

Warning

Avoid modifying ingressAdmissionControllerTicketPoolSize unless directed by MongoDB engineers. 除非MongoDB工程师另有指示,否则避免修改ingressAdmissionControllerTicketPoolSizeThis setting has major implications across both WiredTiger and MongoDB.此设置对WiredTiger和MongoDB都有重大影响。

ingressConnectionEstablishmentRateLimiterEnabled

New in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: false

Determines whether rate limiting for new connection establishment is enabled. When enabled, MongoDB applies rate limiting to control the number of new connections that can be established per second.确定是否启用了新连接建立的速率限制。启用后,MongoDB应用速率限制来控制每秒可以建立的新连接数量。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
ingressConnectionEstablishmentRatePerSec

New in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)

Available for both mongod and mongos.适用于mongodmongos

Type: int32

Default: disabled

Minimum: 1

Specifies the maximum number of new connections that can be established per second when rate limiting is enabled.指定启用速率限制时每秒可以建立的最大新连接数。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
ingressConnectionEstablishmentBurstCapacitySecs

New in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)

Available for both mongod and mongos.适用于mongodmongos

Type: double

Default: disabled

Minimum: 1

Describes how many seconds worth of connection establishments that the server can admit before rate limiting begins. 描述在速率限制开始之前,服务器可以允许多少秒的连接建立。This allows the server to handle temporary bursts of connection requests that exceed the rate limit specified by ingressConnectionEstablishmentRatePerSec.这允许服务器处理超过ingressConnectionEstablishmentRatePerSec指定的速率限制的临时连接请求。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
ingressConnectionEstablishmentMaxQueueDepth

New in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)

Available for both mongod and mongos.适用于mongodmongos

Type: int32

Default: 0 (disabled)

Specifies the maximum number of connection attempts in the connection establishment queue. After the queue reaches this number of connection attempts, the server rejects new connection attempts.指定连接建立队列中的最大连接尝试次数。队列达到此连接尝试次数后,服务器将拒绝新的连接尝试。

The default value of 0 means that the server rejects all connections that will queue for establishment.默认值0表示服务器拒绝所有将排队等待建立的连接。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
ingressConnectionEstablishmentRateLimiterBypass

New in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)

Available for both mongod and mongos.适用于mongodmongos

Type: string array

Default: []

Provides a list of IP addresses and CIDR ranges that the server must exempt from the connection establishment rate limits. This allows specific trusted clients to bypass rate limiting restrictions.提供服务器必须免除连接建立速率限制的IP地址和CIDR范围列表。这允许特定的受信任客户端绕过速率限制。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
maxIndexBuildMemoryUsageMegabytes

Available for mongod only.仅适用于mongod

Default (absolute): 200
Minimum (absolute): 50
Maximum (percent): 0.8

Limits the amount of memory that simultaneous index builds on one collection may consume for their duration. 限制在一个集合上同时构建索引在其持续时间内可能消耗的内存量。The specified amount of memory is shared between all indexes built using a single createIndexes command or its shell helper db.collection.createIndexes(). 指定数量的内存在使用单个createIndexes命令或其shell助手db.collection.createIndexes()构建的所有索引之间共享。Increasing the limit improves sorting performance when the index build process generates and sorts index keys. 增加限制可以提高索引构建过程生成和排序索引键时的排序性能。The memory consumed by an index build is separate from the WiredTiger cache memory (see cacheSizeGB).索引构建所消耗的内存与cacheSizeGB缓存内存是分开的(请参阅cacheSizeGB)。

  • Set this value to 0-0.8 to limit builds to a percentage of memory.将此值设置为0-0.8,以将构建限制在内存的百分比内。
  • Set this value to 1.0 or greater to limit builds to an absolute number of megabytes.将此值设置为1.0或更大,以将构建限制为绝对兆字节数。

If this setting allocates less than 50 MB, mongod uses a minimum of 50 MB. If the percentage setting is greater than 0.8, mongod uses a maximum of 80% of available memory.如果此设置分配的空间小于50 MB,mongod将使用至少50 MB。如果百分比设置大于0.8,mongod最多使用80%的可用内存。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
maxNumActiveUserIndexBuilds

Available for mongod only.仅适用于mongod

Type: integer

Default: 3

Sets the maximum number of concurrent index builds allowed on the primary. This is a global limit that applies across all collections.设置primary上允许的并发索引构建的最大数量。这是一个适用于所有集合的全局限制。

Increasing the value of maxNumActiveUserIndexBuilds allows additional concurrent index builds at the cost of increased pressure on the WiredTiger cache.增加maxNumActiveUserIndexBuilds的值允许以增加WiredTiger缓存压力为代价进行额外的并发索引构建。

System indexes are not limited to maxNumActiveUserIndexBuilds, however a system index build counts against the limit for user index builds.系统索引不限于maxNumActiveUserIndexBuilds,但是系统索引构建会计入用户索引构建的限制。

After the server reaches maxNumActiveUserIndexBuilds, it blocks additional user index builds until the number of concurrent index builds drops below the maxNumActiveUserIndexBuilds limit. If an index build is blocked, the server logs this message:服务器达到maxNumActiveUserIndexBuilds后,它会阻止其他用户索引构建,直到并发索引构建的数量降至maxNumActiveUserIndexBuilds限制以下。如果索引构建被阻止,服务器会记录以下消息:

Too many index builds running simultaneously, waiting until the
number of active index builds is below the threshold.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following command sets a limit of 4 concurrent index builds:以下命令设置了4个并发索引构建的限制:

db.adminCommand( { setParameter: 1, maxNumActiveUserIndexBuilds: 4 } )

See also:另请参阅:

notablescan

Available for mongod only.仅适用于mongod

Prevents running some collection scans when an index could be used, whether present or not. 阻止在可以使用索引(无论是否存在)时运行某些集合扫描。If true, MongoDB will not execute queries that require a collection scan and will return an error. Exclusions include queries without filters and queries against capped collections, such as the oplog.如果为true,MongoDB将不会执行需要集合扫描的查询,并将返回错误。排除项包括没有筛选器的查询和对有上限的集合(如oplog)的查询。

Consider the following example which sets notablescan to true or true:考虑以下将notablescan设置为truetrue的示例:

db.adminCommand( { setParameter: 1, notablescan: true } )

Setting notablescan to true can be useful for testing application queries, for example, to identify queries that scan an entire collection and cannot use an index.notablescan设置为true对于测试应用程序查询非常有用,例如,识别扫描整个集合但不能使用索引的查询。

To detect unindexed queries without notablescan, consider reading the Analyze Query Performance section and using the logLevel parameter, mongostat and profiling.要在不使用notablescan的情况下检测未索引的查询,请考虑阅读“分析查询性能”部分,并使用logLevel参数、mongostat和分析。

Don't run production mongod instances with notablescan because preventing collection scans can potentially affect queries in all databases, including administrative queries.不要使用notablescan运行生产mongod实例,因为阻止集合扫描可能会影响所有数据库中的查询,包括管理查询。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Note

notablescan does not allow unbounded queries that use a clustered index because the queries require a full collection scan. notablescan不允许使用聚集索引的无界查询,因为这些查询需要进行完整的集合扫描。For more information, see Collection Scans.有关详细信息,请参阅集合扫描

reportOpWriteConcernCountersInServerStatus

Available for mongod only.仅适用于mongod

Default: false

A boolean flag that determines whether the db.serverStatus() method and serverStatus command return opWriteConcernCounters information. 一个布尔标志,用于确定db.serverStatus()方法和serverStatus命令是否返回opWriteConcernCounters信息。[1]

mongod --setParameter reportOpWriteConcernCountersInServerStatus=true
[1] Enabling reportOpWriteConcernCountersInServerStatus can have a negative performance impact; specifically, when running without TLS.启用reportOpWriteConcernCountersInServerStatus可能会对性能产生负面影响;特别是在没有TLS的情况下运行时。
slowConnectionThresholdMillis

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

Available for both mongod and mongos.适用于mongodmongos

Default: 100

Sets the time limit in milliseconds to log the establishment of slow server connections.设置记录慢速服务器连接建立的时间限制(以毫秒为单位)。

If a connection takes longer to establish than the slowConnectionThresholdMillis parameter, an event is added to the log with the message msg field set to "Slow connection establishment".如果建立连接所需的时间比slowConnectionThresholdMillis参数长,则会在日志中添加一个事件,并将消息msg字段设置为"Slow connection establishment"(慢速连接建立)。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets slowConnectionThresholdMillis to 250 milliseconds.以下示例将slowConnectionThresholdMillis设置为250毫秒。

mongod --setParameter slowConnectionThresholdMillis=250

Or, if using the setParameter command within mongosh:或者,如果在mongosh中使用setParameter命令:

db.adminCommand( { setParameter: 1, slowConnectionThresholdMillis: 250 } )

Warning

tcmallocAggressiveMemoryDecommit is deprecated in 8.0. MongoDB 8.0 uses an updated version of tcmalloc that improves memory fragmentation and management. See tcmalloc upgrade for more information. tcmallocAggressiveVemoryDecommit在8.0中已被弃用。MongoDB 8.0使用tcmalloc的更新版本,改进了内存分片和管理。有关更多信息,请参阅tcmalloc升级To release memory back to the operating system, consider using tcmallocEnableBackgroundThread instead.要将内存释放回操作系统,请考虑改用tcmallocEnableBackgroundThread

tcmallocEnableBackgroundThread

Available for both mongod and mongos.适用于mongodmongos

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

Type: boolean

Default: true

If set to true, tcmallocEnableBackgroundThread creates a background thread that periodically releases memory back to the operating system. 如果设置为truetcmallocEnableBackgroundThread将创建一个后台线程,定期将内存释放回操作系统。The value of tcmallocReleaseRate determines the rate, in bytes per second, at which the background thread releases memory.tcmallocReleaseRate的值决定了后台线程释放内存的速率,单位为字节每秒。

Note

If tcmallocEnableBackgroundThread is true and tcmallocReleaseRate is 0, MongoDB still releases memory.如果tcmallocEnableBackgroundThreadtruetcmallocReleaseRate0,MongoDB仍会释放内存。

For improved memory usage, we recommend using the default value of true. To learn more about improvements to performance and memory management, see Upgraded TCMalloc.为了提高内存使用率,我们建议使用默认值true。要了解有关性能和内存管理改进的更多信息,请参阅升级的TCMalloc

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

The following operation sets tcmallocEnableBackgroundThread to false:以下操作将tcmallocEnableBackgroundThread设置为false

mongod --setParameter "tcmallocEnableBackgroundThread=false"
tcmallocReleaseRate

Available for both mongod and mongos.适用于mongodmongos

Changed in version 8.0.在版本8.0中的更改。

Default: 0

Specifies the TCMalloc release rate in bytes per second. Release rate refers to the rate at which MongoDB releases unused memory to the system. 指定TCMalloc释放速率,单位为字节每秒。释放速率是指MongoDB向系统释放未使用内存的速率。If tcmallocReleaseRate is set to 0 MongoDB doesn't release memory back to the system. Increase this value to return memory faster; decrease it to return memory slower.如果tcmallocReleaseRate设置为0,MongoDB不会将内存释放回系统。增加此值可更快地返回内存;减小它以更慢地返回内存。

Note

If tcmallocEnableBackgroundThread is true and tcmallocReleaseRate is 0, MongoDB still releases memory.如果tcmallocEnableBackgroundThreadtruetcmallocReleaseRate0,MongoDB仍会释放内存。

Starting in MongoDB 8.0, the default value of tcmallocReleaseRate is reduced to 0 due to a tcmalloc upgrade that prioritizes CPU performance over memory release.从MongoDB 8.0开始,由于tcmalloc升级优先考虑CPU性能而非内存释放,tcmallocReleaseRate的默认值降低为0。

In earlier versions, MongoDB used an older version of tcmalloc that:在早期版本中,MongoDB使用了tcmalloc的旧版本,该版本:

  • Set the default tcmallocReleaseRate to 1.将默认tcmallocReleaseRate设置为1
  • Accepted values for tcmallocReleaseRate between 0 and 10, inclusive.tcmallocReleaseRate的接受值介于010之间(包括0和10)。

Important

If you run MongoDB on a platform that uses tcmalloc-gperf such as Windows, PPC, or s390x, tcmallocReleaseRate has the same behavior as earlier MongoDB versions.如果你在使用tcmalloc-gperf的平台上运行MongoDB,如Windows、PPC或s390x,tcmallocReleaseRate的行为与早期的MongoDB版本相同。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

To modify the release rate during run time, you can use the setParameter command. For example:要在运行时修改释放速率,可以使用setParameter命令。例如:

db.adminCommand( { setParameter: 1, tcmallocReleaseRate: 2097152 } )

You can also set tcmallocReleaseRate at startup time; for example:您还可以在启动时设置tcmallocReleaseRate;例如:

mongod --setParameter "tcmallocReleaseRate=2097152"
tcpFastOpenClient

Available for both mongod and mongos.适用于mongodmongos

Default: true

Linux Operating System Only

Enables support for outbound TCP Fast Open (TFO) connections from the mongod/mongos to a client. TFO requires both the client and the mongod/mongos host machine support and enable TFO.支持从mongod/mongos到客户端的出站TCP快速开放(TFO)连接。TFO需要客户端和mongod/mongos主机的支持,并启用TFO。

Linux operating systems running Linux Kernel 4.11 or later can support outbound TFO.运行Linux Kernel 4.11或更高版本的Linux操作系统可以支持出站TFO。

Set the value of /proc/sys/net/ipv4/tcp_fastopen to enable outbound TFO connections:设置/proc/sys/net/ipv4/tcp_fastopen的值以启用出站TFO连接:

  • 1 to enable only outbound TFO connections.仅启用出站TFO连接。
  • 3 to enable inbound and outbound TFO connections.以启用入站和出站TFO连接。

This parameter has no effect if the host operating system does not support or is not configured to support TFO connections.如果主机操作系统不支持或未配置为支持TFO连接,则此参数无效。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

tcpFastOpenQueueSize

Available for both mongod and mongos.适用于mongodmongos

Default: 1024

As part of establishing a TCP Fast Open (TFO) connection, the client submits a valid TFO cookie to the mongod/mongos before completion of the standard TCP 3-way handshake. 作为建立TCP快速开放(TFO)连接的一部分,客户端在完成标准TCP三次握手之前向mongod/mongos提交一个有效的TFO cookie。The mongod/mongos keeps a queue of all such pending TFO connections.mongod/mongos保留了一个所有此类未决TFO连接的队列。

The tcpFastOpenQueueSize parameter sets the size of the queue of pending TFO connections. tcpFastOpenQueueSize参数设置挂起的TFO连接的队列大小。While the queue is full, the mongod/mongos falls back to the normal three-way handshake for incoming client requests and ignores the presence of TFO cookies. 当队列已满时,mongod/mongos会对传入的客户端请求恢复正常的三方握手,并忽略TFO Cookie的存在。Once the queue size falls back below the limit, the mongod/mongos begins accepting new TFO cookies.一旦队列大小回落到限制以下,mongod/mongos就开始接受新的TFO Cookie。

  • Increasing the default queue size may improve the effect of TFO on network performance. However, large queue sizes also increase the risk of server resource exhaustion due to excessive incoming TFO requests.增加默认队列大小可能会改善TFO对网络性能的影响。但是,由于传入的TFO请求过多,较大的队列大小也会增加服务器资源耗尽的风险。
  • Decreasing the default queue size may reduce the risk of resource server resource exhaustion due to excessive incoming TFO requests. However, small queue sizes may also reduce the effect of TFO on network performance.减小默认队列大小可以降低由于传入TFO请求过多而导致的资源服务器资源耗尽的风险。然而,较小的队列大小也可能降低TFO对网络性能的影响。

    The minimum queue size is 0. A queue of 0 effectively disables TFO.最小队列大小为00的队列有效地禁用了TFO。

This parameter has no effect on host operating systems that do not support or are not configured for TFO connections.此参数对不支持或未配置TFO连接的主机操作系统没有影响。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

tcpFastOpenServer

Available for both mongod and mongos.适用于mongodmongos

Default: true

Enables support for accepting inbound TCP Fast Open (TFO) connections to the mongod/mongos from a client. TFO requires both the client and mongod/mongos host machine support and enable TFO:支持从客户端接受到mongod/mongos的入站TCP快速开放(TFO)连接。TFO需要客户端和mongod/mongos主机支持,并启用TFO:

Windows

The following Windows operating systems support TFO:以下Windows操作系统支持TFO:

  • Microsoft Windows Server 2016 and later.微软Windows Server 2016及更高版本。
  • Microsoft Windows 10 Update 1607 and later.Microsoft Windows 10 Update 1607及更高版本。
macOS
macOS 10.11 (El Capitan) and later support TFO.
Linux

Linux operating systems running Linux Kernel 3.7 or later can support inbound TFO.运行Linux Kernel 3.7或更高版本的Linux操作系统可以支持入站TFO。

Set the value of /proc/sys/net/ipv4/tcp_fastopen to enable inbound TFO connections:设置/proc/sys/net/ipv4/tcp_fastopen的值以启用入站TFO连接:

  • Set to 2 to enable only inbound TFO connections.设置为2以仅启用入站TFO连接。
  • Set to 3 to enable inbound and outbound TFO connections.设置为3以启用入站和出站TFO连接。

This parameter has no effect if the host operating system does not support or is not configured to support TFO connections.如果主机操作系统不支持或未配置为支持TFO连接,则此参数无效。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

ttlMonitorEnabled

Available for mongod only.仅适用于mongod

Default: true

To support TTL Indexes, mongod instances have a background thread that is responsible for deleting documents from collections with TTL indexes.为了支持TTL索引mongod实例有一个后台线程,负责从具有TTL索引的集合中删除文档。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

To disable this worker thread for a mongod, set ttlMonitorEnabled to false, as in the following operations:要为mongod禁用此工作线程,请将ttlMonitorEnabled设置为false,如下操作所示:

db.adminCommand( { setParameter: 1, ttlMonitorEnabled: false } )

Alternately, you may disable the thread at startup time by starting the mongod instance with the following option:或者,您可以在启动时禁用线程,方法是使用以下选项启动mongod实例:

mongod --setParameter ttlMonitorEnabled=false

Important

Do not run production mongod instances with ttlMonitorEnabled disabled, except under guidance from MongoDB support. Preventing TTL document removal can negatively impact MongoDB internal system operations that depend on TTL Indexes.除非在MongoDB支持的指导下,否则不要在禁用ttlMonitorEnabled的情况下运行生产mongod实例。阻止TTL文档删除可能会对依赖TTL索引的MongoDB内部系统操作产生负面影响。

watchdogPeriodSeconds

Available for mongod only.仅适用于mongod

Type: integer

Default: -1 (disabled)

Determines how frequent the Storage Node Watchdog checks the status of the monitored filesystems:确定存储节点监视器检查受监视文件系统状态的频率:

Valid values for watchdogPeriodSeconds are:watchdogPeriodSeconds的有效值为:

Note

  • If a filesystem on a monitored directory becomes unresponsive, it can take a maximum of nearly twice the value of watchdogPeriodSeconds to terminate the mongod.如果受监视目录上的文件系统变得没有响应,则最多需要watchdogPeriodSeconds值的两倍来终止mongod
  • If any of its monitored directory is a symlink to other volumes, the Storage Node Watchdog does not monitor the symlink target. 如果其任何受监视的目录是指向其他卷的符号链接,则存储节点监视器不会监视符号链接目标。For example, if the mongod uses storage.directoryPerDB: true (or --directoryperdb) and symlinks a database directory to another volume, the Storage Node Watchdog does not follow the symlink to monitor the target.例如,如果mongod使用storage.directoryPerDB: true(或 --directoryperdb)并将数据库目录符号链接到另一个卷,则存储节点监视器不会遵循符号链接来监视目标。

To enable Storage Node Watchdog, watchdogPeriodSeconds must be set during startup.要启用存储节点监视器,必须在启动期间设置watchdogPeriodSeconds

mongod --setParameter watchdogPeriodSeconds=60

You can only enable the Storage Node Watchdog at startup. 您只能在启动时启用存储节点监视器However, once enabled, you can pause the Storage Node Watchdog or change the watchdogPeriodSeconds during run time.但是,一旦启用,您可以在运行时暂停存储节点监视器或更改watchdogPeriodSeconds

Once enabled,一旦启用,

Note

It is an error to set watchdogPeriodSeconds at run time if the Storage Node Watchdog was not enabled at startup time.如果启动时未启用存储节点监视器,则在运行时设置watchdogPeriodSeconds是错误的。

Logging Parameters测井参数

enableDetailedConnectionHealthMetricLogLines

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

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: true

Determines whether to enable specific log messages related to cluster connection health metrics. 确定是否启用与群集连接健康指标相关的特定日志消息。If enableDetailedConnectionHealthMetricLogLines is set to false, the following log messages are turned off, but MongoDB still collects data on the cluster connection health metrics:如果enableDetailedConnectionHealthMetricLogLines设置为false,则以下日志消息将被关闭,但MongoDB仍会集合集群连接健康指标的数据:

Log Message日志消息Description描述
Accepted TLS connection from peer接受来自对等端的TLS连接Indicates that the server successfully parsed the peer certificate during the TLS handshake with an accepted ingress connection.表示服务器在与接受的入口连接进行TLS握手期间成功解析了对等端证书。
Ingress TLS handshake complete入口TLS握手完成Indicates that the TLS handshake with an ingress connection is complete.表示与入口连接的TLS握手已完成。
Hello completed你好,已完成

Indicates that the initial connection handshake completed on an incoming client connection.表示在传入的客户端连接上完成了初始连接握手。

MongoDB displays the log message only with the first hello command.MongoDB仅使用第一个hello命令显示日志消息。

Auth metrics report认证指标报告Specifies the completion of a step in the authentication conversation.指定身份验证对话中某个步骤的完成。
Received first command on ingress connection since session start or auth handshake自会话启动或身份验证握手以来,在入口连接上收到第一个命令Indicates that an ingress connection received the first command that is not part of the handshake.表示入口连接接收到的第一个命令不是握手的一部分。
Slow network response send time网络响应发送时间慢Indicates that the time spent, in milliseconds, to send the response back to the client over an ingress connection takes more time than the duration defined by the slowMS server parameter.表示通过入口连接将响应发送回客户端所花费的时间(以毫秒为单位)比slowMS服务器参数定义的持续时间更长。
Completed client-side verification of OCSP request已完成OCSP请求的客户端验证If the peer doesn't include an OCSP response to the TLS handshake when an egress TLS connection is established, the server must send an OCSP request to the certificate authority. 如果在建立出口TLS连接时,对等端没有包含对TLS握手的OCSP响应,则服务器必须向证书颁发机构发送OCSP请求。MongoDB writes this log message when the certificate authority receives the OCSP response.当证书颁发机构收到OCSP响应时,MongoDB会写入此日志消息。
Slow connection establishment连接建立缓慢Indicates that the time taken to send a response back to the client over an ingress connection takes longer than the threshold specified with the slowConnectionThresholdMillis parameter. MongoDB also emits this log message when the connection establishment times out.表示通过入口连接将响应发送回客户端所花费的时间长于使用slowConnectionThresholdMillis参数指定的阈值。当连接建立超时时,MongoDB也会发出此日志消息。
Operation timed out while waiting to acquire connection等待获取连接时操作超时Indicates that an operation timed out while waiting to acquire an egress connection.表示在等待获取出口连接时操作超时。
Acquired connection for remote operation and completed writing to wire已获取远程操作连接,并已完成对线路的写入Indicates that the server took one millisecond or longer to write an outgoing request on an egress connection, counting from the instant when the connection establishes.表示服务器在出口连接上写入传出请求需要一毫秒或更长时间,从连接建立的时刻开始计算。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
logComponentVerbosity

Available for both mongod and mongos.适用于mongodmongos

Default: 0

Sets the verbosity levels of various components for log messages. The verbosity level determines the amount of Informational and Debug messages MongoDB outputs. 设置日志消息的各种组件的详细程度。详细程度决定了MongoDB输出的信息和调试消息的数量。[2]

The verbosity level can range from 0 to 5:详细程度可以从05

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,用于包含信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15会增加详细程度,以包含调试消息。

For a component, you can also specify -1 to inherit the parent's verbosity level.对于组件,您还可以指定-1来继承父级的详细程度。

To specify the verbosity level, use a document similar to the following:要指定详细程度,请使用类似于以下内容的文档:

{
verbosity: <int>,
<component1>: { verbosity: <int> },
<component2>: {
verbosity: <int>,
<component3>: { verbosity: <int> }
},
...
}

For the components, you can specify just the <component>: <int> in the document, unless you are setting both the parent verbosity level and that of the child component(s) as well:对于组件,您可以在文档中仅指定<component>: <int>,除非您同时设置父组件和子组件的详细程度:

{
verbosity: <int>,
<component1>: <int> ,
<component2>: {
verbosity: <int>,
<component3>: <int>
}
...
}

The top-level verbosity field corresponds to systemLog.verbosity which sets the default level for all components. 顶级verbosity字段对应于systemLog.verbosity,它为所有组件设置默认级别。The default value of systemLog.verbosity is 0.systemLog.verbosity的默认值为0

The components correspond to the following settings:这些组件对应于以下设置:

Unless explicitly set, the component has the verbosity level of its parent. 除非明确设置,否则组件具有其父级的详细程度。For example, storage is the parent of storage.journal. 例如,storagestorage.journal的父级。That is, if you specify a storage verbosity level, this level also applies to:也就是说,如果指定了storage详细程度级别,则该级别也适用于:

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the default verbosity level to 1, the query to 2, the storage to 2, and the storage.journal to 1.

db.adminCommand( {
setParameter: 1,
logComponentVerbosity: {
verbosity: 1,
query: { verbosity: 2 },
storage: {
verbosity: 2,
journal: {
verbosity: 1
}
}
}
} )

You can also set parameter logComponentVerbosity at startup time, passing the verbosity level document as a string.您还可以在启动时设置参数logComponentVerbosity,将详细程度级别文档作为字符串传递。

mongod --setParameter "logComponentVerbosity={command: 3}"

mongosh also provides the db.setLogLevel() to set the log level for a single component. For various ways to set the log verbosity level, see Configure Log Verbosity Levels.

[2] Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. For example, if the verbosity level is 2, MongoDB logs D2. In previous versions, MongoDB log messages only specified D for Debug level.
logLevel

Available for both mongod and mongos.适用于mongodmongos

Default: 0 (informational)

Specify an integer between 0 and 5 signifying the verbosity of the logging, where 5 is the most verbose. 指定一个介于05之间的整数,表示日志的详细程度,其中5是最详细的。[3]

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets the logLevel to 2:

db.adminCommand( { setParameter: 1, logLevel: 2 } )
[3] Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. 从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs D2. In previous versions, MongoDB log messages only specified D for Debug level.例如,如果详细程度为2,MongoDB会记录D2。在以前的版本中,MongoDB日志消息仅将调试级别指定为D
maxLogSizeKB

Available for both mongod and mongos.适用于mongodmongos

Type: non-negative integer

Default: 10

Specifies the maximum size, in kilobytes, for an individual attribute field in a log entry; attributes exceeding this limit are truncated.指定日志条目中单个属性字段的最大大小(以千字节为单位);超过此限制的属性将被截断。

Truncated attribute fields print field content up to the maxLogSizeKB limit and excise field content past that limit, retaining valid JSON formatting. 截断的属性字段打印的字段内容不超过maxLogSizeKB限制,并删除超过该限制的字段内容,保留有效的JSON格式。Log entries that contain truncated attributes append a truncated object to the end of the log entry.包含截断属性的日志条目将truncated(截断)对象附加到日志条目的末尾。

See log message truncation for more information.有关详细信息,请参阅日志消息截断

A value of 0 disables truncation entirely. Negative values for this parameter are not valid.值为0时完全禁用截断。此参数的负值无效。

Warning

Using a large value, or disabling truncation with a value of 0, may adversely affect system performance and negatively impact database operations.使用大值或禁用值为0的截断可能会对系统性能产生不利影响,并对数据库操作产生负面影响。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets the maximum log line size to 20 kilobytes:以下示例将最大日志行大小设置为20 KB:

mongod --setParameter maxLogSizeKB=20
quiet

Available for both mongod and mongos.适用于mongodmongos

Sets quiet logging mode. If 1, mongod will go into a quiet logging mode which will not log the following events/activities:设置安静日志记录模式。如果为1mongod将进入安静日志模式,不会记录以下事件/活动:

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Consider the following example which sets the quiet parameter to 1:考虑以下将quiet参数设置为1的示例:

db.adminCommand( { setParameter: 1, quiet: 1 } )
redactClientLogData

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Note

Enterprise Feature

Available in MongoDB Enterprise only.仅适用于MongoDB企业版。

Configure the mongod or mongos to redact any message accompanying a given log event before logging. This prevents the program from writing potentially sensitive data stored on the database to the diagnostic log. Metadata such as error or operation codes, line numbers, and source file names are still visible in the logs.

Use redactClientLogData in conjunction with Encryption at Rest and TLS/SSL (Transport Encryption) to assist compliance with regulatory requirements.

To enable log redaction at startup, you can either:

You can't use the --setParameter option to set redactClientLogData at startup.

To enable log redaction on a running mongod or mongos, use the following command:

db.adminCommand( { setParameter: 1, redactClientLogData : true } )
redactEncryptedFields

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

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: true

Configures mongod and mongos to redact field values of encrypted Binary data from all log messages.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
suppressNoTLSPeerCertificateWarning

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: false

By default, a mongod or mongos with TLS/SSL enabled and net.ssl.allowConnectionsWithoutCertificates : true lets clients connect without providing a certificate for validation while logging an warning. Set suppressNoTLSPeerCertificateWarning to 1 or true to suppress those warnings.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

The following operation sets suppressNoTLSPeerCertificateWarning to true:

db.adminCommand( { setParameter: 1, suppressNoTLSPeerCertificateWarning: true} )
traceExceptions

Available for both mongod and mongos.适用于mongodmongos

Configures mongod to log full source code stack traces for every database and socket C++ exception, for use with debugging. If true, mongod will log full stack traces.

This parameter is only available at runtime. To set the parameter, use the setParameter command.setParameter

Consider the following example which sets the traceExceptions to true:

db.adminCommand( { setParameter: 1, traceExceptions: true } )

Diagnostic Parameters

To facilitate analysis of the MongoDB server behavior by MongoDB engineers, MongoDB logs server statistics to diagnostic files at periodic intervals.

For mongod, the diagnostic data files are stored in the diagnostic.data directory under the mongod instance's --dbpath or storage.dbPath.

For mongos, the diagnostic data files, by default, are stored in a directory under the mongos instance's --logpath or systemLog.path directory. The diagnostic data directory is computed by truncating the logpath's file extension(s) and concatenating diagnostic.data to the remaining name.

For example, if mongos has --logpath /var/log/mongodb/mongos.log.201708015, then the diagnostic data directory is /var/log/mongodb/mongos.diagnostic.data/ directory. To specify a different diagnostic data directory for mongos, set the diagnosticDataCollectionDirectoryPath parameter.

The following parameters support diagnostic data capture (FTDC):

Note

The default values for the diagnostic data capture interval and the maximum sizes are chosen to provide useful data to MongoDB engineers with minimal impact on performance and storage size. Typically, these values will only need modifications as requested by MongoDB engineers for specific diagnostic purposes.

diagnosticDataCollectionDirectoryPath

Available for mongos only.仅适用于mongos

Type: String

Warning

If Full Time Diagnostic Data Capture (FTDC) is disabled with diagnosticDataCollectionEnabled or if systemLog.destination is set to syslog, you must restart mongos after setting diagnosticDataCollectionDirectoryPath.

Specify the directory for the diagnostic directory for mongos. If the directory does not exist, mongos creates the directory.

If unspecified, the diagnostic data directory is computed by truncating the mongos instance's --logpath or systemLog.path file extension(s) and concatenating diagnostic.data.

For example, if mongos has --logpath /var/log/mongodb/mongos.log.201708015, then the diagnostic data directory is /var/log/mongodb/mongos.diagnostic.data/.

If the mongos cannot create the specified directory, the diagnostic data capture is disabled for that instance. mongos may not be able to create the specified directory if a file with the same name already exists in the path or if the process does not have permissions to create the directory.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
diagnosticDataCollectionDirectorySizeMB

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 250 (500 in sharded clusters)

Specifies the maximum size, in megabytes, of the diagnostic.data directory. If directory size exceeds this number, the oldest diagnostic files in the directory are automatically deleted based on the timestamp in the file name.

Changed in version 8.0.在版本8.0中的更改。 diagnosticDataCollectionDirectorySizeMB has a default value of 400 MB for mongos and mongod instances used in sharded clusters. mongod instances used in replica set or as standalone servers have a default value of 200 MB.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the maximum size of the directory to 250 megabytes:

mongod --setParameter diagnosticDataCollectionDirectorySizeMB=250

The minimum value for diagnosticDataCollectionDirectorySizeMB is 10 megabytes. diagnosticDataCollectionDirectorySizeMB must be greater than maximum diagnostic file size diagnosticDataCollectionFileSizeMB.

diagnosticDataCollectionEnabled

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: true

Determines whether to enable the collecting and logging of data for diagnostic purposes. Diagnostic logging is enabled by default.确定是否启用用于诊断目的的数据集合和记录。默认情况下启用诊断日志记录。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following disables the diagnostic collection:

mongod --setParameter diagnosticDataCollectionEnabled=false
diagnosticDataCollectionFileSizeMB

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 10

Specifies the maximum size, in megabytes, of each diagnostic file. If the file exceeds the maximum file size, MongoDB creates a new file.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the maximum size of each diagnostic file to 20 megabytes:

mongod --setParameter diagnosticDataCollectionFileSizeMB=20

The minimum value for diagnosticDataCollectionFileSizeMB is 1 megabyte.

diagnosticDataCollectionPeriodMillis

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 1000

Specifies the interval, in milliseconds, at which to collect diagnostic data.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, the following sets the interval to 5000 milliseconds or 5 seconds:

mongod --setParameter diagnosticDataCollectionPeriodMillis=5000

The minimum value for diagnosticDataCollectionPeriodMillis is 100 milliseconds.

Replication and Consistency

allowMultipleArbiters

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

Available for mongod only.仅适用于mongod

Type: boolean

Default: false

Specifies whether the replica set allows the use of multiple arbiters.

The use of multiple arbiters is not recommended:

  • Multiple arbiters prevent the reliable use of the majority write concern. MongoDB counts arbiters in calculating a membership majority, but arbiters do not store data. With the inclusion of multiple arbiters, it's possible for a majority write operation to return success before the write replicates to a majority of data bearing nodes.
  • Multiple arbiters allow replica sets to accept writes even when the replica set doesn't have sufficient secondaries for data replication.

For more information, see Concerns with Multiple Arbiters.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

mongod --setParameter allowMultipleArbiters=true
connectTimeoutMs

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 10000

Sets the connection timeout, in milliseconds, for the replica set monitor.

This parameter is only available at startup. If you set this parameter, it must be greater than or equal to 500.

The following example sets connectTimeoutMs for a mongod instance to 700 milliseconds:

mongod --setParameter connectTimeoutMs=700
createRollbackDataFiles

Available for mongod only.仅适用于mongod

Type: boolean

Default: true

Flag that determines whether MongoDB creates rollback files that contains documents affected during a rollback.

By default, createRollbackDataFiles is true and MongoDB creates the rollback files.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets createRollbackDataFiles to false so that the rollback files are not created:

mongod --setParameter createRollbackDataFiles=false

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, createRollbackDataFiles: false } )

For more information, see Collect Rollback Data.

disableSplitHorizonIPCheck

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

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: false

To configure cluster nodes for split horizon DNS, use host names instead of IP addresses.

Starting in MongoDB v5.0, replSetInitiate and replSetReconfig reject configurations that use IP addresses instead of hostnames.

Use disableSplitHorizonIPCheck to modify nodes that cannot be updated to use host names. The parameter only applies to the configuration commands.

mongod and mongos do not rely on disableSplitHorizonIPCheck for validation at startup. Legacy mongod and mongos instances that use IP addresses instead of host names can start after an upgrade.

Instances that are configured with IP addresses log a warning to use host names instead of IP addresses.

To allow configuration changes using IP addresses, set disableSplitHorizonIPCheck=true using the command line:

/usr/local/bin/mongod  --setParameter disableSplitHorizonIPCheck=true -f /etc/mongod.conf

This parameter is only available at startup. To set the parameter, use the setParameter setting.

setParameter:
disableSplitHorizonIPCheck: true
enableFlowControl

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: true

Enables or disables the mechanism that controls the rate at which the primary applies its writes with the goal of keeping the secondary members' majority committed lag under a configurable maximum value.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
enableOverrideClusterChainingSetting

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

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: false

If enableOverrideClusterChainingSetting is true, replica set secondary members can replicate data from other secondary members even if settings.chainingAllowed is false.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the enableOverrideClusterChainingSetting for a mongod instance to true:

mongod --setParameter enableOverrideClusterChainingSetting=true
flowControlTargetLagSeconds

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 10

The target maximum majority committed lag when running with flow control. When flow control is enabled, the mechanism attempts to keep the majority committed lag under the specified seconds. The parameter has no effect if flow control is disabled.

The specified value must be greater than 0.

In general, the default settings should suffice; however, if modifying from the default value, decreasing, rather than increasing, the value may prove to be more useful.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
flowControlWarnThresholdSeconds

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 10

The amount of time to wait to log a warning once the flow control mechanism detects the majority commit point has not moved.

The specified value must be greater than or equal to 0, with 0 to disable warnings.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
heartBeatFrequencyMs

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 10000

When replicaSetMonitorProtocol is set to 'sdam', heartBeatFrequencyMs determines how long, in milliseconds, to wait between hello requests.

When replicaSetMonitorProtocol is set to 'streamable', heartBeatFrequencyMs determines how long, in milliseconds, to wait between hello round trip time (RTT) measurements. RTT measurements are used in server selection.

This parameter is only available at startup. If you set this parameter, it must be greater than or equal to 500.

The following example sets heartBeatFrequencyMs in a mongod instance to 700 milliseconds:

mongod --setParameter heartBeatFrequencyMs=700
initialSyncIndexBuildMemoryPercentage

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

Available for mongod only.仅适用于mongod

Type: double

Default: 10.0

The percentage of system memory that MongoDB allocates for index builds during initial sync. The amount of system memory used is bound by the values of initialSyncIndexBuildMemoryMinMB and initialSyncIndexBuildMemoryMaxMB.

You can specify a value between 0.0 and 80.0, inclusive.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set the initialSyncIndexBuildMemoryPercentage for a mongod instance to 40%:

mongod --setParameter initialSyncIndexBuildMemoryPercentage=40
initialSyncIndexBuildMemoryMaxMB

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 16384

The maximum amount of system memory, in megabytes, that MongoDB can use for index builds during initial sync.

You can specify a value between 50 and 10000000.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set the initialSyncIndexBuildMemoryMaxMB for a mongod instance to 20000 MB:

mongod --setParameter initialSyncIndexBuildMemoryMaxMB=20000
initialSyncIndexBuildMemoryMinMB

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

Available for mongod only.仅适用于mongod

Type: Integer

Default: 200

The minimum amount of system memory, in megabytes, that MongoDB can use for index builds during initial sync.

You can specify a value between 50 and 10000000.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set the initialSyncIndexBuildMemoryMinMB for a mongod instance to 60 MB:

mongod --setParameter initialSyncIndexBuildMemoryMinMB=60
initialSyncMethod

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

Available for mongod only.仅适用于mongod

Type: String

Default: logical

Available only in MongoDB Enterprise.

Method used for initial sync.

Set to logical to use logical initial sync. Set to fileCopyBased to use file copy based initial sync.

This parameter only affects the sync method for the member on which it is specified. Setting this parameter on a single replica set member does not affect the sync method of any other replica set members.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

initialSyncSourceReadPreference

Available for mongod only.仅适用于mongod

Type: String

The preferred source for performing initial sync. Specify one of the following read preference modes:

If the replica set has disabled chaining, the default initialSyncSourceReadPreference read preference mode is primary.

You cannot specify a tag set or maxStalenessSeconds to initialSyncSourceReadPreference.

If the mongod cannot find a sync source based on the specified read preference, it logs an error and restarts the initial sync process. The mongod exits with an error if it cannot complete the initial sync process after 10 attempts. For more information on sync source selection, see Initial Sync Source Selection.

initialSyncSourceReadPreference takes precedence over the replica set's settings.chainingAllowed setting when selecting an initial sync source. After a replica set member successfully completes initial sync, it defers to the value of chainingAllowed when selecting a replication sync source.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

initialSyncTransientErrorRetryPeriodSeconds

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 86400

The amount of time in seconds a secondary performing initial sync attempts to resume the process if interrupted by a transient network error. The default value is equivalent to 24 hours.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
localLogicalSessionTimeoutMinutes

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 30

Warning

For testing purposes only

This parameter is intended for testing purposes only and not for production use.

The time in minutes that a session remains active after its most recent use. Sessions that have not received a new read/write operation from the client or been refreshed with refreshSessions within this threshold are cleared from the cache. State associated with an expired session may be cleaned up by the server at any time.

This parameter applies only to the instance on which it is set. To set this parameter on replica sets and sharded clusters, you must specify the same value on every member; otherwise, sessions will not function properly.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the localLogicalSessionTimeoutMinutes for a test mongod instance to 20 minutes:

mongod --setParameter localLogicalSessionTimeoutMinutes=20
localThresholdMs

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 15

Defines the length of the latency window used in server selection in milliseconds.

This parameter is only available at startup. If you set this parameter, it must be greater than or equal to 0.

The following example sets localThresholdMs for a mongod instance to 20 milliseconds:

mongod --setParameter localThresholdMs=20
logicalSessionRefreshMillis

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 300000 (5 minutes)

The interval (in milliseconds) at which the cache refreshes its logical session records against the main session store.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the logicalSessionRefreshMillis for a mongod instance to 10 minutes:

mongod --setParameter logicalSessionRefreshMillis=600000
maxAcceptableLogicalClockDriftSecs

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 31536000 (1 year)

The maximum amount by which the current cluster time can be advanced; specifically, maxAcceptableLogicalClockDriftSecs is the maximum difference between the new value of the cluster time and the current cluster time. Cluster time is a logical time used for ordering of operations.

You cannot advance the cluster time to a new value if the new cluster time differs from the current cluster time by more than maxAcceptableLogicalClockDriftSecs.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the maxAcceptableLogicalClockDriftSecs for a mongod instance to 15 minutes:

mongod --setParameter maxAcceptableLogicalClockDriftSecs=900
maxNumSyncSourceChangesPerHour

Available for both mongod and mongos.适用于mongodmongos

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

Type: integer

Default: 3

Sync sources are evaluated each time a sync source is updated and each time a node fetches a batch of oplog entries. If there are more than maxNumSyncSourceChangesPerHour source changes in an hour, the node temporarily stops re-evaluating that sync source. If this parameter is set with a high value, the node may make unnecessary source changes.

This parameter will not prevent a node from starting to sync from another node if it doesn't have a sync source. The node will re-evaluate if a sync source becomes invalid. Similarly, if the primary changes and chaining is disabled, the node will update to sync from the new primary.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
maxSessions

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 1000000

The maximum number of sessions that can be cached.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the maxSessions for a mongod instance to 1000:

mongod --setParameter maxSessions=1000
mirrorReads

Available for mongod only.仅适用于mongod

Type: Document

Default: { samplingRate: 0.01, maxTimeMS: 1000 }

Specifies the settings for mirrored reads for the mongod instance. The settings only take effect when the member is a primary.

The parameter mirrorReads takes a JSON document with the following fields:

Field字段Description描述
samplingRate

The sampling rate used to mirror a subset of operations that support mirroring to a subset of electable (specifically, priority greater than 0) secondaries. That is, the primary mirrors reads to each electable secondary at the specified sampling rate.

Valid values are:

0.0Turns off mirroring.
1.0The primary mirrors all operations that supports mirroring to each electable secondary.
Number between 0.0 and 1.0 (exclusive)The primary randomly samples each electable secondary at the specified rate to be sent mirrored reads.

For example, given a replica set with a primary and two electable secondaries and a sampling rate of 0.10, the primary mirrors reads to each electable secondary at the sampling rate of 10 percent such that one read may be mirrored to one secondary and not to the other or to both or to neither. That is, if the primary receives 100 operations that can be mirrored, the sampling rate of 0.10 may result in 8 reads being mirrored to one secondary and 13 reads to the other or 10 to each, etc.

The default value is 0.01.

maxTimeMS

The maximum time in milliseconds for the mirrored reads. The default value is 1000.

The maxTimeMS for the mirrored reads is separate from the maxTimeMS of the original read being mirrored.

targetedMirroring

Contains fields to configure how you target specific nodes for cache warming. For more information on targeted mirroring, see Targeted Mirrored Reads.

Includes the following fields:

tag

Defaults to an empty BSONObj. The replica set tag that you can use to target nodes for mirroring. You can configure a node for targeted mirroring using the following syntax:

tag: { "<tag1>": "<string1>" }

You can only supply one tag. All nodes within the same replica set that have these tags are targeted.

samplingRate

Type: Float

Range: 0.0 to 1.0 (inclusive)

The rate at which targeted reads are mirrored to the host or hosts. A rate of 0.0 means no reads are mirrored, and a rate of 1.0 means all reads are mirrored. Although samplingRate defaults to 0.01, the targetedMirroring feature is off by default, since the tag field defaults to empty.

maxTimeMS

Type: int

The maximum time in milliseconds before the mirrored read times out. The minumum value for maxTimeMS is 0. Defaults to 1000.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

If you specify from the configuration file or on the command line, enclose the mirrorReads document in quotes.

For example, the following sets the mirror reads sampling rate to 0.10 from the command line:

mongod --setParameter mirrorReads='{ samplingRate: 0.10 }'

Or, to specify in a configuration file:

setParameter:
mirrorReads: '{samplingRate: 0.10}'

Or if using the setParameter command in a mongosh session that is connected to a running mongod, do not enclose the document in quotes:

db.adminCommand( { setParameter: 1, mirrorReads: { samplingRate: 0.10 } } )
mirrorReadsMaxConnPoolSize

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

Type: int

Default: 4

Controls the maximum number of connections in the mirroring pool. This parameter affects both general and targeted mirrored reads. mirrorReadsMaxConnPoolSize has a minimum value of 1.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
oplogBatchDelayMillis

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

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 0

The number of milliseconds to delay applying batches of oplog operations on secondary nodes. By default, oplogBatchDelayMillis is 0, meaning oplog batches are applied with no delay. When there is no delay, MongoDB may apply frequent, small oplog batches to secondaries.

Increasing oplogBatchDelayMillis causes MongoDB to apply oplog batches less frequently on secondaries, with each batch containing larger amounts of data. This reduces IOPS on secondaries, but adds latency for writes with write concern "majority".

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, run the following command to set the oplogBatchDelayMillis for a mongod instance to 20 milliseconds:

mongod --setParameter oplogBatchDelayMillis=20
oplogFetcherUsesExhaust

Available for mongod only.仅适用于mongod

Type: boolean

Default: true

Enables or disables streaming replication. Set the value to true to enable streaming replication.

Set the value to false to disable streaming replication. If disabled, secondaries fetch batches of oplog entries by issuing a request to their sync from source and waiting for a response. This requires a network roundtrip for each batch of oplog entries.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

oplogInitialFindMaxSeconds

Available for mongod only.仅适用于mongod

Type: integer

Default: 60

Maximum time in seconds for a member of a replica set to wait for the find command to finish during data synchronization.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
periodicNoopIntervalSecs

Available for mongod only.仅适用于mongod

Type: integer

Default: 10

The duration in seconds between noop writes on each individual node.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

Note

To modify this value for a MongoDB Atlas cluster, you must contact Atlas Support.

The following example sets the periodicNoopIntervalSecs to 1 second at startup:

mongod --setParameter periodicNoopIntervalSecs=1
replBatchLimitBytes

Available for both mongod and mongos.适用于mongodmongos

Default: 104857600 (100MB)

Sets the maximum oplog application batch size in bytes.

Values can range from 16777216 (16MB) to 104857600 (100MB) inclusive.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets replBatchLimitBytes to 64 MB to limit the oplog application batch size:

mongod --setParameter replBatchLimitBytes=67108864

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, replBatchLimitBytes: 64 * 1024 * 1024 } )
replicaSetMonitorProtocol

Available for both mongod and mongos.适用于mongodmongos

Type: string

Default: "streamable"

Determines which replica set monitor protocol to use. You can set this parameter to "streamable", which is compliant with Server Discovery and Monitoring (SDAM) specification and allows for constant hello requests. You can also set this parameter to "sdam", which is compliant with SDAM specification.

This parameter is only available at startup.

The following example sets replicaSetMonitorProtocol to "sdam" on a mongod instance:

mongod --setParameter replicaSetMonitorProtocol='sdam'
replWriterMinThreadCount

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 0

Minimum number of threads to use to apply replicated operations in parallel. Values can range from 0 to 256 inclusive. You can only set replWriterMinThreadCount at startup and cannot change this setting with the setParameter command.

Parallel application of replication operations uses up to replWriterThreadCount threads. If replWriterMinThreadCount is configured with a value less than replWriterThreadCount, the thread pool will timeout idle threads until the total count of threads in the thread pool is equal to replWriterMinThreadCount.

replWriterMinThreadCount must be configured with a value that is less than or equal to replWriterThreadCount.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

replWriterThreadCount

Available for mongod only.仅适用于mongod

Type: integer

Default: 16

Maximum number of threads to use to apply replicated operations in parallel. Values can range from 1 to 256 inclusive. However, the maximum number of threads used is capped at twice the number of available cores.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

rollbackTimeLimitSecs

Available for mongod only.仅适用于mongod

Type: 64-bit integer

Default: 86400 (1 day)

Maximum age of data that can be rolled back. Negative values for this parameter are not valid.

If the time between the end of the to-be-rolledback instance's oplog and the first operation after the common point (the last point where the source node and the to-be-rolledback node had the same data) exceeds this value, the rollback will fail.

To effectively have an unlimited rollback period, set the value to 2147483647 which is the maximum value allowed and equivalent to roughly 68 years.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
TransactionRecordMinimumLifetimeMinutes

Available for mongod only.仅适用于mongod

Type: integer

Default: 30

The minimum lifetime a transaction record exists in the transactions collection before the record becomes eligible for cleanup.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the TransactionRecordMinimumLifetimeMinutes for a mongod instance to 20 minutes:

mongod --setParameter TransactionRecordMinimumLifetimeMinutes=20
waitForSecondaryBeforeNoopWriteMS

Available for mongod only.仅适用于mongod

Type: integer

Default: 10

The length of time (in milliseconds) that a secondary must wait if the afterClusterTime is greater than the last applied time from the oplog. After the waitForSecondaryBeforeNoopWriteMS passes, if the afterClusterTime is still greater than the last applied time, the secondary makes a no-op write to advance the last applied time.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets the waitForSecondaryBeforeNoopWriteMS to 20 milliseconds:

mongod --setParameter waitForSecondaryBeforeNoopWriteMS=20

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, waitForSecondaryBeforeNoopWriteMS: 20 } )

Sharding Parameters

analyzeShardKeyCharacteristicsDefaultSampleSize

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 10000000

If sampleRate and sampleSize are not set when you run analyzeShardKey, specifies the number of documents to sample when calculating shard key characteristics metrics. Must be greater than 0.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets analyzeShardKeyCharacteristicsDefaultSampleSize to 10000 at startup:

mongod --setParameter analyzeShardKeyCharacteristicsDefaultSampleSize=10000

During run time, you can set or modify the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, analyzeShardKeyCharacteristicsDefaultSampleSize: 10000 } )
analyzeShardKeyMonotonicityCorrelationCoefficientThreshold

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

Available for mongod only.仅适用于mongod

Type: double

Default: 0.7

Specifies the RecordId correlation coefficient threshold used to determine if a shard key is monotonically changing in insertion order. Must be greater than 0 and less than or equal to 1.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets analyzeShardKeyMonotonicityCorrelationCoefficientThreshold to 1 at startup:

mongod --setParameter analyzeShardKeyMonotonicityCorrelationCoefficientThreshold=1

During run time, you can set or modify the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, analyzeShardKeyMonotonicityCorrelationCoefficientThreshold: 1 } )
analyzeShardKeyNumMostCommonValues

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 5

Specifies the number of most common shard key values to return. If the collection contains fewer unique shard keys than this value, analyzeShardKeyNumMostCommonValues returns that number of most common values. Must be greater than 0 and less than or equal to 1000.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets analyzeShardKeyNumMostCommonValues to 3 at startup:

mongod --setParameter analyzeShardKeyNumMostCommonValues=3

During run time, you can set or modify the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, analyzeShardKeyNumMostCommonValues: 3 } )
analyzeShardKeyNumRanges

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 100

Specifies the number of ranges to partition the shard key space into when calculating the hotness of shard key ranges. Must be greater than 0 and less than or equal to 10000.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets analyzeShardKeyNumRanges to 50 at startup:

mongod --setParameter analyzeShardKeyNumRanges=50

During run time, you can set or modify the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, analyzeShardKeyNumRanges: 50 } )
autoMergerIntervalSecs

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 3600

When AutoMerger is enabled, specifies the amount of time between automerging rounds, in seconds. The default value is 3600 seconds, or one hour.

autoMergerIntervalSecs can only be set on config servers.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets autoMergerIntervalSecs to 7200 seconds, or two hours, at startup:

mongod --setParameter autoMergerIntervalSecs=7200

During run time, you can set or modify the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, autoMergerIntervalSecs: 7200 } )
autoMergerThrottlingMS

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 15000

When AutoMerger is enabled, specifies the minimum amount time between merges initiated by the AutoMerger on the same collection, in milliseconds.

autoMergerThrottlingMS can only be set on config servers.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets autoMergerThrottlingMS to 60000 milliseconds, or one minute, at startup:

mongod --setParameter autoMergerThrottlingMS=60000

During run time, you can set or modify the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, autoMergerThrottlingMS: 60000 } )
balancerMigrationsThrottlingMs

New in version 7.0.在版本7.0中新增。 (Also available starting in 6.3.1, 6.0.6, 5.0.18)

Available for mongod only.仅适用于mongod

Type: integer

Default: 1000

Specifies the minimum amount of time between two consecutive balancing rounds. This allows you to throttle the balancing rate. This parameter only takes effect on config server nodes.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets balancerMigrationsThrottlingMs to 2000 milliseconds at startup:

mongod --setParameter balancerMigrationsThrottlingMs=2000

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, balancerMigrationsThrottlingMs: 2000 } )
catalogCacheCollectionMaxEntries

New in version 8.1.在版本8.1中新增。 (also available starting in 8.0.10, 7.0.22)

Type: integer

Default: 10000

Available for both mongod and mongos.适用于mongodmongos

Maximum number of entries allowed in the catalog cache for collections.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

catalogCacheDatabaseMaxEntries

New in version 8.1.在版本8.1中新增。 (also available starting in 8.0.10, 7.0.22)

Type: integer

Default: 10000

Available for both mongod and mongos.适用于mongodmongos

Maximum number of entries allowed in the catalog cache for databases.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

chunkDefragmentationThrottlingMS

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

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 0

Specifies the minimum time period (in milliseconds) between consecutive split and merge commands run by the balancer when the chunks in a sharded collection are defragmented. chunkDefragmentationThrottlingMS limits the rate of split and merge commands.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets chunkDefragmentationThrottlingMS to 10 milliseconds:

mongod --setParameter chunkDefragmentationThrottlingMS=10

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, chunkDefragmentationThrottlingMS: 10 } )
disableResumableRangeDeleter

Available for mongod only.仅适用于mongod

Type: boolean

Default: false

If set on a shard's primary, specifies if MongoDB pauses range deletion on the shard. If set to true, MongoDB pauses cleanup of ranges containing orphaned documents. The shard can continue to donate chunks to other shards, but the shard does not remove donated documents until you set this parameter to false. This shard can continue to receive chunks from other shards as long as it does not have a pending range deletion task in the config.rangeDeletions collection that overlaps with the incoming chunk's range.

When disableResumableRangeDeleter is true, chunk migrations fail if orphaned documents exist on the recipient shard's primary in the same range as the incoming chunks.

The parameter has no effect on the mongod if it is not the shard's primary.

Important

If you set disableResumableRangeDeleter parameter to true, ensure that you apply it consistently for all members in the shard's replica set. In the event of a failover, this setting's value on the new primary dictates the behavior of the range deleter.

Starting in MongoDB 8.2, you can set disableResumableRangeDeleter during both startup and run time.

To set disableResumableRangeDeleter at startup, use the following command:

mongod --setParameter disableResumableRangeDeleter=false

To set disableResumableRangeDeleter during run time, use the following command:

db.adminCommand( { setParameter: 1, disableResumableRangeDeleter: false } )
enableFinerGrainedCatalogCacheRefresh

Note

Deprecated in 8.0

Starting in MongoDB 8.0, the parameter is deprecated and doesn't cause any changes or errors.

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: true

This parameter allows the catalog cache to be refreshed only if the shard needs to be refreshed. If disabled, any stale chunk will cause the entire chunk distribution for a collection to be considered stale and force all routers who contact the shard to refresh their shard catalog cache.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

mongod --setParameter enableFinerGrainedCatalogCacheRefresh=true
mongos --setParameter enableFinerGrainedCatalogCacheRefresh=true
enableShardedIndexConsistencyCheck

Available for mongod only.仅适用于mongod

Type: boolean

Default: true

If set on the config server's primary, enables or disables the index consistency check for sharded collections. The parameter has no effect on the mongod if it is not the config server's primary.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets enableShardedIndexConsistencyCheck to false for a config server primary:

mongod --setParameter enableShardedIndexConsistencyCheck=false

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, enableShardedIndexConsistencyCheck: false } )

Tip

findChunksOnConfigTimeoutMS

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

Available for both mongod and mongos.适用于mongodmongos

Type: Non-negative integer

Default: 900000

The timeout in milliseconds for find operations on chunks.

If there is a large number of chunks in the cluster and chunk loading fails with the error ExceededTimeLimit, increase the parameter value:

mongod --setParameter findChunksOnConfigTimeoutMS=1000000

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
findShardsOnConfigTimeoutMS

Available for both mongod and mongos.适用于mongodmongos

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

Type: Non-negative integer

Default: 10000 milliseconds

The timeout in milliseconds for find operations against the config.shards namespace.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets findShardsOnConfigTimeoutMS to 15000 milliseconds during runtime:

db.adminCommand( { setParameter: 1, findShardsOnConfigTimeoutMS: 15000 } )

The following example sets findShardsOnConfigTimeoutMS to 15000 milliseconds at startup:

mongos --setParameter findShardsOnConfigTimeoutMS=15000
loadRoutingTableOnStartup

Available for mongos only.仅适用于mongos

Type: boolean

Default: true

Configures a mongos instance to preload the routing table for a sharded cluster on startup. With this setting enabled, the mongos caches the cluster-wide routing table for each sharded collection as part of its startup procedure, before it begins accepting client connections.

Without this setting enabled, the mongos only loads a routing table as needed for incoming client connections, and only loads the specific routing table for the namespace of a given request.

A mongos instance with the loadRoutingTableOnStartup parameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.

loadRoutingTableOnStartup is enabled by default.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

maxCatchUpPercentageBeforeBlockingWrites

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 10

For moveChunk and moveRange operations, specifies the maximum percentage of untrasferred data allowed by the migration protocol (expressed in percentage of the total chunk size) to transition from the catchup phase to the commit phase.

Setting a higher catchup percentage can decrease the amount of time it takes for the migration to complete at the cost of increased latency during concurrent upsert and delete operations.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

Starting in MongoDB 7.1 (and 7.0.1), you can set the parameter during runtime.

For example, to set the maximum percentage to 20, you can issue the following during startup:

mongod --setParameter maxCatchUpPercentageBeforeBlockingWrites=20

Starting in MongoDB 7.1 (and 7.0.1), you can set the parameter during runtime with the setParameter command:

db.adminCommand( { setParameter: 1, maxCatchUpPercentageBeforeBlockingWrites: 20} )
maxTimeMSForHedgedReads

Important

Starting in MongoDB 8.1, hedged reads are removed and this parameter has no effect.

metadataRefreshInTransactionMaxWaitBehindCritSecMS

Deprecated

Note

Starting in MongoDB 8.1, the old metadataRefreshInTransactionMaxWaitBehindCritSecMS parameter is renamed metadataRefreshInTransactionMaxWaitMS. You can continue to use metadataRefreshInTransactionMaxWaitBehindCritSecMS as the parameter name, but it is deprecated and will be removed in a future MongoDB release.

New in version 5.2.在版本5.2中新增。 (Also available starting in 5.1.0, 5.0.4)

Changed in version 8.1.在版本8.1中的更改。

Available for mongod only.仅适用于mongod

Type: integer

Default: 500

Limits the time a shard waits for a critical section within a transaction.

When a query accesses a shard, a chunk migration or DDL operation may already hold the critical section for the collection. If the query finds the critical section is taken, the shard waits until the critical section has been released. When the shard returns control to mongos, mongos retries the query. However, if a multi-shard transaction interacts with an operation that takes the critical section on multiple shards, the interaction can result in a distributed deadlock.

metadataRefreshInTransactionMaxWaitBehindCritSecMS limits the maximum time a shard waits within a transaction for the critical section to be released.

To reduce the maximum wait time for the critical section within a transaction, lower the value of metadataRefreshInTransactionMaxWaitBehindCritSecMS.

Warning

If metadataRefreshInTransactionMaxWaitBehindCritSecMS is too low, mongos could use all of its retry attempts and return an error.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set metadataRefreshInTransactionMaxWaitBehindCritSecMS to 400 milliseconds:

db.adminCommand( { setParameter: 1, metadataRefreshInTransactionMaxWaitBehindCritSecMS: 400 } )
metadataRefreshInTransactionMaxWaitMS

Changed in version 8.1.在版本8.1中的更改。

Available for mongod only.仅适用于mongod

Type: integer

Default: 500

Limits the time a shard waits for a critical section within a transaction.

Note

Starting in MongoDB 8.1, the old metadataRefreshInTransactionMaxWaitBehindCritSecMS parameter is renamed metadataRefreshInTransactionMaxWaitMS. You can continue to use metadataRefreshInTransactionMaxWaitBehindCritSecMS as the parameter name, but it is deprecated and will be removed in a future MongoDB release.

When a query accesses a shard, a chunk migration or DDL operation may already hold the critical section for the collection. If the query finds the critical section is taken, the shard waits until the critical section has been released. When the shard returns control to mongos, mongos retries the query. However, if a multi-shard transaction interacts with an operation that takes the critical section on multiple shards, the interaction can result in a distributed deadlock.

metadataRefreshInTransactionMaxWaitMS limits the maximum time a shard waits within a transaction for the critical section to be released.

To reduce the maximum wait time for the critical section within a transaction, lower the value of metadataRefreshInTransactionMaxWaitMS.

Warning

If metadataRefreshInTransactionMaxWaitMS is too low, mongos could use all of its retry attempts and return an error.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set metadataRefreshInTransactionMaxWaitMS to 400 milliseconds:

db.adminCommand( { setParameter: 1, metadataRefreshInTransactionMaxWaitMS: 400 } )
migrateCloneInsertionBatchDelayMS

Available for mongod only.仅适用于mongod

Type: Non-negative integer

Default: 0

Time in milliseconds to wait between batches of insertions during cloning step of the migration process. This wait is in addition to the secondaryThrottle.

The default value of 0 indicates no additional wait.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following sets the migrateCloneInsertionBatchDelayMS to 200 milliseconds:

mongod --setParameter migrateCloneInsertionBatchDelayMS=200

The parameter may also be set using the setParameter command:

db.adminCommand( { setParameter: 1, migrateCloneInsertionBatchDelayMS: 200 } )
migrateCloneInsertionBatchSize

Available for mongod only.仅适用于mongod

Type: Non-negative integer

Default: 0

The maximum number of documents to insert in a single batch during the cloning step of the migration process.

The default value of 0 indicates no maximum number of documents per batch. However, in practice, this results in batches that contain up to 16 MB of documents.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following sets the migrateCloneInsertionBatchSize to 100 documents:

mongod --setParameter migrateCloneInsertionBatchSize=100

The parameter may also be set using the setParameter command:

db.adminCommand( { setParameter: 1, migrateCloneInsertionBatchSize: 100 } )
mongosShutdownTimeoutMillisForSignaledShutdown

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

Available for mongos only.仅适用于mongos

Type: integer

Default: 15000

Specifies the time (in milliseconds) to wait for any ongoing database operations to complete before initiating a shutdown of mongos in response to a SIGTERM signal.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set the time to 250 milliseconds, you can issue the following during startup:

mongos --setParameter mongosShutdownTimeoutMillisForSignaledShutdown=250

Or if using the setParameter command in a mongosh session that is connected to a running mongos:

db.adminCommand( { setParameter: 1, mongosShutdownTimeoutMillisForSignaledShutdown: 250 } )
opportunisticSecondaryTargeting

Important

Starting in MongoDB 8.1, hedged reads are removed and this parameter has no effect.

orphanCleanupDelaySecs

Changed in version 8.2.在版本8.2中的更改。

Available for mongod only.仅适用于mongod

Default: 3600 (60 minutes)

Minimum delay before a migrated chunk is deleted from the source shard.

Before deleting a migrated chunk, MongoDB waits for in-progress queries involving the chunk to complete on the shard primary and then waits an additional orphanCleanupDelaySecs seconds.

Starting in 8.2, the behavior of in-progress queries on shard secondaries is determined by terminateSecondaryReadsOnOrphanCleanup.

If a shard has storage constraints, consider reducing this value temporarily. If running queries that exceed 60 minutes on shard secondaries, consider increasing this value.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following sets the orphanCleanupDelaySecs to 20 minutes:

mongod --setParameter orphanCleanupDelaySecs=1200

This may also be set using the setParameter command:

db.adminCommand( { setParameter: 1, orphanCleanupDelaySecs: 1200 } )

Tip

In all versions, the new value of orphanCleanupDelaySecs is only applied to range deletions created after the value is changed. To apply the new value to existing range deletions, force a step down.

persistedChunkCacheUpdateMaxBatchSize

New in version 7.2.在版本7.2中新增。 (and 7.1.1, 7.0.4, 6.0.13, 5.0.25)

Available for mongod only.仅适用于mongod

Type: Integer

Default: 1000

To route and serve operations, shards must know the routing and ownership information associated with their collections. This information propogates from a shard's primary node to its secondary nodes through the replication of the internal cache collections config.cache.collections and config.cache.chunks.<collectionName>.

In previous versions, updates on the chunk cache collection were performed individually (meaning that an entry was deleted and a new entry was inserted). Starting in MongoDB 7.2, these updates are performed as a batch of deletions followed by a batch of insertions. The updated logic improves performance for collections that contain a large number of chunks.

The persistedChunkCacheUpdateMaxBatchSize parameter specifies the maximum batch size used for updating the persisted chunk cache.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets persistedChunkCacheUpdateMaxBatchSize to 700 at startup:

mongod --setParameter persistedChunkCacheUpdateMaxBatchSize=700

You can also set persistedChunkCacheUpdateMaxBatchSize during runtime:

db.adminCommand( { setParameter: 1, persistedChunkCacheUpdateMaxBatchSize: 700 } )
queryAnalysisSampleExpirationSecs

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 7 * 24 * 3600

Amount of time that a sampled query document exists before being removed by the TTL monitor, in seconds. Must be greater than 0.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets queryAnalysisSampleExpirationSecs to 691200 (8 * 24 * 3600) at startup on a mongod instance:

mongod --setParameter queryAnalysisSampleExpirationSecs=691200

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, queryAnalysisSampleExpirationSecs: 691200 } )
queryAnalysisSamplerConfigurationRefreshSecs

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

Changed in version 7.0.1.在版本7.0.1中的更改。

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 10

Interval that a sampler (mongos or mongod) refreshes its query analyzer sample rates.

The sample rate configured by the configureQueryAnalyzer command is divided among mongos instances in the sharded cluster or mongod instances in the replica set based on the traffic going through them. To make the sample rate assignment for a mongos or mongod more responsive to the traffic going through it, decrease this value.

We recommend using the default value.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

Starting in MongoDB 7.0.1, you can set queryAnalysisSamplerConfigurationRefreshSecs during run time.

This example sets queryAnalysisSamplerConfigurationRefreshSecs to 60 seconds at startup on a mongod instance:

mongod --setParameter queryAnalysisSamplerConfigurationRefreshSecs=60

This example sets queryAnalysisSamplerConfigurationRefreshSecs to 60 seconds at startup on a mongos instance:

mongos --setParameter queryAnalysisSamplerConfigurationRefreshSecs=60

To set the value to 30 seconds, run the following:

db.adminCommand( { setParameter: 1, queryAnalysisSamplerConfigurationRefreshSecs: 30 } )
queryAnalysisWriterIntervalSecs

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

Changed in version 7.0.1.在版本7.0.1中的更改。

Available for mongod only.仅适用于mongod

Type: integer

Default: 90

Interval that sampled queries are written to disk, in seconds.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

Starting in MongoDB 7.0.1, you can set queryAnalysisWriterIntervalSecs during run time.

This example sets queryAnalysisWriterIntervalSecs to 60 seconds at startup on a mongod instance:

mongod --setParameter queryAnalysisWriterIntervalSecs=60

To set the value to 60 seconds, run the following:

db.adminCommand( { setParameter: 1, queryAnalysisWriterIntervalSecs: 60 } )
queryAnalysisWriterMaxBatchSize

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 100000

Maximum number of sampled queries to write to disk at once. Must be greater than 0 and less than or equal to 100000.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets queryAnalysisWriterMaxBatchSize to 1000 at startup on a mongod instance:

mongod --setParameter queryAnalysisWriterMaxBatchSize=1000

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, queryAnalysisWriterMaxBatchSize: 1000 } )
queryAnalysisWriterMaxMemoryUsageBytes

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 100 * 1024 * 1024

Maximum amount of memory in bytes that the query sampling writer is allowed to use. Once the limit is reached, all new queries and diffs are discarded from sampling until the buffer is flushed. Must be greater than 0.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

This example sets queryAnalysisWriterMaxMemoryUsageBytes to 10000000 at startup on a mongod instance:

mongod --setParameter queryAnalysisWriterMaxMemoryUsageBytes=10000000
rangeDeleterBatchDelayMS

Available for mongod only.仅适用于mongod

Type: Non-negative integer

Default: 20

The amount of time in milliseconds to wait before the next batch of deletion during the cleanup stage of range migration.

The _secondaryThrottle replication delay occurs after each batch deletion.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following sets the rangeDeleterBatchDelayMS to 200 milliseconds:

mongod --setParameter rangeDeleterBatchDelayMS=200

The parameter may also be set using the setParameter command:

db.adminCommand( { setParameter: 1, rangeDeleterBatchDelayMS: 200 } )

Tip

In versions prior to 6.0.3, the new value of rangeDeleterBatchDelayMS is only applied to range deletions created after the value is changed. To apply the new value to existing range deletions, force a step down.

From 6.0.3 on, the new value of the parameter is applied to all the range deletions processed after the update, regardless of when the range deletion was created.

rangeDeleterBatchSize

Available for mongod only.仅适用于mongod

Type: Non-negative integer

Default: 2147483647 starting in MongoDB 5.1.2 and 5.0.6

The maximum number of documents in each batch to delete during the cleanup stage of range migration.

A value of 0 indicates that the system chooses the default value.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets rangeDeleterBatchSize to 32 documents:

mongod --setParameter rangeDeleterBatchSize=32

The parameter may also be set using the setParameter command:

db.adminCommand( { setParameter: 1, rangeDeleterBatchSize: 32 } )

Tip

In versions prior to 6.0.3, the new value of rangeDeleterBatchSize is only applied to range deletions created after the value is changed. To apply the new value to existing range deletions, force a step down.

From 6.0.3 on, the new value of the parameter is applied to all the range deletions processed after the update, regardless of when the range deletion was created.

readHedgingMode

Important

Starting in MongoDB 8.1, hedged reads are removed and this parameter has no effect.

routingTableCacheChunkBucketSize

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

Changed in version 7.2.在版本7.2中的更改。

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 500

Specifies the size of the routing table cache buckets used to implement chunk grouping optimization. Must be greater than 0.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, to set the cache chunk bucket size to 250 on a mongod, issue the following command at startup:

mongod --setParameter routingTableCacheChunkBucketSize=250
shardedIndexConsistencyCheckIntervalMS

Available for mongod only.仅适用于mongod

Type: integer

Default: 600000

If set on the config server's primary, the interval, in milliseconds, at which the config server's primary checks the index consistency of sharded collections. The parameter has no effect on the mongod if it is not the config server's primary.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example, the following sets the interval at 300000 milliseconds (5 minutes) at startup:

mongod --setParameter shardedIndexConsistencyCheckIntervalMS=300000

Tip

ShardingTaskExecutorPoolHostTimeoutMS

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 300000 (5 minutes)

Maximum time that mongos goes without communication to a host before mongos drops all connections to the host.

If set, ShardingTaskExecutorPoolHostTimeoutMS should be greater than the sum of ShardingTaskExecutorPoolRefreshRequirementMS and ShardingTaskExecutorPoolRefreshTimeoutMS. Otherwise, mongos adjusts the value of ShardingTaskExecutorPoolHostTimeoutMS to be greater than the sum.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets ShardingTaskExecutorPoolHostTimeoutMS to 120000 during startup:

mongos --setParameter ShardingTaskExecutorPoolHostTimeoutMS=120000

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolHostTimeoutMS: 120000 } )
ShardingTaskExecutorPoolMaxConnecting

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 2

Maximum number of simultaneous initiating connections (including pending connections in setup/refresh state) each TaskExecutor connection pool can have to a mongod instance. You can set this parameter to control the rate at which mongos adds connections to a mongod instance.

If set, ShardingTaskExecutorPoolMaxConnecting should be less than or equal to ShardingTaskExecutorPoolMaxSize. If it is greater, mongos ignores the ShardingTaskExecutorPoolMaxConnecting value.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets ShardingTaskExecutorPoolMaxConnecting to 20 during startup:

mongos --setParameter ShardingTaskExecutorPoolMaxConnecting=20

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMaxConnecting: 20 } )
ShardingTaskExecutorPoolMaxSize

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 2 64 - 1

Maximum number of outbound connections each TaskExecutor connection pool can open to any given mongod instance. The maximum possible connections to any given host across all TaskExecutor pools is:

ShardingTaskExecutorPoolMaxSize * taskExecutorPoolSize

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets ShardingTaskExecutorPoolMaxSize to 20 during startup:

mongos --setParameter ShardingTaskExecutorPoolMaxSize=20

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMaxSize: 20 } )

mongos can have up to n TaskExecutor connection pools, where n is the number of cores. See taskExecutorPoolSize.

ShardingTaskExecutorPoolMaxSizeForConfigServers

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

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: -1

Optional 可选。override for ShardingTaskExecutorPoolMaxSize to set the maximum number of outbound connections each TaskExecutor connection pool can open to a configuration server.

When set to:

  • -1, ShardingTaskExecutorPoolMaxSize is used. This is the default.
  • an integer value greater than -1, overrides the maximum number of outbound connections each TaskExecutor connection pool can open to a configuration server.

Parameter only applies to sharded deployments.

The following example sets ShardingTaskExecutorPoolMaxSize to 2 during startup, which sets the maximum number of outbound connections each TaskExecutor connection pool can open to a configuration server to 2:

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
mongos --setParameter ShardingTaskExecutorPoolMaxSizeForConfigServers=2

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMaxSizeForConfigServers: 2 } )
ShardingTaskExecutorPoolMinSize

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 1

Minimum number of outbound connections each TaskExecutor connection pool can open to any given mongod instance.

ShardingTaskExecutorPoolMinSize connections are created the first time a connection to a new host is requested from the pool. While the pool is idle, the pool maintains this number of connections until ShardingTaskExecutorPoolHostTimeoutMS milliseconds pass without any application using that pool.

For a mongos using the warmMinConnectionsInShardingTaskExecutorPoolOnStartup parameter, the ShardingTaskExecutorPoolMinSize parameter also controls how many connections to each shard host are established on startup of the mongos instance before it begins accepting incoming client connections.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets ShardingTaskExecutorPoolMinSize to 2 during startup:

mongos --setParameter ShardingTaskExecutorPoolMinSize=2

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMinSize: 2 } )

mongos can have up to n TaskExecutor connection pools, where n is the number of cores. See taskExecutorPoolSize.

ShardingTaskExecutorPoolMinSizeForConfigServers

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

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: -1

Optional 可选。override for ShardingTaskExecutorPoolMinSize to set the minimum number of outbound connections each TaskExecutor connection pool can open to a configuration server.

When set to:

  • -1, ShardingTaskExecutorPoolMinSize is used. This is the default.
  • an integer value greater than -1, overrides the minimum number of outbound connections each TaskExecutor connection pool can open to a configuration server.

Parameter only applies to sharded deployments.

The following example sets ShardingTaskExecutorPoolMinSize to 2 during startup, which sets the minimum number of outbound connections each TaskExecutor connection pool can open to a configuration server to 2:

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
mongos --setParameter ShardingTaskExecutorPoolMinSizeForConfigServers=2

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMinSizeForConfigServers: 2 } )
ShardingTaskExecutorPoolRefreshRequirementMS

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 60000 (1 minute)

Maximum time the mongos waits before attempting to heartbeat an idle connection in the pool. An idle connection may be discarded during the refresh if the pool is above its minimum size.

If set, ShardingTaskExecutorPoolRefreshRequirementMS should be greater than ShardingTaskExecutorPoolRefreshTimeoutMS. Otherwise, mongos adjusts the value of ShardingTaskExecutorPoolRefreshTimeoutMS to be less than ShardingTaskExecutorPoolRefreshRequirementMS.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets ShardingTaskExecutorPoolRefreshRequirementMS to 90000 during startup:

mongos --setParameter ShardingTaskExecutorPoolRefreshRequirementMS=90000

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolRefreshRequirementMS: 90000 } )
ShardingTaskExecutorPoolRefreshTimeoutMS

Available for both mongod and mongos.适用于mongodmongos

Type: integer

Default: 20000 (20 seconds)

Maximum time the mongos waits for a heartbeat before timing out the heartbeat.

If set, ShardingTaskExecutorPoolRefreshTimeoutMS should be less than ShardingTaskExecutorPoolRefreshRequirementMS. Otherwise, mongos adjusts the value of ShardingTaskExecutorPoolRefreshTimeoutMS to be less than ShardingTaskExecutorPoolRefreshRequirementMS.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets ShardingTaskExecutorPoolRefreshTimeoutMS to 30000 during startup:

mongos --setParameter ShardingTaskExecutorPoolRefreshTimeoutMS=30000

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolRefreshTimeoutMS: 30000 } )
ShardingTaskExecutorPoolReplicaSetMatching

Changed in version 5.0.在版本5.0中的更改。

Available for both mongod and mongos.适用于mongodmongos

Type: string

Default: "automatic"

On a mongos instance, this parameter sets the policy that determines the minimum size limit of its connection pools to nodes within replica sets.

On a mongod instance, this parameter sets the policy that determines the minimum size limit of its connection pools to nodes within other replica sets.

Note that this parameter only manages connections for operations that are directly related to user requests and CRUD operations.

Available values are:

Matching PolicyDescription描述
"automatic" (Default)

Starting in 5.0, "automatic" is the new default value.

When set for a mongos, the instance follows the behavior specified for the "matchPrimaryNode" option.

When set for a mongod, the instance follows the behavior specified for the "disabled" option.

WARNING: If the ShardingTaskExecutorPoolReplicaSetMatching is set to "automatic", the replicaSetMatchingStrategy still describes the actual policy being used, not "automatic". To find the value of the ShardingTaskExecutorPoolReplicaSetMatching, use getParameter which returns the value of the server parameter.

"matchPrimaryNode"

When set for a mongos, the minimum size limit of the instance's connection pool to each secondary of a replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the size of its connection pool to that replica set's primary.

When set for a mongod, the minimum size limit of the instance's connection pool to each secondary of another replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the size of its connection pool to that replica set's primary.

WARNING: If multiple shard servers in your topology can experience a rapid influx of cross-shard operations, do not set this option on your mongod instances.

In case of a primary stepdown, matchPrimaryNode ensures that any secondary that becomes the primary can handle the current level of primary reads and writes.

"matchBusiestNode"

When set for a mongos, the instance's minimum size limit of the connection pool to each member of a replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the largest among the active connection counts to the primary and each secondary member of that replica set.

When set for a mongod, the instance's minimum size limit of the connection pool to each member of another replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the largest among the active connection counts to the primary and each secondary member of that replica set.

With "matchBusiestNode", mongos maintains enough connections to each secondary to handle the current level of primary and secondary reads and writes. The number of connections to maintain in the pool decreases as the number of active connections decreases.

"disabled"

When set for a mongos, the instance's minimum number of connections in the instance's connection pool to each node of a replica set in the sharded clusterv (specifically, shard replica set and config servers) is equal to the ShardingTaskExecutorPoolMinSize.

When set for a mongod, the instance's minimum number of connections in the instance's connection pool to each node of another replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the ShardingTaskExecutorPoolMinSize.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets the ShardingTaskExecutorPoolReplicaSetMatching to "automatic" during startup:

mongod --setParameter ShardingTaskExecutorPoolReplicaSetMatching="automatic"

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( { setParameter: 1,  ShardingTaskExecutorPoolReplicaSetMatching: "automatic" } )
shutdownTimeoutMillisForSignaledShutdown

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

Available for mongod only.仅适用于mongod

Type: integer

Default: 15000

Specifies the time (in milliseconds) to wait for any ongoing database operations to complete before initiating a shutdown of mongod in response to a SIGTERM signal.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set the time to 250 milliseconds, you can issue the following during startup:

mongod --setParameter shutdownTimeoutMillisForSignaledShutdown=250

Or if using the setParameter command in a mongosh session that is connected to a running mongod:

db.adminCommand( { setParameter: 1, shutdownTimeoutMillisForSignaledShutdown: 250 } )
skipShardingConfigurationChecks

Available for mongod only.仅适用于mongod

Type: boolean

Default: false

When true, allows for starting a shard member or config server member as a standalone for maintenance operations. This parameter is mutually exclusive with the --configsvr or --shardsvr options.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

mongod --setParameter skipShardingConfigurationChecks=true

Important

Once maintenance has completed, remove the skipShardingConfigurationChecks parameter when restarting the mongod.

taskExecutorPoolSize

Available for mongos only.仅适用于mongos

Type: integer

Default: 1

The number of Task Executor connection pools to use for a given mongos.

If the parameter value is 0 or less, the number of Task Executor connection pools is the number of cores with the following exceptions:

  • If the number of cores is less than 4, the number of Task Executor connection pools is 4.
  • If the number of cores is greater than 64, the number of Task Executor connection pools is 64.

The default value of taskExecutorPoolSize is 1:

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。
mongos --setParameter taskExecutorPoolSize=6
terminateSecondaryReadsOnOrphanCleanup

Available for mongod only.仅适用于mongod

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

Type: boolean

Default: true

Controls whether long-running read operations on secondary nodes automatically terminate before orphaned document deletion following a chunk migration.

In sharded clusters, when a chunk successfully migrates from the source shard to the destination shard, MongoDB does not immediately remove the migrated documents from the source shard. Instead, the primary of the source shard waits for any in-progress reads involving the namespace of the migrated chunk to complete, and after that, waits an additional period controlled by orphanCleanupDelaySecs (default: 1 hour). This additional delay allows any long-running secondary reads to finish before orphaned documents are deleted from the source shard.

After the orphaned documents are deleted from the source shard, any ongoing reads running on secondary nodes that started before the chunk migration may silently miss documents without returning an error unless terminateSecondaryReadsOnOrphanCleanup is set to true.

When terminateSecondaryReadsOnOrphanCleanup is set to true, read operations on secondary nodes that began before the chunk migration commit are automatically terminated before the orphaned documents are removed from the secondary node. This prevents long-running secondary reads from silently missing documents that were moved during migration.

When set to false, read operations on secondary nodes continue executing even after orphaned documents are deleted. Operations may silently miss documents without returning an error. This matches the behavior in MongoDB versions before 8.2.

Note

This behavior only affects read operations that start before the chunk migration commit. It applies to all read operations on secondaries, including queries, aggregations, and operations spanning multiple namespaces.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Error Response

When a read operation terminates due to terminateSecondaryReadsOnOrphanCleanup, MongoDB returns the following error:

{
code: 175,
name: QueryPlanKilled,
categories: [CursorInvalidatedError],
errmsg: "Read has been terminated due to orphan range cleanup"
}

This error is not retryable by design. To learn more about handling these errors, see Long-Running Secondary Reads in Sharded Clusters.

warmMinConnectionsInShardingTaskExecutorPoolOnStartup

Available for mongos only.仅适用于mongos

Type: boolean

Default: true

Configures a mongos instance to prewarm its connection pool on startup. With this parameter enabled, the mongos attempts to establish ShardingTaskExecutorPoolMinSize network connections to each shard server as part of its startup procedure, before it begins accepting client connections.

A timeout for this behavior can be configured with the warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS parameter. If this timeout is reached, the mongos will begin accepting client connections regardless of the size of its connection pool.

A mongos instance with this parameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.

warmMinConnectionsInShardingTaskExecutorPoolOnStartup is enabled by default.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS

Available for mongos only.仅适用于mongos

Type: integer

Default: 2000 (2 seconds)

Sets the timeout threshold in milliseconds for a mongos to wait for ShardingTaskExecutorPoolMinSize connections to be established per shard host when using the warmMinConnectionsInShardingTaskExecutorPoolOnStartup parameter. If this timeout is reached, the mongos will begin accepting client connections regardless of the size of its connection pool.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

Health Manager Parameters

activeFaultDurationSecs

Available for mongos only.仅适用于mongos

Type: Document

The amount of time to wait from a Health Managers Overview failure until the mongos is removed from the cluster, in seconds.

When a failure is detected and a Health Manager is configured as critical, the server waits for the specified interval before removing the mongos from the cluster.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For example, to set the duration from failure to crash to five minutes, issue the following at startup:

mongos --setParameter activeFaultDurationSecs=300

Or if using the setParameter command in a mongosh session that is connected to a running mongos:

db.adminCommand(
{
setParameter: 1,
activeFaultDurationSecs: 300
}
)

Parameters set with setParameter do not persist across restarts. See the setParameter page for details.

To make this setting persistent, set activeFaultDurationSecs in your mongos config file using the setParameter option as in the following example:

setParameter:
activeFaultDurationSecs: 300
healthMonitoringIntensities

Available for mongos only.仅适用于mongos

Type: Array of documents

Use this parameter to set intensity levels for Health Managers.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

healthMonitoringIntensities accepts an array of documents, values. Each document in values takes two fields:

  • type, the Health Manager facet
  • intensity, the intensity level

Health Managers

FacetWhat the Health Observer Checks
configServerCluster health issues related to connectivity to the config server.
dnsCluster health issues related to DNS availability and functionality.
ldapCluster health issues related to LDAP availability and functionality.

Intensity Levels

Intensity LevelDescription描述
criticalThe Health Manager on this facet is enabled and has the ability to move the failing mongos out of the cluster if an error occurs. The Health Manager waits the amount of time specified by activeFaultDurationSecs before stopping and moving the mongos out of the cluster automatically.
non-criticalThe Health Manager on this facet is enabled and logs errors, but the mongos remains in the cluster if errors are encountered.
offThe Health Manager on this facet is disabled. The mongos does not perform any health checks on this facet. This is the default intensity level.

For example, to set the dns Health Manager facet to the critical intensity level, issue the following at startup:

mongos --setParameter 'healthMonitoringIntensities={ values:[ { type:"dns", intensity: "critical"} ] }'

Or if using the setParameter command in a mongosh session that is connected to a running mongos:

db.adminCommand(
{
setParameter: 1,
healthMonitoringIntensities: { values: [ { type: "dns", intensity: "critical" } ] } } )
}
)

Parameters set with setParameter do not persist across restarts. See the setParameter page for details.

To make this setting persistent, set healthMonitoringIntensities in your mongos config file using the setParameter option as in the following example:

setParameter:
healthMonitoringIntensities: "{ values:[ { type:\"dns\", intensity: \"critical\"} ] }"
healthMonitoringIntervals

Available for mongos only.仅适用于mongos

Type: Array of documents

How often this Health Manager will run, in milliseconds.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

healthMonitoringIntervals accepts an array of documents, values. Each document in values takes two fields:

  • type, the Health Manager facet
  • interval, the time interval it runs at, in milliseconds

Health Managers

FacetWhat the Health Observer Checks
configServerCluster health issues related to connectivity to the config server.
dnsCluster health issues related to DNS availability and functionality.
ldapCluster health issues related to LDAP availability and functionality.

For example, to set the ldap Health Manager facet to the run health checks every 30 seconds, issue the following at startup:

mongos --setParameter 'healthMonitoringIntervals={ values:[ { type:"ldap", interval: "30000"} ] }'

Or if using the setParameter command in a mongosh session that is connected to a running mongos:

db.adminCommand(
{
setParameter: 1,
healthMonitoringIntervals: { values: [ { type: "ldap", interval: "30000" } ] } } )
}
)

Parameters set with setParameter do not persist across restarts. See the setParameter page for details.

To make this setting persistent, set healthMonitoringIntervals in your mongos config file using the setParameter option as in the following example:

setParameter:
healthMonitoringIntervals: "{ values: [{type: \"ldap\", interval: 200}] }"
progressMonitor

Available for mongos only.仅适用于mongos

Type: Document

Progress Monitor runs tests to ensure that Health Manager checks do not become stuck or unresponsive. Progress Monitor runs these tests in intervals specified by interval. If a health check begins but does not complete within the timeout given by deadline, Progress Monitor stops the mongos and removes it from the cluster.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

progressMonitor Fields

Field字段Description描述Units
intervalHow often to ensure Health Managers are not stuck or unresponsive.Milliseconds
deadlineTimeout before automatically failing the mongos if a Health Manager check is not making progress.Seconds

To set the interval to 1000 milliseconds and the deadline to 300 seconds, issue the following at startup:

mongos --setParameter 'progressMonitor={"interval": 1000, "deadline": 300}'

Or if using the setParameter command in a mongosh session that is connected to a running mongos:

db.adminCommand(
{
setParameter: 1,
progressMonitor: { interval: 1000, deadline: 300 } )
}
)

Parameters set with setParameter do not persist across restarts. See the setParameter page for details.

To make this setting persistent, set progressMonitor in your mongos config file using the setParameter option as in the following example:

setParameter:
progressMonitor: "{ interval: 1000, deadline: 300 }"

Storage Parameters

enableAutoCompaction

Available for both mongod and mongos.适用于mongodmongos

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

Type: boolean

Default: false

Specifies whether the instance runs automatic background compaction.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

The following example enables automatic background compaction on the instance:

mongod --setParameter "enableAutoCompaction=true"
honorSystemUmask

Available for mongod only.仅适用于mongod

Default: false

If honorSystemUmask is set to true, new files created by MongoDB have permissions in accordance with the user's umask settings. You cannot set processUmask if honorSystemUmask is set to true.

If honorSystemUmask is set to false, new files created by MongoDB have permissions set to 600, which gives read and write permissions only to the owner. New directories have permissions set to 700. You can use processUmask to override the default permissions for groups and other users on all new files created by MongoDB.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

mongod --setParameter honorSystemUmask=true

Note

honorSystemUmask is not available on Windows systems.

journalCommitInterval

Available for mongod only.仅适用于mongod

Specify an integer between 1 and 500 signifying the number of milliseconds (ms) between journal commits.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Consider the following example which sets the journalCommitInterval to 200 ms:

db.adminCommand( { setParameter: 1, journalCommitInterval: 200 } )
minSnapshotHistoryWindowInSeconds

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

Available for mongod only.仅适用于mongod

Default: 300

The minimum time window in seconds for which the storage engine keeps the snapshot history. If you query data using read concern "snapshot" and specify an atClusterTime value older than the specified minSnapshotHistoryWindowInSeconds, mongod returns a SnapshotTooOld error.

Warning

In sharded clusters, changing the default minSnapshotHistoryWindowInSeconds value on config server nodes may cause internal operations to fail.

Do not set minSnapshotHistoryWindowInSeconds to 0 on config server nodes. Setting this parameter to 0 causes internal operations conducting snapshot reads targeting the config server with a specified atClusterTime to fail.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Specify an integer greater than or equal to (>=) 0.

Consider the following example which sets the minSnapshotHistoryWindowInSeconds to 600 seconds:

db.adminCommand( { setParameter: 1, minSnapshotHistoryWindowInSeconds: 600 } )

Note

Increasing the value of minSnapshotHistoryWindowInSeconds increases disk usage. For more information, see Snapshot History Retention.

To modify this value for a MongoDB Atlas cluster, you must contact Atlas Support.

processUmask

Available for mongod only.仅适用于mongod

Overrides the default permissions used for groups and other users when honorSystemUmask is set to false. By default, when honorSystemUmask is set to false, new files created by MongoDB have permissions set to 600. Use the processUmask parameter to override this default with a custom umask value. The file owner inherits permissions from the system umask.

This parameter is only available at startup. To set the parameter, use the setParameter setting.

You cannot set this parameter if honorSystemUmask is set to true.

Consider the following example, which sets the permissions for groups and other users to read/write only and retains the system umask settings for the owner:

mongod --setParameter processUmask=011

Note

processUmask is not available on Windows systems.

storageEngineConcurrentReadTransactions

Changed in version 7.0.在版本7.0中的更改。

Available for mongod only.仅适用于mongod

Type: integer

Specifies the maximum number of concurrent read transactions (read tickets) allowed into the storage engine.

Note

Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.

Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.

Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.

storageEngineConcurrentWriteTransactions

Changed in version 7.0.在版本7.0中的更改。

Available for mongod only.仅适用于mongod

Type: integer

Specifies the maximum number of concurrent write transactions allowed into the WiredTiger storage engine.

Note

Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.

Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.

Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.

syncdelay

Available for mongod only.仅适用于mongod

Default: 60

Specify the interval in seconds when mongod flushes its working memory to disk. By default, mongod flushes memory to disk every 60 seconds. In almost every situation you should not set this value and use the default setting.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Consider the following example which sets the syncdelay to 60 seconds:

db.adminCommand( { setParameter: 1, syncdelay: 60 } )

To provide durable data, WiredTiger uses checkpoints. For more details, see Journaling and the WiredTiger Storage Engine.

temporarilyUnavailableBackoffBaseMs

Available for mongod only.仅适用于mongod

Default: 1000

Specifies the initial delay before retying a write operation that was rolled back due to cache pressure.

In rare circumstances, a write can fail due to cache pressure. When this happens MongoDB issues a TemporarilyUnavailable error and increments the temporarilyUnavailableErrors counter in two places: the slow query log and the Full Time Diagnostic Data Capture (FTDC).

Individual operations within multi-document transactions never return TemporarilyUnavailable errors.

Adjust the write retry properties by modifying the temporarilyUnavailableBackoffBaseMs and temporarilyUnavailableMaxRetries parameters.

The parameter accepts:

ValueDescription描述
integer >= 0

Defaults to 1 second. The initial delay between retries. The value increases with each retry to a maximum of 55 seconds. A larger value increases the chance that the cache pressure will be reduced before the next retry.

To configure number of retries, use temporarilyUnavailableMaxRetries.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

To set a new value, use db.adminCommand():

db.adminCommand( { setParameter: 1, temporarilyUnavailableBackoffBaseMs: 3 } )

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

temporarilyUnavailableMaxRetries

Available for mongod only.仅适用于mongod

Default: 10

Specifies the maximum number of retries when a write operation is rolled back due to cache pressure.

In rare circumstances, a write can fail due to cache pressure. When this happens MongoDB issues a TemporarilyUnavailable error and increments the temporarilyUnavailableErrors counter in two places: the slow query log and the Full Time Diagnostic Data Capture (FTDC).

Individual operations within multi-document transactions never return TemporarilyUnavailable errors.

Adjust the write retry properties by modifying the temporarilyUnavailableBackoffBaseMs and temporarilyUnavailableMaxRetries parameters.

The parameter accepts:

ValueDescription描述
integer >= 0

The maximum number of retries.

There is an increasing delay between retries. To configure the backoff time, use temporarilyUnavailableBackoffBaseMs.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

To set a new value, use db.adminCommand():

db.adminCommand( { setParameter: 1, temporarilyUnavailableMaxRetries: 5 } )

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

upsertMaxRetryAttemptsOnDuplicateKeyError

Available for both mongod and mongos.适用于mongodmongos

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

Maximum number of retry attempts when an upsert operation encounters a duplicate key error.

Type: Integer

Default: 100

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

Important

Starting in MongoDB 8.1, if an upsert operation runs in a multidocument transaction, then the upsert does not retry when it encounters a duplicate key error.

The following example sets the maximum number of times the server retries an upsert operation when encountering a duplicate key error to 50.

mongod --setParameter "upsertMaxRetryAttemptsOnDuplicateKeyError=50"

During run time, you can also set the parameter with the setParameter command:

db.adminCommand( {
setParameter: 1,
upsertMaxRetryAttemptsOnDuplicateKeyError: 50
} )

WiredTiger Parameters

wiredTigerConcurrentReadTransactions

Available for mongod only.仅适用于mongod

Type: integer

Specifies the maximum number of concurrent read transactions (read tickets) allowed into the storage engine.

Note

Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.

Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.

Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.

Changed in version 6.0.在版本6.0中的更改。

The wiredTigerConcurrentReadTransactions parameter was renamed to storageEngineConcurrentReadTransactions.

wiredTigerConcurrentWriteTransactions

Available for mongod only.仅适用于mongod

Type: integer

Specifies the maximum number of concurrent write transactions allowed into the WiredTiger storage engine.

Note

Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.

Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.

Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.

Changed in version 6.0.在版本6.0中的更改。

The wiredTigerConcurrentWriteTransactions parameter was renamed to storageEngineConcurrentWriteTransactions.

wiredTigerEngineRuntimeConfig

Available for mongod only.仅适用于mongod

Specify wiredTiger storage engine configuration options for a running mongod instance.

This parameter is only available at runtime. To set the parameter, use the setParameter command.setParameter

Warning

Avoid modifying the wiredTigerEngineRuntimeConfig unless under the direction from MongoDB engineers as this setting has major implication across both WiredTiger and MongoDB.除非在MongoDB工程师的指导下,否则避免修改wiredTigerEngineRuntimeConfig,因为此设置对WiredTiger和MongoDB都有重大影响。

Consider the following operation prototype:考虑以下操作原型:

db.adminCommand({
"setParameter": 1,
"wiredTigerEngineRuntimeConfig": "<option>=<setting>,<option>=<setting>"
})
wiredTigerFileHandleCloseIdleTime

Available for mongod only.仅适用于mongod

Type: integer

Default: 600

Specifies the amount of time in seconds that a file handle in wiredTiger can remain idle before being closed.指定wiredTiger中的文件句柄在关闭之前可以保持空闲的时间量(秒)。

If you set wiredTigerFileHandleCloseIdleTime to 0, idle handles are not closed.如果将wiredTigerFileHandleCloseIdleTime设置为0,则空闲句柄不会关闭。

Tip

This parameter is case sensitive. If you capitalize the w in wiredTigerFileHandleCloseIdleTime and run the parameter, the operation returns the following error message:此参数区分大小写。如果将wiredTigerFileHandleCloseIdleTime中的w大写并运行该参数,则操作将返回以下错误消息:

{ "code":2,"codeName":"BadValue","errmsg":"Unknown --setParameter 'WiredTigerFileHandleCloseIdleTime'" }

This parameter is only available at startup. To set the parameter, use the setParameter setting.

For example:例如:

mongod --setParameter wiredTigerFileHandleCloseIdleTime=100000
wiredTigerSessionMax

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

Type: 32-bit integer

Default: 33000

Available for mongod only.仅适用于mongod

Maximum number of sessions allowed by WiredTiger.WiredTiger允许的最大会话数。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

See the WiredTiger documentation for all available WiredTiger configuration options.有关所有可用的WiredTiger配置选项,请参阅WiredTiger文档。

Auditing Parameters

auditAuthorizationSuccess

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: false

Note

Available only in MongoDB Enterprise and MongoDB Atlas.

Enables the auditing of authorization successes for the authCheck action.启用authCheck操作的授权成功审核

When auditAuthorizationSuccess is false, the audit system only logs the authorization failures for authCheck.auditAuthorizationSuccessfalse时,审核系统仅记录authCheck的授权失败。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

To enable the audit of authorization successes, issue the following command:要启用对授权成功的审核,请发出以下命令:

db.adminCommand( { setParameter: 1, auditAuthorizationSuccess: true } )

Enabling auditAuthorizationSuccess degrades performance more than logging only the authorization failures.启用auditAuthorizationSuccess比仅记录授权失败更会降低性能。

If runtime audit configuration is enabled, the auditAuthorizationSuccess parameter should not appear in the mongod or mongos configuration file. 如果启用了运行时审核配置,则auditAuthorizationSuccess参数不应出现在mongodmongos配置文件中。The server will fail to start if the parameter is present.如果参数存在,服务器将无法启动。

auditConfigPollingFrequencySecs

Available for both mongod and mongos.适用于mongodmongos

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

Type: integer

Default: 300

A sharded cluster may have servers which maintain audit configuration settings for the cluster. Set the interval, in seconds, for non-configured servers to poll a config server for the current audit generation. 分片集群可能具有维护集群审计配置设置的服务器。设置未配置服务器轮询当前审核生成的配置服务器的间隔(秒)。If this value returned differs from the previously known value, the initiating node will request the current configuration and update its internal state.如果返回的值与先前已知的值不同,则发起节点将请求当前配置并更新其内部状态。

Note

Using the default value of 300 seconds, non-config nodes may lag up to 5 minutes after you set the auditConfig cluster parameter.使用默认值300秒,在设置auditConfig集群参数后,非配置节点可能会延迟长达5分钟。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

auditEncryptionHeaderMetadataFile

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

Available for both mongod and mongos.适用于mongodmongos

Type: string

Note

Available only in MongoDB Enterprise. MongoDB Enterprise and Atlas have different configuration requirements.仅在MongoDB企业版中可用。MongoDB企业版和Atlas有不同的配置要求。

Path and file name for logging metadata audit headers for audit log encryption. 用于审计日志加密的日志元数据审计头的路径和文件名。A header is placed at the top of each audit log file and contains metadata for decrypting the audit log. The headers are also stored in the audit log.每个审计日志文件的顶部都有一个标题,其中包含用于解密审计日志的元数据。标头也存储在审核日志中。

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

For example, the following sets the path and file for auditEncryptionHeaderMetadataFile:例如,以下设置auditEncryptionHeaderMetadataFile的路径和文件:

mongod --setParameter auditEncryptionHeaderMetadataFile=/auditFiles/auditHeadersMetadataFile.log
auditEncryptKeyWithKMIPGet

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

Available for both mongod and mongos.适用于mongodmongos

Type: boolean

Default: false

Note

Available only in MongoDB Enterprise. MongoDB Enterprise and Atlas have different configuration requirements.仅在MongoDB Enterprise中可用。MongoDB Enterprise和Atlas有不同的配置要求。

Enables audit log encryption for Key Management Interoperability Protocol (KMIP) servers that only support KMIP protocol version 1.0 or 1.1.为仅支持KMIP协议版本1.0或1.1的KMIP服务器启用审计日志加密

This parameter is only available at startup. To set the parameter, use the setParameter setting.此参数仅在启动时可用。要设置参数,请使用setParameter设置。

The following example sets auditEncryptKeyWithKMIPGet to true:以下示例将auditEncryptKeyWithKMIPGet设置为true

mongod --setParameter auditEncryptKeyWithKMIPGet=true

Transaction Parameters事务参数

AbortExpiredTransactionsSessionCheckoutTimeout

New in version 8.1.在版本8.1中新增。 (also available in 8.0.13)

Available for mongod only.仅适用于mongod

Type: integer

Default: 100 milliseconds

A session is checked out from a session pool to run database operations.从会话池中签出会话以运行数据库操作。

AbortExpiredTransactionsSessionCheckoutTimeout sets the maximum number of milliseconds for a session to be checked out when attempting to end an expired transaction.

If the expired transaction is successfully ended, MongoDB increments metrics.abortExpiredTransactions.successfulKills. If the transaction isn't successfully ended because it timed out when attempting to check out a session, MongoDB increments metrics.abortExpiredTransactions.timedOutKills.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets AbortExpiredTransactionsSessionCheckoutTimeout to 120 milliseconds:

db.adminCommand( { setParameter: 1, AbortExpiredTransactionsSessionCheckoutTimeout: 120 } )

You can also set this parameter during startup. For example:您还可以在启动过程中设置此参数。例如:

mongod --setParameter AbortExpiredTransactionsSessionCheckoutTimeout=120
coordinateCommitReturnImmediatelyAfterPersistingDecision

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

Updated in version 6.1在6.1版本中更新

Available for mongod only.仅适用于mongod

Type: boolean

Default: false

  • When set to false, the shard transaction coordinator waits for all participating shards to acknowledge the decision to either commit or cancel a multi-document transaction before returning the result to the client.当设置为false时,分片事务协调器会等待所有参与的分片确认提交或取消多文档事务的决定,然后再将结果返回给客户端。
  • When set to true, the shard transaction coordinator returns a multi-document transaction commit decision to the client as soon as the decision is made durable with the requested transaction write concern.当设置为true时,分片事务协调器会在所请求的事务写入关注使多文档事务提交决策持久后,立即向客户端返回该决策。

    If the client requested a write concern that is less than "majority", the commit may roll back after the decision is returned to the client.如果客户端请求的写入关注度低于"majority",则提交可能会在决定返回给客户端后回滚。

    Transactions may not have "read your writes" consistency. That is, a read operation may not show the results of write operations that preceded it. This can happen if:事务可能没有“读写”一致性。也就是说,读取操作可能不会显示之前的写入操作的结果。如果发生以下情况,可能会发生这种情况:

    • A transaction has to write to multiple shards.一个事务必须写入多个分片。
    • The read and the earlier write take place in different sessions.阅读和之前的写作发生在不同的会话中。

    Causal consistency only guarantees the causal relationship of reads and writes that occur within the same session.因果一致性仅保证在同一会话中发生的读写之间的因果关系。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets coordinateCommitReturnImmediatelyAfterPersistingDecision to true:以下示例将coordinateCommitReturnImmediatelyAfterPersistingDecision设置为true

mongod --setParameter coordinateCommitReturnImmediatelyAfterPersistingDecision=true

During run time, you can also set the parameter with the setParameter command:在运行时,您还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, coordinateCommitReturnImmediatelyAfterPersistingDecision: true } )
internalSessionsReapThreshold

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

Available for both mongod and mongos.适用于mongodmongos

Default: 1000

Session limit for internal session metadata deletion. The metadata:删除内部会话元数据的会话限制。元数据:

  • Contains session transaction information for user operations.包含用户操作的会话事务信息。
  • Is stored in the config.transactions collection.存储在config.transactions集合中。

When the number of internal sessions is greater than internalSessionsReapThreshold, the metadata is deleted.当内部会话数大于internalSessionsReapThreshold时,元数据将被删除。

If you set internalSessionsReapThreshold to 0, the internal session metadata is only deleted when the user session ends.如果将internalSessionsReapThreshold设置为0,则只有在用户会话结束时才会删除内部会话元数据。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following example sets internalSessionsReapThreshold to 500 sessions:以下示例将internalSessionsReapThreshold设置为500个会话:

db.adminCommand( { setParameter: 1, internalSessionsReapThreshold: 500 } )

You can also set internalSessionsReapThreshold at startup. For example:您还可以在启动时设置内部internalSessionsReapThreshold。例如:

mongod --setParameter internalSessionsReapThreshold=500
transactionLifetimeLimitSeconds

Available for mongod only.仅适用于mongod

Default: 60

Specifies the lifetime of multi-document transactions. Transactions that exceed this limit are considered expired and will be aborted by a periodic cleanup process. 指定多文档事务的生存期。超过此限制的事务将被视为已过期,并将通过定期清理过程中止。The cleanup process runs every transactionLifetimeLimitSeconds/2 seconds or at least once every 60 seconds.清理过程在每笔transactionLifetimeLimitSeconds/2秒或至少每60秒运行一次。

The cleanup process helps relieve storage cache pressure.清理过程有助于缓解存储缓存压力。

The minimum value for transactionLifetimeLimitSeconds is 1 second.transactionLifetimeLimitSeconds的最小值为1秒。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following sets the transactionLifetimeLimitSeconds to 30 seconds:以下将transactionLifetimeLimitSeconds设置为30秒:

db.adminCommand( { setParameter: 1, transactionLifetimeLimitSeconds: 30 } )

You can also set parameter transactionLifetimeLimitSeconds at startup time.您还可以在启动时设置参数transactionLifetimeLimitSeconds

mongod --setParameter "transactionLifetimeLimitSeconds=30"

To set the parameter for a sharded cluster, the parameter must be modified for all shard replica set members.要为分片集群设置参数,必须为所有分片副本集成员修改该参数。

Starting in MongoDB 5.0, if you change the transactionLifetimeLimitSeconds parameter, you must also change transactionLifetimeLimitSeconds to the same value on all config server replica set members. 从MongoDB 5.0开始,如果更改transactionLifetimeLimitSeconds参数,则还必须在所有配置服务器副本集成员上将transactionLifetimeLimitSeconds更改为相同的值。Keeping this value consistent:保持此值一致:

  • Ensures the routing table history is retained for at least as long as the transaction lifetime limit on the shard replica set members.确保路由表历史记录的保留时间至少与分片副本集成员的事务生存期限制一样长。
  • Reduces the transaction retry frequency and therefore improves performance.降低事务重试频率,从而提高性能。
transactionTooLargeForCacheThreshold

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

Available for mongod only.仅适用于mongod

Type: decimal

Default: 0.75

The threshold value for retrying transactions that fail due to cache pressure. The value is a percentage of the dirty cache size. The default value, 0.75, means 75% of the dirty cache.重试因缓存压力而失败的事务的阈值。该值是脏缓存大小的百分比。默认值0.75表示75%的脏缓存。

The dirty cache is limited to 20% of the total cache size. When transactionTooLargeForCacheThreshold is set to 0.75, the server only retries transactions that use less than 15% (0.75 * 20%) of the total storage engine cache.脏缓存限制为总缓存大小的20%。当transactionTooLargeForCacheThreshold设置为0.75时,服务器仅重试使用总存储引擎缓存不足15%(0.75*20%)的事务。

The limit only applies to retries. Large transactions can use more than transactionTooLargeForCacheThreshold percent of the dirty cache. 该限制仅适用于重试。大型事务可以使用超过transactionTooLargeForCacheThreshold百分比的脏缓存。However, if a large transaction is rolled back due to cache pressure, the server issues a TransactionTooLargeForCache error and does not retry the transaction.但是,如果由于缓存压力而回滚了一个大型事务,服务器会发出TransactionTooLargeForCache错误,并且不会重试该事务。

To disable this behavior, set transactionTooLargeForCacheThreshold to 1.0.要禁用此行为,请将transactionTooLaggeForCacheThreshold设置为1.0

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

For more information on WiredTiger storage, see: storage.wiredTiger Options.有关WiredTiger存储的详细信息,请参阅:storage.wiredTiger选项。

maxTransactionLockRequestTimeoutMillis

Available for mongod only.仅适用于mongod

Type: integer

Default: 5

The maximum amount of time in milliseconds that multi-document transactions should wait to acquire locks required by the operations in the transaction.多文档事务应等待以获取事务中操作所需锁的最长时间(毫秒)。

If the transaction cannot acquire the locks after waiting maxTransactionLockRequestTimeoutMillis, the transaction aborts.如果事务在等待maxTransactionLockRequestTimeoutMillis后无法获取锁,则事务中止。

By default, multi-document transactions wait 5 milliseconds. 默认情况下,多文档事务等待5毫秒。That is, if the transaction cannot acquire the locks within 5 milliseconds, the transaction aborts. If an operation provides a greater timeout in a lock request, maxTransactionLockRequestTimeoutMillis overrides the operation-specific timeout.

You can set maxTransactionLockRequestTimeoutMillis to:您可以将maxTransactionLockRequestTimeoutMillis设置为:

  • 0 such that if the transaction cannot acquire the required locks immediately, the transaction aborts.这样,如果事务不能立即获取所需的锁,则事务中止。
  • A number greater than 0 to wait the specified time to acquire the required locks. 一个大于0的数字,用于等待指定时间以获取所需的锁。This can help obviate transaction aborts on momentary concurrent lock acquisitions, like fast-running metadata operations. However, this could possibly delay the abort of deadlocked transaction operations.这可以帮助避免瞬时并发锁获取时的事务中止,如快速运行的元数据操作。然而,这可能会延迟死锁事务操作的中止。
  • -1 to use the operation specific timeout.以使用特定于操作的超时。

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following sets the maxTransactionLockRequestTimeoutMillis to 20 milliseconds:

db.adminCommand( { setParameter: 1, maxTransactionLockRequestTimeoutMillis: 20 } )

You can also set this parameter during start-up:

mongod --setParameter maxTransactionLockRequestTimeoutMillis=20

Slot-Based Execution Parameters

planCacheSize

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

Available for mongod only.仅适用于mongod

Type: string

Default: 5%

Note

Although the planCacheSize parameter existed in prior versions of MongoDB, it had no effect on the plan cache until version 6.3.

Sets the size of the plan cache only for the slot-based query execution engine.

You can set the planCacheSize value to either:

  • A percentage of the system's total physical memory to allocate for the plan cache. For example, "8.5%".
  • The exact amount of data to allocate for the plan cache in either MB or GB. For example, "100MB" or "1GB".

Increasing the plan cache size adds more cached plan cache query shapes for the query planner. This can improve query performance, but increases memory usage.

This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:

  • To set the parameter at runtime, use the setParameter command.要在运行时设置参数,请使用setParameter命令。
  • To set the parameter at startup, use the setParameter setting.要在启动时设置参数,请使用setParameter设置。

The following startup command sets planCacheSize to 80 megabytes:

mongod --setParameter planCacheSize="80MB"

You can also use the setParameter command within the MongoDB Shell:

db.adminCommand( { setParameter: 1, planCacheSize: "80MB" } )