MongoDB Server Parameters服务器参数

On this page本页内容

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 Configuration File Options, mongod and mongos.有关其他配置选项,请参阅配置文件选项mongodmongos

Parameters参数

Authentication Parameters身份验证参数

authenticationMechanisms

Changed in version 4.0.在版本4.0中更改

Remove support for the deprecated MONGODB-CR authentication mechanism.删除对不推荐使用的MONGODB-CR身份验证机制的支持。

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.有关身份验证机制的描述,请参阅身份验证

ValueDescription描述
SCRAM-SHA-1RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.使用SHA-1哈希函数的标准Salted质询-响应身份验证机制。
SCRAM-SHA-256

RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.使用SHA-256哈希函数的标准Salted质询-响应身份验证机制。

Requires featureCompatibilityVersion set to 4.0.需要将featureCompatibilityVersion设置为4.0

New in version 4.0.在版本4.0中新增

MONGODB-X509MongoDB TLS/SSL certificate authentication.证书认证。
GSSAPI (Kerberos)External authentication using Kerberos. 使用Kerberos的外部身份验证。This mechanism is available only in MongoDB Enterprise.此机制仅在MongoDB Enterprise中可用。
PLAIN (LDAP SASL)External authentication using LDAP. 使用LDAP进行外部身份验证。You can also use PLAIN for authenticating in-database users. 还可以使用PLAIN对数据库用户进行身份验证。PLAIN transmits passwords in plain text. PLAIN传输明文密码。This mechanism is available only in MongoDB Enterprise.此机制仅在MongoDB企业版中可用。

You can only set authenticationMechanisms during start-up.只能在启动期间设置authenticationMechanisms(身份验证机制)。

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
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 and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodmongos以及用于客户端TLS/SSL配置

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

Available for both mongod and mongos.mongodmongos均可使用。

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

enableLocalhostAuthBypass is not available using setParameter database command. 使用setParameter数据库命令时,enableLocalhostAuthBypass不可用。Use the setParameter option in the configuration file or the --setParameter option on the command line.使用配置文件中的setParameter选项或命令行中的--setParameter选项。

See Localhost Exception for more information.有关详细信息,请参阅本地主机异常

KeysRotationIntervalSec

Default默认值: 7776000 seconds (90 days)

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

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

ldapUserCacheInvalidationInterval

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

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. 用于使用LDAP授权的MongoDB部署。Available for mongod instances only.仅适用于mongod实例。

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. 增加指定的值会增加MongoDB和LDAP服务器可能不同步的时间,但会减少LDAP服务器上的负载。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服务器上的负载。

Defaults to 30 seconds.默认为30秒。

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.用于使用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.用于使用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:如果在LDAP服务器上没有成功刷新用户信息的情况下,超过ldapUserCacheStalenessInterval秒,则mongod

  • Invalidates the cached LDAP user information.使缓存的LDAP用户信息无效。
  • Is unavailable for LDAP users. 对LDAP用户不可用。LDAP users are unable to authenticate until mongod contacts the LDAP server.mongod联系LDAP服务器之前,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 } )
ldapUseConnectionPool

New in version 4.0.9.在版本4.0.9中新增

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

Starting in version 4.2, MongoDB uses the following default values:从4.2版开始,MongoDB使用以下默认值:

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

In earlier versions (versions 4.0.9+), the default value is false.

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

ldapConnectionPoolUseLatencyForHostPriority

New in version 4.2.1 and 4.0.13版本4.2.1和4.0.13中新增

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 runtime with the setParameter database command.只能在启动期间设置ldapConnectionPoolUseLatencyForHostPriority,不能使用setParameter数据库命令在运行期间更改此设置。

ldapConnectionPoolMinimumConnectionsPerHost

New in version 4.2.1 and 4.0.13版本4.2.1和4.0.13中新增

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 runtime with the setParameter database command.只能在启动期间设置ldapConnectionPoolMinimumConnectionsPerHost,不能使用setParameter数据库命令在运行期间更改此设置。

ldapConnectionPoolMaximumConnectionsPerHost

New in version 4.2.1 and 4.0.13版本4.2.1和4.0.13中新增

Changed in version 4.4.在版本4.4中更改

Changed default value to 2. 将默认值更改为2In previous versions, the default is unset.在以前的版本中,默认设置为未设置。

Default默认值: 2

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 runtime with the setParameter database command.只能在启动期间设置ldapConnectionPoolMaximumConnectionsPerHost,不能使用setParameter数据库命令在运行期间更改此设置。

ldapConnectionPoolMaximumConnectionsInProgressPerHost

New in version 4.2.1 and 4.0.13版本4.2.1和4.0.13中新增

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数据库命令更改此设置。

ldapConnectionPoolHostRefreshIntervalMillis

New in version 4.2.1 and 4.0.13版本4.2.1和4.0.13中新增

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

New in version 4.2.1 and 4.0.13版本4.2.1和4.0.13中新增

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数据库命令更改此设置。

ldapShouldRefreshUserCacheEntries

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

Available for mongod only.仅适用于mongod

Type类型: boolean

Default默认值: true

For MongoDB deployments using LDAP Authorization.用于使用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. 在启动期间,只能在配置文件中设置ldapShouldRefreshUserCacheEntries,或者在命令行上使用--setParameter选项。For example, the following disables ldapShouldRefreshUserCacheEntries:例如,以下命令禁用ldapShouldRefreshUserCacheEntries

mongod --setParameter ldapShouldRefreshUserCacheEntries=false
maxValidateMemoryUsageMB

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将返回尽可能多的结果,并警告说,由于限制,可能不会报告所有的损坏。

You can set maxValidateMemoryUsageMB during startup, and can change this setting using the setParameter database command.您可以在启动期间设置maxValidateMemoryUsageMB,并可以使用setParameter数据库命令更改此设置。

ocspEnabled

New in version 4.4.在版本4.4中新增 Available on Linux and macOS.可在Linux和macOS上使用。

Default默认值: true

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

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

mongod --setParameter ocspEnabled=false ...
ocspValidationRefreshPeriodSecs

New in version 4.4.在版本4.4中新增 Available on Linux.可在Linux上使用。

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

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

mongod --setParameter ocspValidationRefreshPeriodSecs=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响应。

opensslCipherConfig

Available on Linux only仅在Linux上可用

Changed in version 4.0.在版本4.0中更改

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库,Linux/BSD支持参数opensslCipherConfig,Windows和macOS不再支持该参数。See MongoDB 4.0 TLS/SSL.请参阅MongoDB 4.0 TLS/SSL

Specify the cipher string for OpenSSL when using TLS/SSL encryption. 使用TLS/SSL加密时,指定OpenSSL的密码字符串。For a list of cipher strings, see https://www.openssl.org/docs/man1.1.1/man1/ciphers.html. 有关密码字符串列表,请参阅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. 此参数仅用于TLS 1.2或更早版本。To specify cipher suites for use with TLS 1.3, use the opensslCipherSuiteConfig parameter.要指定用于TLS 1.3的密码套件,请使用opensslCipherSuiteConfig参数。

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

For version 4.2 and greater, the use of TLS options is preferred over SSL options. 对于4.2及更高版本,使用TLS选项比使用SSL选项更可取。The TLS options have the same functionality as the SSL options. TLS选项与SSL选项具有相同的功能。For example, the following configures a mongod with a opensslCipherConfig cipher string of 'HIGH:!EXPORT:!aNULL@STRENGTH' in MongoDB 4.2:例如,下面在MongoDB 4.2中使用opensslCipherConfig加密字符串'HIGH:!EXPORT:!aNULL@STRENGTH'配置mongod

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

For versions 4.0 and earlier:对于4.0及更早版本:

mongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL@STRENGTH' --sslMode requireSSL --sslPEMKeyFile Certs/server.pem
opensslCipherSuiteConfig

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. 有关与TLS 1.3一起使用的密码套件列表,请参阅https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_cipher_list.htmlMultiple cipher suites can be provided as a colon-separated list.可以以冒号分隔的列表形式提供多个密码套件。

Note注意

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

You can only set opensslCipherSuiteConfig during start-up, and cannot change this setting using the setParameter database command. 只能在启动期间设置opensslCipherSuiteConfig,不能使用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:例如,下面使用'TLS_AES_256_GCM_SHA384'opensslCipherSuiteConfig密码套件配置mongod,用于TLS 1.3:

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

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加密期间支持短暂的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-Hellman(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注意

Starting in MongoDB 4.2, 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. 从MongoDB 4.2开始,如果opensslDiffieHellmanParameters参数未设置但启用了ECDHE,MongoDB将使用RFC-7919附录A.2中定义的ffdhe3072 Diffie-Hellman参数启用DHE。The ffdhe3072 is a strong parameter (specifically, size is greater than 1024). ffdhe3072是一个强参数(具体来说,大小大于1024)。Strong parameters are not supported with Java 6 and 7 unless extended support has been purchased from Oracle.Java 6和7不支持强参数,除非从Oracle购买了扩展支持。

You can only set opensslDiffieHellmanParameters during startup, and cannot change this setting using the setParameter database command.您只能在启动期间设置opensslDiffieHellmanParameters,并且不能使用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' ...
saslauthdPath
Note注意
Available only in MongoDB Enterprise (except MongoDB Enterprise for Windows).仅在MongoDB Enterprise中可用(Windows版MongoDB Enterprise除外)。

Available for both mongod and mongos.mongodmongos均可使用。

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

saslHostName

Available for both mongod and mongos.mongodmongos均可使用。

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

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

You can only set saslHostName during start-up, and cannot change this setting using the setParameter database command.你只能在启动期间设置saslHostName,无法使用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. 允许用户在每个实例的基础上覆盖Kerberos主体名称的默认Kerberos服务名称组件。If unspecified, the default value is mongodb.如果未指定,则默认值为mongodb

MongoDB only permits setting saslServiceName at startup. MongoDB只允许在启动时设置saslServiceNameThe setParameter command can not change this setting.setParameter命令无法更改此设置。

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

Important重要

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

scramIterationCount

Default默认值: 10000

Available for both mongod and mongos.mongodmongos均可使用。

Changes the number of hashing iterations used for all new SCRAM-SHA-1 passwords. 更改用于所有新的SCRAM-SHA-1密码的哈希迭代次数。More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts. 更多的迭代会增加客户端向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或更大。

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

New in version 4.0.在版本4.0中新增

Default默认值: 15000

Available for both mongod and mongos.mongodmongos均可使用。

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

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

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. net.ssl.mode设置为preferSSLrequireSSLUseful during rolling upgrade to TLS/SSL to minimize downtime.滚动升级到TLS/SSL时非常有用,可最大限度地减少停机时间。

For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodmongos以及用于客户端TLS/SSL配置

db.adminCommand( { setParameter: 1, sslMode: "preferSSL" } )
Tip提示
See also: 参阅:
tlsMode

New in version 4.2.在版本4.2中新增

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期间非常有用,可以最大限度地减少停机时间。

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

For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodmongos以及用于客户端TLS/SSL配置

Tip提示
See also: 参阅:
tlsOCSPStaplingTimeoutSecs

New in version 4.4.在版本4.4中新增 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. 指定一个大于或等于(>=)1的整数。If unset, tlsOCSPStaplingTimeoutSecs uses the tlsOCSPVerifyTimeoutSecs value.如果未设置,则tlsOCSPStaplingTimeoutSecs将使用tlsOCSPVerifyTimeoutSecs值。

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

mongod --setParameter tlsOCSPStaplingTimeoutSecs=20 ...
tlsOCSPVerifyTimeoutSecs

New in version 4.4.在版本4.4中新增 Available for Linux and Windows.适用于Linux和Windows。

Default默认值: 5

The maximum number of seconds that the mongod/mongos should wait for the OCSP response when verifying client certificates.验证客户端证书时,mongod/mongos应等待OCSP响应的最长秒数。

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

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

mongod --setParameter tlsOCSPVerifyTimeoutSecs=20 ...
tlsWithholdClientCertificate

Default默认值: false

New in version 4.2.在版本4.2中新增

Available for both mongod and mongos.mongodmongos均可使用。

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.--clusterAuthMode x509互斥。

tlsX509ClusterAuthDNOverride

New in version 4.2.在版本4.2中新增

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.50 9证书(net.tls.clusterFile,如果指定,以及net.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.如果已设置,则必须在部署的所有成员上设置此参数。

You can use this parameter for a rolling update of certificates to new certificates that contain a new DN value. 可以使用此参数将证书滚动更新为包含新DN值的新证书。See Rolling Update of x.509 Cluster Certificates that Contain New DN.请参阅包含新DN的x.509群集证书的滚动更新

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

tlsX509ExpirationWarningThresholdDays

New in version 4.4.在版本4.4中新增

Default默认值 : 30

Available for both mongod and mongos.mongodmongos均可使用。

Starting in MongoDB 4.4, mongod/mongos logs a warning on connection if the presented x.509 certificate expires within 30 days of the mongod/mongos system clock. 从MongoDB 4.4开始,如果提供的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

You can only set tlsX509ExpirationWarningThresholdDays during mongod/mongos startup using either:mongod/mongos启动期间,您只能使用以下选项之一设置tlsX509ExpirationWarningThresholdDays

See x.509 Certificates Nearing Expiry Trigger Warnings for more information on x.509 expiration warnings in MongoDB 4.4.有关MongoDB 4.4中x.509到期警告的更多信息,请参阅x.509证书即将到期触发警告。

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

sslWithholdClientCertificate

Default默认值: false

Deprecated since version 4.2自4.2版以来已弃用: Use tlsWithholdClientCertificate instead.:请改用tlsWithholdClientCertificate

Available for both mongod and mongos.mongodmongos均可使用。

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 sslWithholdClientCertificate to 1 or true to direct the instance to withhold sending its TLS certificate during these communications. sslWithholdClientCertificate设置为1true,以指示实例在这些通信期间不发送其TLS证书。Use this option with --tlsAllowConnectionsWithoutCertificates(to allow inbound connections without certificates) on all members of the deployment. 将此选项与部署的所有成员上的--tlsAllowConnectionsWithoutCertificates(允许无证书的入站连接)一起使用。sslWithholdClientCertificate is mutually exclusive with --clusterAuthMode x509.--clusterAuthMode x509互斥。

userCacheInvalidationIntervalSecs

Default默认值: 30

Available for mongos only.仅适用于mongos

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小时)。

authFailedDelayMs

Default默认值: 0

Available for both mongod and mongos.mongodmongos均可使用。

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.此参数可能在0到5000之间(含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服务器响应的客户端仍然会消耗服务器资源,如果服务器同时拒绝访问许多其他客户端,这可能会对良性登录尝试产生不利影响。

allowRolesFromX509Certificates

Default默认值: true

Available for both mongod and mongos.mongodmongos均可使用。

Available starting in MongoDB 4.0.11 (and 3.6.14 and 3.4.22)从MongoDB 4.0.11(以及3.6.14和3.4.22)开始提供

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

You can only set allowRolesFromX509Certificates during startup in the config file or on the command line.在启动期间,只能在配置文件或命令行中设置allowRolesFromX509Certificates

General Parameters一般参数

connPoolMaxShardedConnsPerHost

Default默认值: 200

Available for both mongod and mongos.mongodmongos均可使用。

Sets the maximum size of the legacy connection pools for communication to the shards. 设置用于与碎分片通信的旧连接池的最大大小。The size of a pool does not prevent the creation of additional connections, but does prevent the connection pools from retaining connections above this limit.池的大小不会阻止创建其他连接,但阻止连接池保留超过此限制的连接。

Note注意

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

Increase the connPoolMaxShardedConnsPerHost value only if the number of connections in a connection pool has a high level of churn or if the total number of created connections increase.当连接池中的连接数具有较高的搅动级别或创建的连接总数增加时,才增加connPoolMaxShardedConnsPerHost值。

You can only set connPoolMaxShardedConnsPerHost during startup in the config file or on the command line. 在启动期间,只能在配置文件或命令行中设置connPoolMaxShardedConnsPerHostFor example:

mongos --setParameter connPoolMaxShardedConnsPerHost=250
connPoolMaxShardedInUseConnsPerHost

Available for both mongod and mongos.mongodmongos均可使用。

Sets the maximum number of in-use connections at any given time for the legacy sharded cluster connection pools.设置旧分分片群集连接池在任何给定时间的最大在用连接数。

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

You can only set connPoolMaxShardedConnsPerHost during startup in the config file or on the command line. 在启动期间,只能在配置文件或命令行中设置connPoolMaxShardedConnsPerHostFor example:例如:

mongos --setParameter connPoolMaxShardedInUseConnsPerHost=100
Tip提示
See also: 参阅:
shardedConnPoolIdleTimeoutMinutes

Available for both mongod and mongos.mongodmongos均可使用。

Sets the time limit that a connection in the legacy sharded cluster connection pool can remain idle before being closed.设置旧分分片群集连接池中的连接在关闭前可以保持空闲的时间限制。

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

You can only set shardedConnPoolIdleTimeoutMinutes during startup in the config file or on the command line. 在启动期间,只能在配置文件或命令行中设置shardedConnPoolIdleTimeoutMinutesFor example:例如:

mongos --setParameter shardedConnPoolIdleTimeoutMinutes=10
Tip提示
See also: 参阅:
connPoolMaxConnsPerHost

Default默认值: 200

Available for both mongod and mongos.mongodmongos均可使用。

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. 该参数与TaskExecutor池中的连接是分开的。See ShardingTaskExecutorPoolMaxSize.请参阅ShardingTaskExecutorPoolMaxSize

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

You can only set connPoolMaxConnsPerHost during startup in the config file or on the command line. 在启动期间,只能在配置文件或命令行中设置connPoolMaxConnsPerHostFor example:例如:

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.默认情况下,该参数是未设置的。

You can only set connPoolMaxInUseConnsPerHost during startup in the config file or on the command line. 在启动期间,只能在配置文件或命令行中设置connPoolMaxInUseConnsPerHostFor example:例如:

mongod --setParameter connPoolMaxInUseConnsPerHost=100
Tip提示
See also: 参阅:
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.默认情况下,该参数未设置。

You can only set globalConnPoolIdleTimeoutMinutes during startup in the config file or on the command line. 您只能在配置文件或命令行中设置启动期间的globalConnPoolIdleTimeoutMinutesFor example:例如:

mongos --setParameter globalConnPoolIdleTimeoutMinutes=10
Tip提示
See also: 参阅:
cursorTimeoutMillis

Default默认值: 600000 (10 minutes)

Available for both mongod and mongos.mongodmongos均可使用。

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中空闲的游标。

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()游标修饰符之类的工具来分析平均查询时间并选择适当的超时时间。

failIndexKeyTooLong

Removed in 4.4在4.4中删除

Important重要

For MongoDB 2.6 through MongoDB versions with featureCompatibilityVersion (fCV) set to "4.0" or earlier, Index Key Length Limit applies. 对于featureCompatibilityVersion(fCV)设置为“4.0”或更早版本的MongoDB 2.6到MongoDB版本,适用索引密钥长度限制。If you attempt to insert or update a document whose index field exceeds the Index Key Length Limit, the operation will fail and return an error to the client.如果尝试插入或更新索引字段超过索引键长度限制的文档,则操作将失败并向客户端返回错误。

To avoid this issue, consider using hashed indexes or indexing a computed value. 为避免此问题,请考虑使用散列索引或对计算值进行索引。If you have an existing data set and want to disable this behavior so you can upgrade and then gradually resolve these indexing issues, you can use failIndexKeyTooLong to disable this behavior.如果您有一个现有的数据集并希望禁用此行为,以便可以升级并逐步解决这些索引问题,可以使用failIndexKeyTooLong禁用此行为。

Setting failIndexKeyTooLong to false is a temporary workaround, not a permanent solution to the problem of oversized index keys. failIndexKeyTooLong设置为false是一种临时解决方案,而不是解决索引键过大问题的永久解决方案。With failIndexKeyTooLong set to false, queries can return incomplete results if they use indexes that skip over documents whose indexed fields exceed the Index Key Length Limit.failIndexKeyTooLong设置为false时,如果查询使用的索引跳过索引字段超过索引键长度限制的文档,则可能返回不完整的结果。

failIndexKeyTooLong defaults to true.默认为true

Issue the following command to disable the index key length validation:发出以下命令以禁用索引键长度验证:

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

You can also set failIndexKeyTooLong at startup with the following option:您还可以使用以下选项在启动时设置failIndexKeyTooLong

mongod --setParameter failIndexKeyTooLong=false
notablescan

Available for mongod only.仅适用于mongod

Specify whether all queries must use indexes. 指定是否所有查询都必须使用索引。If 1, MongoDB will not execute queries that require a collection scan and will return an error.如果为1,MongoDB将不执行需要集合扫描的查询,并返回错误。

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

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

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

To detect unindexed queries without notablescan, consider reading the Evaluate Performance of Current Operations and Optimize Query Performance sections and using the logLevel parameter, mongostat and profiling.要检测没有notablescan的未索引查询,请考虑阅读评估当前操作的性能优化查询性能部分,并使用logLevel参数、mongostatprofiling

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

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索引的集合中删除文档。

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. 除非在MongoDB支持的指导下,否则不要在禁用ttlMonitorEnabled的情况下运行生产mongod实例。Preventing TTL document removal can negatively impact MongoDB internal system operations that depend on TTL Indexes.防止删除TTL文档可能会对依赖于TTL索引的MongoDB内部系统操作产生负面影响。

tcpFastOpenServer

New in version 4.4.在版本4.4中新增

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. 支持从客户端接受到mongod/mongos的入站TCP快速开放(TFO)连接。TFO requires both the client and mongod/mongos host machine support and enable TFO:TFO需要客户端和mongod/mongos主机支持,并启用TFO:

Windows

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

  • Microsoft Windows Server 2016 and later.Microsoft Windows Server 2016及更高版本。
  • Microsoft Windows 10 Update 1607 and later.Microsoft Windows 10更新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内核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连接,则此参数无效。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

See Support for TCP Fast Open for more information on MongoDB TFO support.有关MongoDB TFO支持的更多信息,请参阅支持TCP Fast Open

Tip提示
See also: 参阅:
tcpFastOpenClient

New in version 4.4.在版本4.4中新增

Available for both mongod and mongos.mongodmongos均可使用。

Default默认值: true

Linux Operating System Only仅Linux操作系统

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

Linux operating systems running Linux Kernel 4.11 or later can support outbound TFO.运行Linux内核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连接,则此参数无效。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.您只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

See Support for TCP Fast Open for more information on MongoDB TFO support.有关MongoDB TFO支持的更多信息,请参阅支持TCP Fast Open

Tip提示
See also: 参阅:
tcpFastOpenQueueSize

New in version 4.4.在版本4.4中新增

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

    The minimum queue size is 0. 最小队列大小为0A queue of 0 effectively disables TFO.队列0实际上禁用了TFO。

This parameter has no effect on host operating systems that do not support or are not configured for TFO connections. 此参数对不支持或未配置TFO连接的主机操作系统没有影响。See Support for TCP Fast Open for more information on MongoDB TFO support.有关MongoDB TFO支持的更多信息,请参阅支持TCP Fast Open

disableJavaScriptJIT

Changed in version 4.0.在版本4.0中更改

The JavaScript engine's JIT compiler is now disabled by default.JavaScript引擎的JIT编译器现在默认禁用。

Available for mongod only.仅适用于mongod

The MongoDB JavaScript engine uses SpiderMonkey, which implements Just-in-Time (JIT) compilation for improved performance when running scripts.MongoDB JavaScript引擎使用SpiderMonkey,该引擎实现实时(JIT)编译,以提高运行脚本时的性能。

To enable the JIT, set disableJavaScriptJIT to false, as in the following example:要启用JIT,请将disableJavaScriptJIT设置为false,如下例所示:

db.adminCommand( { setParameter: 1, disableJavaScriptJIT: false } )
Note注意

$where will reuse existing JavaScript interpreter contexts, so changes to disableJavaScriptJIT may not take effect immediately for these operations.将重用现有的JavaScript解释器上下文,因此对disableJavaScriptJIT的更改可能不会对这些操作立即生效。

Alternately, you may enable the JIT at startup time by starting the mongod instance with the following option:或者,您可以通过使用以下选项启动mongod实例,在启动时启用JIT:

mongod --setParameter disableJavaScriptJIT=false
indexMaxNumGeneratedKeysPerDocument

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参数指定的键,则操作将失败。

maxIndexBuildMemoryUsageMegabytes

Default默认值:

  • 200 (For versions 4.2.3 and later)(适用于版本4.2.3及更高版本)
  • 500 (For versions 4.2.2 and earlier)(适用于4.2.2及更早版本)

Limits the amount of memory that simultaneous index builds on one collection may consume for the duration of the builds. 限制在一个集合上同时生成索引在生成期间可能消耗的内存量。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()构建的所有索引之间共享。

The memory consumed by an index build is separate from the WiredTiger cache memory (see cacheSizeGB).索引构建所消耗的内存与WiredTiger缓存内存是分开的(请参阅cacheSizeGB)。

Index builds may be initiated either by a user command such as Create Index or by an administrative process such as an initial sync. 索引构建可以由用户命令(如创建索引)或管理过程(如初始同步)启动。Both are subject to the limit set by maxIndexBuildMemoryUsageMegabytes.

An initial sync operation populates only one collection at a time and has no risk of exceeding the memory limit. 初始同步操作一次只填充一个集合,没有超过内存限制的风险。However, it is possible for a user to start index builds on multiple collections in multiple databases simultaneously and potentially consume an amount of memory greater than the limit set in maxIndexBuildMemoryUsageMegabytes.但是,用户可以同时在多个数据库中的多个集合上启动索引构建,并且可能会消耗大于maxIndexBuildMemoryUsageMegabytes中设置的限制的内存量。

Tip提示

To minimize the impact of building an index on replica sets and sharded clusters with replica set shards, use a rolling index build procedure as described on Rolling Index Builds on Replica Sets.要最小化使用副本集分片在副本集和分片群集上构建索引的影响,请使用滚动索引构建过程,如在副本集上滚动索引构建中所述。

Changed in version 4.2.在版本4.2中更改

reportOpWriteConcernCountersInServerStatus

New in version 4.0.6.在版本4.0.6中新增

Default默认值: false

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

You can only set reportOpWriteConcernCountersInServerStatus during startup in the config file or on the command line. 在启动期间,只能在配置文件或命令行中设置reportOpWriteConcernCountersInServerStatusFor example:例如:

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

Available for mongod only.仅适用于mongod

Type类型: integer

Default默认值: -1 (disabled)

Note注意
  • Starting in MongoDB 4.2, the Storage Node Watchdog is available in both the Community and MongoDB Enterprise editions.从MongoDB 4.2开始,存储节点看门狗在Community和MongoDB Enterprise版本中都可用。
  • In earlier versions (3.2.16+, 3.4.7+, 3.6.0+, 4.0.0+), the Storage Node Watchdog is only available in MongoDB Enterprise edition.

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)并将数据库目录符号链接到另一个卷,则Storage Node Watchdog不会跟随符号链接来监视目标。

To enable Storage Node Watchdog, watchdogPeriodSeconds must be set during startup.要启用Storage Node Watchdog,必须在启动期间设置watchdogPeriodSeconds

mongod --setParameter watchdogPeriodSeconds=60

You can only enable the Storage Node Watchdog at startup. 您只能在启动时启用Storage Node WatchdogHowever, once enabled, you can pause the Storage Node Watchdog or change the watchdogPeriodSeconds during runtime.但是,一旦启用,您可以在运行时暂停Storage Node Watchdog或更改watchdogPeriodSeconds

Once enabled,一旦启用,

Note注意

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

tcmallocReleaseRate

New in version 4.2.3.在版本4.2.3中新增 Also available in 3.6.17+ and 4.0.14+

Default: 1.0默认值:1.0

Specifies the tcmalloc release rate (TCMALLOC_RELEASE_RATE). 指定tcmalloc释放速率(TCMALLOC_RELEASE_RATE)。Per https://gperftools.github.io/gperftools/tcmalloc.html#runtime TCMALLOC_RELEASE_RATE is described as the "Rate at which we release unused memory to the system, via madvise(MADV_DONTNEED), on systems that support it. https://gperftools.github.io/gperftools/tcmalloc.html#runtime TCMALLOC_RELEASE_RATE被描述为“在支持它的系统上,通过madvise(MADV_DONTNEED)将未使用的内存释放到系统的速率。Zero means we never release memory back to the system. 零意味着我们永远不会将内存释放回系统。Increase this flag to return memory faster; decrease it to return memory slower. Reasonable rates are in the range [0,10]."增加此标志以更快地返回内存;减小该值以减慢返回内存的速度。合理费率在[0,10]范围内。”

To modify the release rate during runtime, you can use the setParameter command; for example:要在运行时修改释放率,可以使用setParameter命令;例如:

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

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

mongod --setParameter "tcmallocReleaseRate=5.0"
fassertOnLockTimeoutForStepUpDown

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

Default: 15 seconds默认值:15秒

Available for both mongod and mongos.mongodmongos均可使用。

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。

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

mongod --setParameter fassertOnLockTimeoutForStepUpDown=0

Logging Parameters日志记录参数

logLevel

Available for both mongod and mongos.mongodmongos均可使用。

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

The default logLevel is 0 (Informational).默认logLevel0(信息)。

The following example sets the logLevel to 2:以下示例将logLevel设置为2

db.adminCommand( { setParameter: 1, logLevel: 2 } )
Tip提示
[2] 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. 例如,如果详细级别为2,则MongoDB记录D2In previous versions, MongoDB log messages only specified D for Debug level.在以前的版本中,MongoDB日志消息只为调试级别指定了D
logComponentVerbosity

Available for both mongod and mongos.mongodmongos均可使用。

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

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详细级别,该级别也适用于:

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.例如,下面将默认的详细级别设置为1,将query设置为2,将storage设置为2以及将storage.journal设置为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. mongosh还提供了db.setLogLevel()来设置单个组件的日志级别。For various ways to set the log verbosity level, see Configure Log Verbosity Levels.有关设置日志详细级别的各种方法,请参阅配置日志详细级别

[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. 例如,如果详细级别为2,MongoDB将记录D2In previous versions, MongoDB log messages only specified D for Debug level.在以前的版本中,MongoDB日志消息只为调试级别指定了D
maxLogSizeKB

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: non-negative integer:非负整数

Default默认值: 10

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

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

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的截断可能会对系统性能产生负面影响,并对数据库操作产生负面影响。

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:如果为1,mongod将进入安静日志模式,该模式不会记录以下事件/活动:

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

db.adminCommand( { setParameter: 1, quiet: 1 } )
Tip提示
See also: 参阅:
redactClientLogData

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: boolean

Note注意
Enterprise Feature企业功能

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

Configure the mongod or mongos to redact any message accompanying a given log event before logging. 配置mongodmongos,以便在记录之前编辑伴随给定日志事件的任何消息。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.redactClientLogData静态加密TLS/SSL(传输加密)结合使用,以帮助遵守法规要求。

To enable log redaction on a running mongod or mongos, use the following command:要在运行的mongodmongos上启用日志编校,请使用以下命令:

db.adminCommand( { setParameter: 1, redactClientLogData : true } )
Tip提示
See also: 参阅:
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. mongod配置为记录每个数据库和套接字C++异常的完整源代码堆栈跟踪,以用于调试。If true, mongod will log full stack traces.如果为truemongod将记录整个堆栈跟踪。

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

db.adminCommand( { setParameter: 1, traceExceptions: true } )
Tip提示
See also: 参阅:
suppressNoTLSPeerCertificateWarning

New in version 4.0.1.在版本4.0.1中新增

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. 默认情况下,启用TLS/SSL并且net.ssl.allowConnectionsWithoutCertificatesmongodmongos允许客户端在记录警告时进行连接,而无需提供验证证书。Set suppressNoTLSPeerCertificateWarning to 1 or true to suppress those warnings.suppressNoTLSPeerCertificateWarning设置为1true以抑制这些警告。

The following operation sets suppressNoTLSPeerCertificateWarning to true:以下操作将suppressNoTLSPeerCertificateWarning设置为true

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

Diagnostic Parameters诊断参数

To facilitate analysis of the MongoDB server behavior by MongoDB engineers, MongoDB logs server statistics to diagnostic files at periodic intervals.为了便于MongoDB工程师分析MongoDB服务器行为,MongoDB定期将服务器统计信息记录到诊断文件中。

For mongod, the diagnostic data files are stored in the diagnostic.data directory under the mongod instance's --dbpath or storage.dbPath.对于mongod,诊断数据文件存储在mongod实例的--dbpathdiagnostic.data目录中或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. 对于mongos,默认情况下,诊断数据文件存储在mongos实例的--logpath的目录中或systemLog.path目录下。The diagnostic data directory is computed by truncating the logpath's file extension(s) and concatenating diagnostic.data to the remaining name.诊断数据目录是通过截断日志路径的文件扩展名并将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/ directory. 例如,如果mongos--logpath /var/log/mongodb/mongos.log.201708015,则诊断数据目录为/var/log/mongodb/mongos.diagnostic.data/To specify a different diagnostic data directory for mongos, set the diagnosticDataCollectionDirectoryPath parameter.要为mongos指定不同的诊断数据目录,请设置diagnosticDataCollectionDirectoryPath参数。

The following parameters support diagnostic data capture (FTDC):以下参数支持诊断数据捕获(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. 选择诊断数据捕获间隔的默认值和最大大小,以便在对性能和存储大小影响最小的情况下为MongoDB工程师提供有用的数据。Typically, these values will only need modifications as requested by MongoDB engineers for specific diagnostic purposes.通常,这些值只需要根据MongoDB工程师的要求进行修改,以用于特定的诊断目的。

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.默认情况下启用诊断日志记录。

For example, the following disables the diagnostic collection:例如,以下内容将禁用诊断集合:

mongod --setParameter diagnosticDataCollectionEnabled=false
diagnosticDataCollectionDirectoryPath

Type类型: String

Available for mongos only.仅适用于mongos

Specify the directory for the diagnostic directory for mongos. 指定mongos诊断目录的目录。If the directory does not exist, mongos creates the directory.如果目录不存在,mongos将创建该目录。

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.如果未指定,则通过截断mongos实例的--logpathsystemLog.path文件扩展名并连接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/.例如,如果mongos具有--logpath /var/log/mongodb/mongos.log.201708015,则诊断数据目录为/var/log/mongodb/mongos.diagnostic.data/

Important重要

If the mongos cannot create the specified directory, the diagnostic data capture is disabled for that instance. 如果mongos无法创建指定的目录,那么将禁用该实例的诊断数据捕获。This is often caused by:这通常是由以下原因引起的:

  • a file with the same name already exists in the path, or路径中已存在同名文件,或者
  • the process does not have permissions to create the directory.进程没有创建目录的权限。
diagnosticDataCollectionDirectorySizeMB

Increased default size to 200 megabytes.将默认大小增加到200 MB。

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: integer

Default默认值: 200

Specifies the maximum size, in megabytes, of the diagnostic.data directory. 指定diagnostic.data目录的最大大小(MB)。If directory size exceeds this number, the oldest diagnostic files in the directory are automatically deleted based on the timestamp in the file name.如果目录大小超过此数字,将根据文件名中的时间戳自动删除目录中最旧的诊断文件

For example, the following sets the maximum size of the directory to 250 megabytes:例如,以下命令将目录的最大大小设置为250 MB:

mongod --setParameter diagnosticDataCollectionDirectorySizeMB=250

The minimum value for diagnosticDataCollectionDirectorySizeMB is 10 megabytes. diagnosticDataCollectionDirectorySizeMB的最小值为10 MB。diagnosticDataCollectionDirectorySizeMB must be greater than maximum diagnostic file size diagnosticDataCollectionFileSizeMB.必须大于最大诊断文件大小ddiagnosticDataCollectionFileSizeMB

diagnosticDataCollectionFileSizeMB

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: integer

Default默认值: 10

Specifies the maximum size, in megabytes, of each diagnostic file. 指定每个诊断文件的最大大小(MB)。If the file exceeds the maximum file size, MongoDB creates a new file.如果文件超过最大文件大小,MongoDB将创建一个新文件。

For example, the following sets the maximum size of each diagnostic file to 20 megabytes:例如,下面将每个诊断文件的最大大小设置为20 MB:

mongod --setParameter diagnosticDataCollectionFileSizeMB=20

The minimum value for diagnosticDataCollectionFileSizeMB is 1 megabyte.diagnosticDataCollectionFileSizeMB的最小值为1 MB。

diagnosticDataCollectionPeriodMillis

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: integer

Default默认值: 1000

Specifies the interval, in milliseconds, at which to collect diagnostic data.指定集合诊断数据的间隔(毫秒)。

For example, the following sets the interval to 5000 milliseconds or 5 seconds:例如,以下命令将间隔设置为5000毫秒或5秒:

mongod --setParameter diagnosticDataCollectionPeriodMillis=5000

The minimum value for diagnosticDataCollectionPeriodMillis is 100 milliseconds.diagnosticDataCollectionPeriodMillis的最小值为100毫秒。

Replication and Consistency复制和一致性

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.要为拆分范围DNS配置群集节点,请使用主机名而不是IP地址。

Starting in MongoDB v5.0, replSetInitiate and replSetReconfig reject configurations that use IP addresses instead of hostnames.从MongoDB v5.0开始,replSetInitiatereplSetReconfig拒绝使用IP地址而不是主机名的配置。

Use disableSplitHorizonIPCheck to modify nodes that cannot be updated to use host names. 使用disableSplitHorizonIPCheck修改无法更新为使用主机名的节点。The parameter only applies to the configuration commands.该参数仅适用于配置命令。

mongod and mongos do not rely on disableSplitHorizonIPCheck for validation at startup. mongodmongos在启动时不依赖disableSplitHorizonIPCheck进行验证。Legacy mongod and mongos instances that use IP addresses instead of host names will start after an upgrade.使用IP地址而不是主机名的旧mongodmongos实例将在升级后启动。

Instances that are configured with IP addresses log a warning to use host names instead of IP addresses.配置了IP地址的实例会记录一条警告,以使用主机名而不是IP地址。

To allow configuration changes using IP addresses, set disableSplitHorizonIPCheck=true using the command line:要允许使用IP地址更改配置,请使用命令行设置disableSplitHorizonIPCheck=true

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

To allow configuration changes using IP addresses, set disableSplitHorizonIPCheck=true using the node's configuration file:要允许使用IP地址更改配置,请使用节点的配置文件将disableSplitHorizonIPCheck设置为true

setParameter:
   disableSplitHorizonIPCheck: true

If you attempt to update disableSplitHorizonIPCheck at runtime, db.adminCommand() returns an error:如果尝试在运行时更新disableSplitHorizonIPCheckdb.adminCommand()将返回一个错误:

db.adminCommand( { setParameter: 1, "disableSplitHorizonIPCheck": true } )
MongoServerError: not allowed to change [disableSplitHorizonIPCheck] at runtime
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.如果enableOverrideClusterChainingSettingtrue,则副本集secondary成员可以从其他辅助成员复制数据,即使settings.chainingAllowedfalse

You can only set enableOverrideClusterChainingSetting at startup and cannot change this setting with the setParameter command.您只能在启动时设置enableOverrideClusterChainingSetting,不能使用setParameter命令更改此设置。

For example, to set the enableOverrideClusterChainingSetting for a mongod instance to true:例如,要将mongod实例的enableOverrideClusterChainingSetting设置为true

mongod --setParameter enableOverrideClusterChainingSetting=true
logicalSessionRefreshMillis
Note注意
Availability可用性

New in version 4.0.4 (and version 3.6.9).4.0.4版(和3.6.9版)中的新增功能。

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.缓存根据主会话存储刷新其逻辑会话记录的间隔(毫秒)。

You can only set logicalSessionRefreshMillis at startup and cannot change this setting with the setParameter command.您只能在启动时设置logicalSessionRefreshMillis,不能使用setParameter命令更改此设置。

For example, to set the logicalSessionRefreshMillis for a mongod instance to 10 minutes:例如,要将mongod实例的logicalSessionRefreshMillis设置为10分钟:

mongod --setParameter logicalSessionRefreshMillis=600000
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. 未从客户端接收到新读/写操作或使用refreshSessions刷新的会话在此阈值内的会话将从缓存中清除。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.要在副本集和分片群集上设置此参数,必须在每个成员上指定相同的值;否则,会话将无法正常工作。

You can only set localLogicalSessionTimeoutMinutes at startup and cannot change this setting with the setParameter command.您只能在启动时设置localLogicalSessionTimeoutMinutes,不能使用setParameter命令更改此设置。

For example, to set the localLogicalSessionTimeoutMinutes for a test mongod instance to 20 minutes:例如,要将测试mongod实例的localLogicalSessionTimeoutMinutes设置为20分钟:

mongod --setParameter localLogicalSessionTimeoutMinutes=20
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. 当前集群时间可以提前的最大数量;具体来说,maxAcceptableLogicalClockDriftSecs是集群时间的新值与当前集群时间之间的最大差值。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.如果新群集时间与当前群集时间的差异超过maxAcceptableLogicalClockDriftSecs,则无法将群集时间提前到新值。

You can only set maxAcceptableLogicalClockDriftSecs at startup and cannot change this setting with the setParameter command.您只能在启动时设置maxAcceptableLogicalClockDriftSecs,不能使用setParameter命令更改此设置。

For example, to set the maxAcceptableLogicalClockDriftSecs for a mongod instance to 15 minutes:例如,要将mongod实例的maxAcceptableLogicalClockDriftSecs设置为15分钟:

mongod --setParameter maxAcceptableLogicalClockDriftSecs=900
maxSessions

New in version 4.0.1.在版本4.0.1中新增

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: integer

Default默认值: 1000000

The maximum number of sessions that can be cached.可以缓存的最大会话数。

You can only set maxSessions during start-up.您只能在启动期间设置maxSessions

For example, to set the maxSessions for a mongod instance to 1000:例如,要将mongod实例的maxSessions设置为1000:

mongod --setParameter maxSessions=1000
storeFindAndModifyImagesInSideCollection

New in version 5.1.在版本5.1中新增

Available for both mongod and mongos.mongodmongos均可使用。

Type类型: boolean

Default默认值: true

Determines whether the temporary documents required for retryable findAndModify commands are stored in the side collection (config.image_collection).确定可重试findAndModify命令所需的临时文档是否存储在侧面集合(config.image_collection)中。

If storeFindAndModifyImagesInSideCollection is:如果storeFindAndModifyImagesInSideCollection为:

  • true, the temporary documents are stored in the side collection.true,则临时文档存储在side集合中。
  • false, the temporary documents are stored in the replica set oplog.false,则临时文档存储在副本集oplog中。

Keep storeFindAndModifyImagesInSideCollection set to true if you:如果出现以下情况,请将storeFindAndModifyImagesInSideCollection设置为true

Note注意

Secondaries may experience increased CPU usage when storeFindAndModifyImagesInSideCollection is true.storeFindAndModifyImagesInSideCollectiontrue时,Secondaries可能会增加CPU使用量。

For example, to set storeFindAndModifyImagesInSideCollection to false during startup:例如,要在启动期间将storeFindAndModifyImagesInSideCollection设置为false

mongod --setParameter storeFindAndModifyImagesInSideCollection=false

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, storeFindAndModifyImagesInSideCollection: false } )
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事务记录在符合清理条件之前存在于transactions集合中的最短生存期.

You can only set TransactionRecordMinimumLifetimeMinutes at startup and cannot change this setting with the setParameter command.只能在启动时设置TransactionRecordMinimumLifetimeMinutes,不能使用setParameter命令更改此设置。

For example, to set the TransactionRecordMinimumLifetimeMinutes for a mongod instance to 20 minutes:例如,要将mongod实例的TransactionRecordMinimumLifetimeMinutes设置为20分钟:

mongod --setParameter TransactionRecordMinimumLifetimeMinutes=20
Tip提示
enableFlowControl

New in version 4.2.在版本4.2中新增

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.启用或禁用控制主要应用其写入的速率的机制,以将次要成员的多数提交延迟保持在可配置的最大值以下。

Note注意

For flow control to engage, the replica set/sharded cluster must have: featureCompatibilityVersion (FCV) of 4.2 and read concern majority enabled. 要启用流控制,副本集/分片集群必须具有:featureCompatibilityVersion(FCV)为4.2,并启用读取关注多数。That is, enabled flow control has no effect if FCV is not 4.2 or if read concern majority is disabled.也就是说,如果FCV不是4.2,或者如果禁用了大多数读取问题,则启用的流量控制无效。

flowControlTargetLagSeconds

New in version 4.2.在版本4.2中新增

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.指定的值必须大于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.通常,默认设置应足够;然而,如果从默认值进行修改,减少而不是增加,该值可能会更有用。

flowControlWarnThresholdSeconds

New in version 4.2.在版本4.2中新增

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.指定的值必须大于或等于0,如果为0,则禁用警告。

initialSyncTransientErrorRetryPeriodSeconds

New in version 4.4.在版本4.4中新增

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.默认值相当于24小时。

initialSyncSourceReadPreference

New in version 4.4.在版本4.4中新增

Type类型: String

Available for mongod only.仅适用于mongod

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.如果副本集已禁用chaining,则默认的initialSyncSourceReadPreference读取首选项模式为primary

You cannot specify a tag set or maxStalenessSeconds to initialSyncSourceReadPreference.不能将标记集或maxStalenesSeconds指定为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. 如果mongod无法根据指定的读取首选项找到同步源,它将记录错误并重新启动初始同步进程。The mongod exits with an error if it cannot complete the initial sync process after 10 attempts. 如果mongod10次尝试后无法完成初始同步过程,则会退出并返回错误。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. 选择初始同步源时,优先于复制集的settings.chainingAllowed设置。After a replica set member successfully completes initial sync, it defers to the value of chainingAllowed when selecting a replication sync source.在副本集成员成功完成初始同步后,在选择复制同步源时,它会遵循chainingAllowed的值。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

initialSyncMethod

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

Available for mongod only.仅适用于mongod

Type类型: String

Default默认值: logical

Method used for initial sync.用于初始同步的方法。

Set to logical to use logical initial sync. 设置为logical以使用逻辑初始同步Set to fileCopyBased to use file copy based initial sync.设置为fileCopyBased以使用基于文件副本的初始同步

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

Note注意

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

maxNumSyncSourceChangesPerHour

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. 每次更新同步源以及每次节点获取一批oplog条目时,都会评估同步源。If there are more than maxNumSyncSourceChangesPerHour source changes in an hour, the node temporarily stops re-evaluating that sync source. 如果一小时内更改的源超过maxNumSyncSourceChangesPerHour,则节点会暂时停止重新评估该同步源。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.类似地,如果主节点更改并禁用链接,则节点将更新为从新的主节点同步。

oplogFetcherUsesExhaust

New in version 4.4.在版本4.4中新增

Available for mongod only.仅适用于mongod

Type类型: boolean

Default默认值: true

Enables or disables streaming replication. 启用或禁用流复制Set the value to true to enable streaming replication.将该值设置为true以启用流复制。

Set the value to false to disable streaming replication. 将该值设置为false以禁用流复制。If disabled, secondaries fetch batches of oplog entries by issuing a request to their sync from source and waiting for a response. 如果被禁用,辅助设备将通过从源发出同步请求并等待响应来获取一批oplog条目。This requires a network roundtrip for each batch of oplog entries.这需要对每批oplog条目进行网络往返。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

oplogInitialFindMaxSeconds

Type类型: integer

Default默认值: 60

Available for mongod only.仅适用于mongod

Maximum time in seconds for a member of a replica set to wait for the find command to finish during data synchronization.数据同步期间,副本集成员等待find命令完成的最长时间(秒)。

replWriterThreadCount

Type类型: integer

Default默认值: 16

Available for mongod only.仅适用于mongod

Maximum number of threads to use to apply replicated operations in parallel. 用于并行应用复制操作的最大线程数。Values can range from 1 to 256 inclusive. 值的范围可以从1到256(含)。You can only set replWriterThreadCount at startup and cannot change this setting with the setParameter command.只能在启动时设置replWriterThreadCount,不能使用setParameter命令更改此设置。

Tip提示
See also: 参阅:
replWriterMinThreadCount

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

Type类型: integer

Default默认值: 0

Available for mongod only.仅适用于mongod

Minimum number of threads to use to apply replicated operations in parallel. 用于并行应用复制操作的最小线程数。Values can range from 0 to 256 inclusive. 值的范围为0到256(包括0和256)。You can only set replWriterMinThreadCount at startup and cannot change this setting with the setParameter command.只能在启动时设置replWriterMinThreadCount,不能使用setParameter命令更改此设置。

Parallel application of replication operations uses up to replWriterThreadCount threads. 复制操作的并行应用程序最多使用replWriterThreadCount个线程。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.如果使用小于replWriterThreadCount的值配置replWriterMinThreadCount,则线程池将使空闲线程超时,直到线程池中的线程总数等于replWriterMinThreadCount

replWriterMinThreadCount must be configured with a value that is less than or equal to replWriterThreadCount.必须配置一个小于或等于replWriterThreadCount的值。

rollbackTimeLimitSecs

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.可以回滚的数据的最长保留时间。此参数的负值无效。

Starting in MongoDB 4.2+ and 4.0.13+, 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.从MongoDB 4.2+和4.0.13+开始,如果要回滚实例的oplog结束到公共点(源节点和要回滚节点具有相同数据的最后一点)之后的第一次操作之间的时间超过此值,回滚将失败。

In MongoDB 4.0.0-4.0.12, if the time between the end of the to-be-rolledback instance's oplog and 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.在MongoDB 4.0.0-4.0.12中,如果待回滚实例的oplog结束与公共点(源节点和待回滚节点具有相同数据的最后一点)之间的时间超过此值,回滚将失败。

To effectively have an unlimited rollback period, set the value to 2147483647 which is the maximum value allowed and equivalent to roughly 68 years.要有效地拥有无限回滚期,请将该值设置为2147483647,这是允许的最大值,大约相当于68年。

New in version 4.0.在版本4.0中新增

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. 如果~大于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.经过waitForSecondaryBeforeNoopWriteMS后,如果afterClusterTime仍然大于上次应用的时间,则辅助服务器将进行无操作写入,以提前上次应用时间。

The following example sets the waitForSecondaryBeforeNoopWriteMS to 20 milliseconds:以下示例将waitForSecondaryBeforeNoopWriteMS设置为20毫秒:

mongod --setParameter waitForSecondaryBeforeNoopWriteMS=20

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

Available for mongod only.仅适用于mongod

Type类型: boolean

Default默认值: true

New in version 4.0.在版本4.0中新增

Flag that determines whether MongoDB creates rollback files that contains documents affected during a rollback.用于确定MongoDB是否创建包含回滚期间受影响文档的回滚文件的标志。

By default, createRollbackDataFiles is true and MongoDB creates the rollback files.默认情况下,createRollbackDataFilestrue,MongoDB创建回滚文件。

The following example sets createRollbackDataFiles to false so that the rollback files are not created:以下示例将createRollbackDataFiles设置为false,以便不创建回滚文件:

mongod --setParameter createRollbackDataFiles=false

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

For more information, see Collect Rollback Data.有关详细信息,请参阅集合回滚数据

enableElectionHandoff

New in version 4.0.2.在版本4.0.2中新增

Type类型: boolean

Default默认值: true

A flag that can reduce the downtime after the primary steps down from either the rs.stepDown() method or the replSetStepDown command.一个标志,可以减少从rs.stepDown()方法或replSetStepDown命令执行主步骤后的停机时间。

If the flag is true, when a primary steps down after rs.stepDown() (or the replSetStepDown command without the force: true), the primary nominates an eligible secondary to call an election immediately.如果该标志为true,则当一名主要候选人在rs.stepDown()之后下台(或不使用force:truereplSetStepDown命令)时,主要候选人提名一名合格的次要候选人立即进行选举。

If the flag is false, after the step down, secondaries can wait up to settings.electionTimeoutMillis before calling an election.如果标志为假,则在下台后,secondaries可以等待设置settings.electionTimeoutMillis,然后再进行选举。

An eligible secondary must be caught up with the stepped down primary and have priority greater than 0. 符合条件的次要成员必须赶上已卸任的主要成员,并且priority大于0。If multiple secondary members meet this criteria, the stepped down primary selects the eligible secondary with the highest priority. 如果多个次要成员符合此条件,则卸任的次要成员将选择具有最高priority的合格次要成员。If the more than one eligible secondary members have the same priority, the stepped down primary selects the secondary with the lowest _id. 如果多个合格的次要成员具有相同的priority,则逐步降级的主要成员将选择具有最低_id的次要成员。The stepped down primary does not wait for the effects of the handoff.逐步下降的主节点不等待切换的影响。

The parameter has no impact if the primary steps down for reasons other than rs.stepDown() (or the replSetStepDown command without the force: true).如果主程序因rs.stepDown()以外的原因(或没有force: truereplSetStepDown命令)而退出,则该参数没有影响。

replBatchLimitBytes

Default默认值: 104857600 (100MB)

Sets the maximum oplog application batch size in bytes.设置oplog应用程序的最大批大小(字节)。

Values can range from 16777216 (16MB) to 104857600 (100MB) inclusive.值的范围为16777216(16MB)到104857600(100MB)(含)。

The following example sets replBatchLimitBytes to 64 MB so that the rollback files are not created:以下示例将replBatchLimitBytes设置为64 MB,以便不创建回滚文件:

mongod --setParameter replBatchLimitBytes=67108864

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

New in version 4.0.10.在版本4.0.10中新增

mirrorReads

Available for mongod only.仅适用于mongod

New in version 4.4.在版本4.4中新增/p>

Type类型: Document

Default默认值: { samplingRate: 0.01, maxTimeMS: 1000 }

Specifies the settings for mirrored reads for the mongod instance. 指定mongod实例的镜像读取设置。The settings only take effect when the member is a primary.这些设置仅在成员是主成员时生效。

The parameter mirrorReads takes a JSON document with the following fields:参数mirrorReads采用具有以下字段的JSON文档:

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. 用于镜像操作子集的采样率,该操作支持镜像到可选择(具体地说,优先级大于0)的次映像的子集。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.主节点以指定的速率随机采样每个可选择的次节点,以发送镜像读取。介于0.01.0之间的数字(不包括)主节点以指定的速率随机采样每个可选择的次节点,以发送镜像读取。

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. 例如,如果一个副本集有一个主副本和两个可选择的次副本,并且采样率为0.10,则主镜像以10%的采样率读取每个可选择的辅助副本,这样一个读取可以镜像到一个辅助副本,而不是镜像到另一个,或者镜像到两个或两者都不镜像。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.也就是说,如果主节点接收到100个可以镜像的操作,0.10的采样率可能会导致8个读取被镜像到一个辅助节点,13个读取被映射到另一个节点,或者每个读取10个,以此类推。

The default value is 0.01.默认值为0.01

maxTimeMS

The maximum time in milliseconds for the mirrored reads. 镜像读取的最大时间(毫秒)。The default value is 1000.默认值为1000

The maxTimeMS for the mirrored reads is separate from the maxTimeMS of the original read being mirrored.镜像读取的maxTimeMS与要镜像的原始读取的maxTimeMS是分开的。

You can set mirrorReads during startup in the configuration file or with the --setParameter option on the command line. 您可以在启动期间在配置文件中或使用命令行上的configuration file选项设置mirrorReadsIf specifying from the configuration file or on the command line, enclose themirrorReads document in quotes.如果从配置文件或命令行中指定,请用引号将mirrorReads文档括起来。

For example, the following sets the mirror reads sampling rate to 0.10 from the command line:例如,以下命令从命令行将镜像读取采样率设置为0.10

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:或者,如果在连接到正在运行的mongodmongosh会话中使用setParameter命令,请不要将文档括在引号中:

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

Sharding Parameters分片参数

Note注意

Starting in version 4.2, MongoDB removes the parameter AsyncRequestsSenderUseBaton and always enables the performance enhancement controlled by the parameter.从4.2版开始,MongoDB删除参数AsyncRequestsSenderUseBaton,并始终启用由该参数控制的性能增强。

chunkDefragmentationThrottlingMS

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

Type类型: integer

Default默认值: 0

Available for both mongod and mongos.mongodmongos均可使用。

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.限制拆分和合并命令的速率。

The following example sets chunkDefragmentationThrottlingMS to 10 milliseconds:以下示例将chunkDefragmentationThrottlingMS设置为10毫秒:

mongod --setParameter chunkDefragmentationThrottlingMS=10

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

New in version 4.4.在版本4.4中新增

Type类型: boolean

Default默认值: false

Available for mongod only.仅适用于mongod

If set on a shard's primary, specifies if range deletion is paused on the shard. 如果在分片的主分片上设置,则指定是否在分片上暂停范围删除。If set to true, cleanup of chunk`ranges containing :term:`orphaned documents is paused. 如果设置为true,则将暂停清理chunk`ranges containing :term:`orphaned documentsThe shard can continue to donate chunks to other shards, but the donated documents will not be removed from this shard until you set this parameter to false. 分片可以继续将块捐赠给其他分片,但在将此参数设置为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.该分片可以继续从其他分片接收块,只要它在config.rangeDeletions集合中没有与传入块的范围重叠的挂起范围删除任务。

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.disableResumableRangeDeletertrue时,如果接收方分片的主分片上存在孤立文档,且该文档与传入块的范围相同,则块迁移失败。

The parameter has no effect on the mongod if it is not the shard's primary.如果该参数不是分片的主参数,则该参数对mongod没有影响。

Important重要

If you set disableResumableRangeDeleter parameter to true, ensure that you apply it consistently for all members in the shard's replica set. 如果将disableResumableRangeDeleter参数设置为true,请确保将其一致地应用于分片副本集中的所有成员。In the event of a failover, this setting's value on the new primary dictates the behavior of the range deleter.在发生故障转移时,新主服务器上的此设置值决定范围删除程序的行为。

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

mongod --setParameter disableResumableRangeDeleter=false
enableShardedIndexConsistencyCheck

New in version 4.4 (and 4.2.6).4.4版(和4.2.6版)新增。

Type类型: boolean

Default默认值: true

Available for mongod only.仅适用于mongod

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.如果mongod不是配置服务器的主参数,则该参数对mongod没有影响。

The following example sets enableShardedIndexConsistencyCheck to false for a config server primary:以下示例将配置服务器主服务器的enableShardedIndexConsistencyCheck设置为false

mongod --setParameter enableShardedIndexConsistencyCheck=false

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, enableShardedIndexConsistencyCheck: false } )
Tip提示
See also: 参阅:
shardedIndexConsistencyCheckIntervalMS

New in version 4.4 (and 4.2.6).4.4版(和4.2.6版)新增。

Type类型: integer

Default默认值: 600000

Available for mongod only.仅适用于mongod

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.如果mongod不是配置服务器的主参数,则该参数对mongod没有影响。

You can only set the parameter during startup, and cannot change this setting using the setParameter database command.只能在启动期间设置参数,不能使用setParameter数据库命令更改此设置。

For example, the following sets the interval at 300000 milliseconds (5 minutes) at startup:例如,以下内容将启动时的间隔设置为300000毫秒(5分钟):

mongod --setParameter shardedIndexConsistencyCheckIntervalMS=300000
Tip提示
See also: 参阅:
enableFinerGrainedCatalogCacheRefresh

New in version 4.4.在版本4.4中新增

Type类型: boolean

Default默认值: true

Available for both mongod and mongos.mongodmongos均可使用。

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.如果禁用,任何过时的块将导致集合的整个块分布被视为过时,并强制所有与分片联系的路由器刷新其分片目录缓存。

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

mongod --setParameter enableFinerGrainedCatalogCacheRefresh=true
mongos --setParameter enableFinerGrainedCatalogCacheRefresh=true
Tip提示
maxTimeMSForHedgedReads

New in version 4.4.在版本4.4中新增

Type类型: integer

Default默认值: 150

Available for mongos only.仅适用于mongos

Specifies the maximimum time limit (in milliseconds) for the hedged read. 指定对冲读取的最大时间限制(毫秒)。That is, the additional read sent to hedge the read operation uses the maxTimeMS value of maxTimeMSForHedgedReads while the read operation that is being hedged uses the maxTimeMS value specified for the operation.也就是说,发送给对冲读取操作的附加读取使用maxTimeMSForHedgedReadsmaxTimeMS值,而对冲的读取操作使用为操作指定的maxTimeMS值。

For example, to set the limit to 200 milliseconds, you can issue the following during startup:例如,要将限制设置为200毫秒,可以在启动期间发出以下命令:

mongos --setParameter maxTimeMSForHedgedReads=200

Or if using the setParameter command in a mongosh session that is connected to a running mongos:或者,如果在连接到正在运行的mongosmongosh会话中使用setParameter命令:

db.adminCommand( { setParameter: 1, maxTimeMSForHedgedReads: 200 } )
Tip提示
maxCatchUpPercentageBeforeBlockingWrites

New in version 5.0.在版本5.0中新增 (Also available starting in 4.4.7, 4.2.15, 4.0.26)

Type类型: integer

Default默认值: 10

Available for mongod only.仅适用于mongod

For moveChunk 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.对于moveChunk操作,指定迁移协议允许从catchup阶段转换到commit阶段的未传输数据的最大百分比(以总块大小的百分比表示)。

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.设置更高的追赶百分比可以减少迁移完成所需的时间,但代价是在并发upsertdelete操作期间增加延迟。

For example, to set the maximum percentage to 20, you can issue the followingduring startup:例如,要将最大百分比设置为20,可以在启动期间发出以下命令:

mongod --setParameter maxCatchUpPercentageBeforeBlockingWrites=20

You cannot change maxCatchUpPercentageBeforeBlockingWrites during runtime.无法在运行时更改maxCatchUpPercentageBeforeBlockingWrites

Tip提示
metadataRefreshInTransactionMaxWaitBehindCritSecMS

New in version 5.2.在版本5.2中新增 (Also available starting in 5.1.0, 5.0.4也可从5.1.0、5.0.4开始提供)

Type类型: integer

Default默认值: 500

Available for mongod only.仅适用于mongod

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. 当查询访问分片时,块迁移DDL操作可能已经保存了集合的关键部分。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. 如果查询发现关键部分被占用,则分片将等待直到关键部分被释放。当shard将控制权返回给mongos时,mongos会重试查询。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 the value of metadataRefreshInTransactionMaxWaitBehindCritSecMS.要减少事务中关键部分的最大等待时间,请降低metadataRefreshInTransactionMaxWaitBehindCritSecMS的值。

Warning警告

If metadataRefreshInTransactionMaxWaitBehindCritSecMS is too low, mongos could use all of its retry attempts and return an error.如果metadataRefreshInTransactionMaxWaitBehindCritSecMS太低,mongos可能会使用其所有重试尝试并返回错误。

You can set metadataRefreshInTransactionMaxWaitBehindCritSecMS at startup and during runtime.您可以在启动时和运行时设置metadataRefreshInTransactionMaxWaitBehindCritSecMS

For example, to set metadataRefreshInTransactionMaxWaitBehindCritSecMS to 400 milliseconds:例如,要将metadataRefreshInTransactionMaxWaitBehindCritSecMS设置为400毫秒:

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

New in version 4.4.在版本4.4中新增

Type类型: string

Default默认值: on

Available for mongos only.仅适用于mongos

Specifies whether mongos supports hedged reads for those read operations whose read preference have enabled the hedged read option.指定mongos是否支持那些读取首选项已启用对冲读取选项的读取操作的对冲读取。

Available values are:可用值包括:

ValueDescription描述
onThe mongos instance supports hedged reads for read operations whose read preference have enabled the hedged read option.mongos实例支持对其读取首选项启用了对冲读取选项的读取操作进行对冲读取。
offThe mongos instance does not support hedged reads. mongos实例不支持对冲读取。That is, hedged reads are unavailable, even for read operations whose read preference have enabled the hedged read option.也就是说,对冲读取不可用,即使对于其读取首选项已启用对冲读取选项的读取操作也是如此。

For example, to turn off hedged read support for a mongos instance, you can issue the following during startup:例如,要关闭mongos实例的对冲读取支持,可以在启动期间发出以下命令:

mongos --setParameter readHedgingMode=off

Or if using the setParameter command in a mongosh session that is connected to a running mongos:或者,如果在连接到正在运行的mongosmongosh会话中使用setParameter命令:

db.adminCommand( { setParameter: 1, readHedgingMode: "off" } )
Tip提示
shutdownTimeoutMillisForSignaledShutdown

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

Type类型: integer

Default默认值: 15000

Available for mongod only.仅适用于mongod

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.指定在响应SIGTERM信号启动mongod关闭之前等待任何正在进行的数据库操作完成的时间(毫秒)。

For example, to set the time to 250 milliseconds, you can issue the following during startup:例如,要将时间设置为250毫秒,可以在启动期间发出以下命令:

mongod --setParameter shutdownTimeoutMillisForSignaledShutdown=250

Or if using the setParameter command in a mongosh session that is connected to a running mongod:或者,如果在连接到正在运行的mongodmongosh会话中使用setParameter命令:

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

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

Type类型: integer

Default默认值: 15000

Available for mongos only.仅适用于mongos

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.指定在响应SIGTERM信号启动mongos关闭之前等待任何正在进行的数据库操作完成的时间(毫秒)。

For example, to set the time to 250 milliseconds, you can issue the following during startup:例如,要将时间设置为250毫秒,可以在启动期间发出以下命令:

mongos --setParameter mongosShutdownTimeoutMillisForSignaledShutdown=250

Or if using the setParameter command in a mongosh session that is connected to a running mongos:或者,如果在连接到正在运行的mongosmongosh会话中使用setParameter命令:

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

Available in MongoDB 3.2 only仅在MongoDB 3.2中可用

Type: integer

Default: 30

The number of times the mongod or mongos instance tries to reach the replica sets in the sharded cluster (for example, shard replica sets, config server replica set) to monitor the replica set status and topology.mongodmongos实例尝试访问分片集群中的副本集(例如,分片副本集、配置服务器副本集)以监视副本集状态和拓扑的次数。

When the number of consecutive unsuccessful attempts exceeds this parameter value, the mongod or mongos instance denotes the monitored replica set as unavailable. 当连续失败的尝试次数超过此参数值时,mongodmongos实例表示受监视的副本集不可用。If the monitored replica set is the config server replica set:如果受监视的副本集是配置服务器副本集:

timeOutMonitoringReplicaSets

Available in MongoDB 3.2.10 and later 3.2-series only仅在MongoDB 3.2.10和更高版本的3.2系列中提供

Type: integer

Default: false

The flag that determines whether the mongod or mongos instance should stop its attempt to reach the monitored replica set after unsuccessfully trying replMonitorMaxFailedChecks number of times.用于确定mongodmongos实例在尝试replMonitorMaxFailedChecks失败后是否应停止尝试访问受监视的副本集的标志。

If the monitored replica set is the config server replica set and timeOutMonitoringReplicaSets is set to true, you must restart mongod or mongos if the mongod or mongos instance cannot reach any of the config servers for the specified number of times. 如果被监视的副本集是配置服务器副本集,并且timeOutMonitoringReplicaSets设置为true,那么如果mongodmongos实例在指定次数内无法访问任何配置服务器,则必须重新启动mongodmongosSee the v3.2 troubleshooting guide for more details.有关详细信息,请参阅v3.2故障排除指南

ShardingTaskExecutorPoolHostTimeoutMS

Type: integer

Default: 300000 (5 minutes)

Available for both mongod and mongos.mongodmongos均可使用。

Maximum time that mongos goes without communication to a host before mongos drops all connections to the host.mongos断开与主机的所有连接之前,mongos不与主机通信的最长时间。

If set, ShardingTaskExecutorPoolHostTimeoutMS should be greater than the sum of ShardingTaskExecutorPoolRefreshRequirementMS and ShardingTaskExecutorPoolRefreshTimeoutMS. 如果设置,ShardingTaskExecutorPoolHostTimeoutMS应大于ShardingTaskExecutorPoolRefreshRequirementMSShardingTaskExecutorPoolRefreshTimeoutMS之和。Otherwise, mongos adjusts the value of ShardingTaskExecutorPoolHostTimeoutMS to be greater than the sum.否则,mongosShardingTaskExecutorPoolHostTimeoutMS的值调整为大于总和。

The following example sets ShardingTaskExecutorPoolHostTimeoutMS to 120000 during startup:以下示例在启动期间将ShardingTaskExecutorPoolHostTimeoutMS设置为120000

mongos --setParameter ShardingTaskExecutorPoolHostTimeoutMS=120000

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolHostTimeoutMS: 120000 } )
ShardingTaskExecutorPoolMaxConnecting

Type: integer

Default: 2

Available for both mongod and mongos.mongodmongos均可使用。

Maximum number of simultaneous initiating connections (including pending connections in setup/refresh state) each TaskExecutor connection pool can have to a mongod instance. 每个TaskExecutor连接池可以同时启动mongod实例的最大连接数(包括处于设置/刷新状态的挂起连接)。You can set this parameter to control the rate at which mongos adds connections to a mongod instance.您可以设置此参数来控制mongosmongod实例添加连接的速率。

If set, ShardingTaskExecutorPoolMaxConnecting should be less than or equal to ShardingTaskExecutorPoolMaxSize. 如果已设置,ShardingTaskExecutorPoolMaxConnecting应小于或等于ShardingTaskExecutorPoolMaxSizeIf it is greater, mongos ignores the ShardingTaskExecutorPoolMaxConnecting value.如果大于此值,mongos将忽略ShardingTaskExecutorPoolMaxConnecting值。

The following example sets ShardingTaskExecutorPoolMaxConnecting to 20 during startup:以下示例在启动期间将ShardingTaskExecutorPoolMaxConnecting设置为20

mongos --setParameter ShardingTaskExecutorPoolMaxConnecting=20

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

Type: integer

Default: 2 64 - 1

Available for both mongod and mongos.mongodmongos均可使用。

Maximum number of outbound connections each TaskExecutor connection pool can open to any given mongod instance. 每个TaskExecutor连接池可以打开到任何给定mongod实例的最大出站连接数。The maximum possible connections to any given host across all TaskExecutor pools is:所有TaskExecutor池中与任何给定主机的最大可能连接数为:

ShardingTaskExecutorPoolMaxSize * taskExecutorPoolSize

The following example sets ShardingTaskExecutorPoolMaxSize to 20 during startup:以下示例在启动期间将ShardingTaskExecutorPoolMaxSize设置为20

mongos --setParameter ShardingTaskExecutorPoolMaxSize=20

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

mongos can have up to n TaskExecutor connection pools, where n is the number of cores. 最多可以有n个TaskExecutor连接池,其中n是核心数。See taskExecutorPoolSize.请参阅taskExecutorPoolSize

Tip提示
See also: 参阅:
ShardingTaskExecutorPoolMinSize

Type: integer

Default: 1

Available for both mongod and mongos.mongodmongos均可使用。

Minimum number of outbound connections each TaskExecutor connection pool can open to any given mongod instance.每个TaskExecutor连接池可以打开到任何给定mongod实例的最小出站连接数。

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.当池处于空闲状态时,池将保持此连接数,直到ShardingTaskExecutorPoolHostTimeoutMS毫秒过去,没有任何应用程序使用该池为止。

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.对于使用warmMinConnectionsInShardingTaskExecutorPoolOnStartup参数的mongosShardingTaskExecutorPoolMinSize参数还控制在mongos实例开始接受传入客户端连接之前,在启动mongos时建立到每个分片主机的连接数。

Note注意

In MongoDB 4.4, the warmMinConnectionsInShardingTaskExecutorPoolOnStartup parameter is enabled by default for the mongos.在MongoDB 4.4中,默认情况下为mongos启用warmMinConnectionsInShardingTaskExecutorPoolOnStartup参数。

The following example sets ShardingTaskExecutorPoolMinSize to 2 during startup:以下示例在启动期间将ShardingTaskExecutorPoolMinSize设置为2

mongos --setParameter ShardingTaskExecutorPoolMinSize=2

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMinSize: 2 } )

mongos can have up to n TaskExecutor connection pools, where n is the number of cores. mongos最多可以有n个TaskExecutor连接池,其中n是核心数。See taskExecutorPoolSize.请参见taskExecutorPoolSize

ShardingTaskExecutorPoolRefreshRequirementMS

Type: integer

Default: 60000 (1 minute)

Available for both mongod and mongos.mongodmongos均可使用。

Maximum time the mongos waits before attempting to heartbeat a resting connection in the pool.mongos在尝试检测池中静止连接之前等待的最长时间。

If set, ShardingTaskExecutorPoolRefreshRequirementMS should be greater than ShardingTaskExecutorPoolRefreshTimeoutMS. 如果设置,ShardingTaskExecutorPoolRefreshRequirementMS应大于ShardingTaskExecutorPoolRefreshTimeoutMSOtherwise, mongos adjusts the value of ShardingTaskExecutorPoolRefreshTimeoutMS to be less than ShardingTaskExecutorPoolRefreshRequirementMS.否则,mongos会将ShardingTaskExecutorPoolRefreshTimeoutMS的值调整为小于ShardingTaskExecutorPoolRefreshRequirementMS

The following example sets ShardingTaskExecutorPoolRefreshRequirementMS to 90000 during startup:以下示例在启动期间将ShardingTaskExecutorPoolRefreshRequirementMS设置为90000

mongos --setParameter ShardingTaskExecutorPoolRefreshRequirementMS=90000

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolRefreshRequirementMS: 90000 } )
ShardingTaskExecutorPoolRefreshTimeoutMS

Type: integer

Default: 20000 (20 seconds)

Available for both mongod and mongos.mongodmongos均可使用。

Maximum time the mongos waits for a heartbeat before timing out the heartbeat.mongos在心跳超时之前等待心跳的最长时间。

If set, ShardingTaskExecutorPoolRefreshTimeoutMS should be less than ShardingTaskExecutorPoolRefreshRequirementMS. 如果设置,ShardingTaskExecutorPoolRefreshTimeoutMS应小于ShardingTaskExecutorPoolRefreshRequirementMSOtherwise, mongos adjusts the value of ShardingTaskExecutorPoolRefreshTimeoutMS to be less than ShardingTaskExecutorPoolRefreshRequirementMS.否则,mongos会将ShardingTaskExecutorPoolRefreshTimeoutMS的值调整为小于ShardingTaskExecutorPoolRefreshRequirementMS

The following example sets ShardingTaskExecutorPoolRefreshTimeoutMS to 30000 during startup:以下示例在启动期间将ShardingTaskExecutorPoolRefreshTimeoutMS设置为30000

mongos --setParameter ShardingTaskExecutorPoolRefreshTimeoutMS=30000

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolRefreshTimeoutMS: 30000 } )
ShardingTaskExecutorPoolReplicaSetMatching

New in version 4.2.在版本4.2中新增

Changed in version 5.0.在版本5.0中更改

(Also starting in 4.4.5 and 4.2.13)

Type: string

Default: "automatic"

Available for both mongod and mongos.mongodmongos均可使用。

On a mongos instance, this parameter sets the policy that determines the minimum size limit of its connection pools to nodes within replica sets.mongos实例上,此参数设置用于确定其连接池到副本集中节点的最小大小限制的策略。

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.mongod实例上,此参数设置用于确定其连接池到其他副本集中节点的最小大小限制的策略。

Note that this parameter only manages connections for operations that are directly related to user requests and CRUD operations.请注意,此参数仅管理与用户请求和CRUD操作直接相关的操作的连接。

Available values are:可用值包括:

Matching PolicyDescription描述
"automatic" (Default)

Starting in 5.0 (and 4.4.5 and 4.2.13), "automatic" is the new default value.从5.0(以及4.4.5和4.2.13)开始,"automatic"是新的默认值。

When set for a mongos, the instance follows the behavior specified for the "matchPrimaryNode" option.mongos设置时,实例遵循为"matchPrimaryNode"选项指定的行为。

When set for a mongod, the instance follows the behavior specified for the "disabled" option.mongod设置时,实例将遵循为"disabled"选项指定的行为。

Note注意

If the ShardingTaskExecutorPoolReplicaSetMatching is set to "automatic", the replicaSetMatchingStrategy still describes the actual policy being used, not "automatic". 如果ShardingTaskExecutorPoolReplicaSetMatching设置为"automatic",则replicaSetMatchingStrategy仍然描述正在使用的实际策略,而不是“自动”。To find the value of the ShardingTaskExecutorPoolReplicaSetMatching, use getParameter which returns the value of the server parameter.要查找ShardingTaskExecutorPoolReplicaSetMatching的值,请使用返回服务器参数值的getParameter

"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.当为mongos设置时,实例连接池到分片集群中副本集的每个辅助服务器(特别是分片副本集和配置服务器)的最小大小限制等于其连接池到该副本集的主服务器的大小。

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.当为mongod设置时,实例连接池到分片集群中另一个副本集(特别是分片副本集和配置服务器)的每个辅助副本的最小大小限制等于其连接池到该副本集的主副本的大小。

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.如果拓扑中的多个分片服务器可能会遇到跨分片操作的快速涌入,请不要在mongod实例上设置此选项。

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.在主节点降级的情况下,matchPrimaryNode确保成为主节点的任何辅助节点都可以处理当前级别的主读取和写入。

"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.当为mongos设置时,分片集群中副本集每个成员(特别是分片副本集和配置服务器)的连接池实例最小大小限制等于该副本集的主成员和每个辅助成员的活动连接计数中的最大值。

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.当为mongod设置时,连接池到分片集群中另一个副本集的每个成员(特别是分片副本集和配置服务器)的实例最小大小限制等于到该副本集的主成员和每个辅助成员的活动连接计数中的最大值。

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.通过"matchBusiestNode"mongos可以维护到每个辅助服务器的足够连接,以处理当前的主和辅助读写级别。池中要维护的连接数随着活动连接数的减少而减少。

"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.当为mongos设置时,实例连接池中实例到分片clusterv中副本集的每个节点(特别是分片副本集和配置服务器)的最小连接数等于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.当为mongod设置时,实例连接池中实例到分片集群中另一个副本集(特别是分片副本集和配置服务器)的每个节点的最小连接数等于ShardingTaskExecutorPoolMinSize

The following example sets the ShardingTaskExecutorPoolReplicaSetMatching to "automatic" during startup:以下示例在启动期间将ShardingTaskExecutorPoolReplicaSetMatching设置为"automatic"

mongod --setParameter ShardingTaskExecutorPoolReplicaSetMatching="automatic"

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1,  ShardingTaskExecutorPoolReplicaSetMatching: "automatic" } )
taskExecutorPoolSize

Changed in version 4.0.在版本4.0中更改

Type: integer

Default: 1

Available for mongos only.仅适用于mongos

The number of Task Executor connection pools to use for a given mongos.用于给定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:如果参数值为0或更小,则Task Executor连接池的数量是核心的数量,但以下情况除外:

  • If the number of cores is less than 4, the number of Task Executor connection pools is 4.如果核心数小于4,则任务执行器连接池数为4。
  • If the number of cores is greater than 64, the number of Task Executor connection pools is 64.如果核心数大于64,则任务执行器连接池数为64。

Starting in MongoDB 4.0, the default value of taskExecutorPoolSize is 1:从MongoDB 4.0开始,taskExecutorPoolSize的默认值为1:

  • In MongoDB 4.0 deployment, you can set taskExecutorPoolSize to 0 and, on Linux, set AsyncRequestsSenderUseBaton to false for the previous behavior.在MongoDB 4.0部署中,您可以将taskExecutorPoolSize设置为0,在Linux上,将AsyncRequestsSenderUseBaton设置为false,以实现先前的行为。
  • In MongoDB 4.2+ deployment, MongoDB removes the AsyncRequestsSenderUseBaton parameter and always enables the performance enhancement controlled by the parameter.在MongoDB 4.2+部署中,MongoDB会删除AsyncRequestsSenderUseBaton参数,并始终启用由该参数控制的性能增强。

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

mongos --setParameter taskExecutorPoolSize=6
loadRoutingTableOnStartup

New in version 4.4.在版本4.4中新增

Type: boolean

Default默认值: true

Available for mongos only.仅适用于mongos

Configures a mongos instance to preload the routing table for a sharded cluster on startup. 配置mongos实例以在启动时为分片集群预加载路由表。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.启用此设置后,mongos在开始接受客户端连接之前,会为每个分片集合缓存集群范围的路由表,作为其启动过程的一部分。

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.如果未启用此设置,mongos将只加载传入客户端连接所需的路由表,并且只加载给定请求的名称空间的特定路由表。

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参数的mongos实例可能会经历更长的启动时间,但启动后会更快地为初始客户端连接提供服务。

loadRoutingTableOnStartup is enabled by default.默认情况下启用。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.您只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

warmMinConnectionsInShardingTaskExecutorPoolOnStartup

New in version 4.4.在版本4.4中新增

Type: boolean

Default默认值: true

Available for mongos only.仅适用于mongos

Configures a mongos instance to prewarm its connection pool on startup. 配置mongos实例以在启动时预热其连接池。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.启用此参数后,mongos会在开始接受客户端连接之前,尝试建立到每个分片服务器的ShardingTaskExecutorPoolMinSize网络连接,作为其启动过程的一部分。

A timeout for this behavior can be configured with the warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS parameter. 可以使用warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS参数配置此行为的超时。If this timeout is reached, the mongos will begin accepting client connections regardless of the size of its connection pool.如果达到此超时,mongos将开始接受客户端连接,而不管其连接池的大小。

A mongos instance with this parameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.启用此参数的mongos实例可能会经历更长的启动时间,但一旦启动,将更快地为初始客户端连接提供服务。

warmMinConnectionsInShardingTaskExecutorPoolOnStartup is enabled by default.默认情况下启用。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS

New in version 4.4.在版本4.4中新增

Type: integer

Default默认值: 2000 (2 seconds)

Available for mongos only.仅适用于mongos

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. 设置当使用warmMinConnectionsInShardingTaskExecutorPoolOnStartup参数时,mongos等待为每个分片主机建立ShardingTaskExecutorPoolMinSize连接的超时阈值(以毫秒为单位)。If this timeout is reached, the mongos will begin accepting client connections regardless of the size of its connection pool.如果达到此超时,mongos将开始接受客户端连接,而不管其连接池的大小。

You can only set this parameter on startup, using either the setParameter configuration file setting or the --setParameter command line option.只能在启动时使用setParameter配置文件设置或--setParameter命令行选项设置此参数。

migrateCloneInsertionBatchDelayMS

New in version 4.0.5.在版本4.0.5中新增 The parameter is also available starting in 3.4.18 and 3.6.10参数也可从3.4.18和3.6.10开始使用

Available for mongod only.仅适用于mongod

Type: Non-negative integer类型:非负整数

Default: 0默认值: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.此等待是对secondaryThrottle的补充。

The default value of 0 indicates no additional wait.默认值0表示无额外等待。

The following sets the migrateCloneInsertionBatchDelayMS to 200 milliseconds:以下内容将migrateCloneInsertionBatchDelayMS设置为200毫秒:

mongod --setParameter migrateCloneInsertionBatchDelayMS=200

The parameter may also be set using the setParameter command:也可以使用setParametersetParameter命令设置参数:

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

New in version 4.0.5.在版本4.0.5中新增 The parameter is also available starting in 3.4.18 and 3.6.10参数也可从3.4.18和3.6.10开始使用

Available for mongod only.仅适用于mongod

Type: Non-negative integer类型:非负整数

Default: 0默认值: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. 默认值0表示每个批次没有最大文档数。However, in practice, this results in batches that contain up to 16 MB of documents.然而,在实践中,这会导致批处理中包含多达16 MB的文档。

The following sets the migrateCloneInsertionBatchSize to 100 documents:以下内容将migrateCloneInsertionBatchSize设置为100个文档:

mongod --setParameter migrateCloneInsertionBatchSize=100

The parameter may also be set using the setParameter command:也可以使用setParameter命令设置参数:

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

Default: 900 (15 minutes)默认值:900(15分钟)

Available for mongod only.仅适用于mongod

Minimum delay before a migrated chunk is deleted from the source shard.从源分片中删除迁移的之前的最小延迟。

Before deleting the chunk during chunk migration, MongoDB waits for orphanCleanupDelaySecs or for in-progress queries involving the chunk to complete on the shard primary, whichever is longer.在块迁移期间删除块之前,MongoDB会等待orphanCleanupDelaySecs或正在进行的涉及块的查询在主分片上完成,以时间较长的为准。

However, because the shard primary has no knowledge of in-progress queries run on the shard secondaries, queries that use the chunk but are run on secondaries may see documents disappear if these queries take longer than the time to complete the shard primary queries and the orphanCleanupDelaySecs.但是,由于分片主节点不知道在分片次节点上运行的正在进行的查询,如果这些查询花费的时间超过完成分片主节点查询和orphanCleanupDelaySecs的时间,则使用区块但在次节点上运行的查询可能会看到文档消失。

Note注意

This behavior only affects in-progress queries that start before the chunk migration. 此行为仅影响在块迁移之前开始的进行中查询。Queries that start after the chunk migration starts will not use the migrating chunk.块迁移开始后开始的查询将不会使用迁移的块。

If a shard has storage constraints, consider reducing this value temporarily. 如果分片有存储限制,请考虑暂时减小此值。If running queries that exceed 15 minutes on shard secondaries, consider increasing this value.如果在分片辅助设备上运行超过15分钟的查询,请考虑增加此值。

The following sets the orphanCleanupDelaySecs to 20 minutes:以下内容将orphanCleanupDelaySecs设置为20分钟:

mongod --setParameter orphanCleanupDelaySecs=1200

This may also be set using the setParameter command:也可以使用setParameter命令进行设置:

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

New in version 4.0.1.在版本4.0.1中新增 The parameter is also available starting in 3.4.17 and 3.6.7.从3.4.17和3.6.7开始,该参数也可用。

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 chunk migration (or the cleanupOrphaned command).块迁移的清理阶段(或cleanupOrphaned命令),下一批删除之前等待的时间(毫秒)。

In MongoDB 3.4, consider whether _secondaryThrottle is set before modifying the rangeDeleterBatchDelayMS. 在MongoDB 3.4中,在修改rangeDeleterBatchDelayMS之前,请考虑是否设置了_secondaryThrottleIn MongoDB 3.4, the _secondaryThrottle replication delay occurs after each document deletion instead of after the batch deletion.在MongoDB 3.4中,_secondaryThrottle复制延迟发生在每次文档删除之后,而不是在批量删除之后。

In MongoDB 3.6+, the _secondaryThrottle replication delay occurs after each batch deletion.在MongoDB 3.6+中,_secondaryThrottle复制延迟发生在每次批量删除之后。

The following sets the rangeDeleterBatchDelayMS to 200 milliseconds:以下内容将rangeDeleterBatchDelayMS设置为200毫秒:

mongod --setParameter rangeDeleterBatchDelayMS=200

The parameter may also be set using the setParameter command:也可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, rangeDeleterBatchDelayMS: 200 } )
rangeDeleterBatchSize

New in version 4.0.5.在版本4.0.5中新增

Available for mongod only.仅适用于mongod

Type: Non-negative integer

Default: 2147483647 starting in MongoDB 5.1.2, 5.0.6, and 4.4.12 (128 in earlier MongoDB versions)默认值:从MongoDB 5.1.2、5.0.6和4.4.12开始的2147483647(早期MongoDB版本中为128)

The maximum number of documents in each batch to delete during the cleanup stage of chunk migration(or the cleanupOrphaned command).区块迁移的清理阶段(或cleanupOrphaned命令),每个批次中要删除的最大文档数。

A value of 0 indicates that the system chooses the default value.值为0表示系统选择默认值。

The following example sets rangeDeleterBatchSize to 32 documents:以下示例将rangeDeleterBatchSize设置为32个文档:

mongod --setParameter rangeDeleterBatchSize=32

The parameter may also be set using the setParameter command:也可以使用setParameter命令设置参数:

db.adminCommand( { setParameter: 1, rangeDeleterBatchSize: 32 } )
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. 如果为true,则允许将分片成员或配置服务器成员作为维护操作的单机启动。This parameter is mutually exclusive with the --configsvr or --shardsvr options.此参数与--configsvr--shardsvr选项互斥。

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

mongod --setParameter skipShardingConfigurationChecks=true
Important重要

Once maintenance has completed, remove the skipShardingConfigurationChecks parameter when restarting the mongod.维护完成后,在重新启动mongod时删除skipShardingConfigurationChecks参数。

The parameter is also available for MongoDB versions:该参数也适用于MongoDB版本:

  • MongoDB 3.2.19+
  • MongoDB 3.4.11+
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.chunks上查找操作的超时(毫秒)。

If there is a large number of chunks in the cluster and chunk loading fails with the error ExceededTimeLimit, increase the parameter value:如果集群中有大量块,并且块加载失败并出现ExceededTimeLimit错误,请增加参数值:

mongod --setParameter findChunksOnConfigTimeoutMS=1000000

Storage Parameters存储参数

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. 如果honorSystemUmask设置为true,则MongoDB创建的新文件具有与用户的umask设置一致的权限。You cannot set processUmask if honorSystemUmask is set to true.如果honorSystemUmask设置为true,则无法设置processUmask

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. 如果honorSystemUmask设置为false,则MongoDB创建的新文件的权限设置为600,这将仅授予所有者读写权限。New directories have permissions set to 700. 新目录的权限设置为700You can use processUmask to override the default permissions for groups and other users on all new files created by MongoDB.您可以使用processUmask覆盖组和其他用户对MongoDB创建的所有新文件的默认权限。

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

mongod --setParameter honorSystemUmask=true
Note注意

honorSystemUmask is not available on Windows systems.在Windows系统上不可用。

journalCommitInterval

Available for mongod only.仅适用于mongod

Specify an integer between 1 and 500 signifying the number of milliseconds (ms) between journal commits.指定一个介于1500之间的整数,表示日志提交之间的毫秒数(ms)。

Consider the following example which sets the journalCommitInterval to 200 ms:考虑以下将journalCommitInterval设置为200ms的示例:

db.adminCommand( { setParameter: 1, journalCommitInterval: 200 } )
Tip提示
minSnapshotHistoryWindowInSeconds

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

Default默认值: 300

Available for mongod only.仅适用于mongod

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.如果使用读取关注点"snapshot"查询数据,并指定比指定的minSnapshotHistoryWindowInSeconds早的atClusterTime值,mongod将返回SnapshotTooOld错误。

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

Consider the following example which sets the minSnapshotHistoryWindowInSeconds to 600 seconds:考虑以下将minSnapshotHistoryWindowInSeconds设置为600秒的示例:

db.adminCommand( { setParameter: 1, minSnapshotHistoryWindowInSeconds: 600 } )
Note注意

Increasing the value of minSnapshotHistoryWindowInSeconds increases disk usage. 增加minSnapshotHistoryWindowInSeconds的值会增加磁盘使用量。For more information, see Snapshot History Retention.有关详细信息,请参阅快照历史记录保留

To modify this value for a MongoDB Atlas cluster, you must contact Atlas Support.要修改MongoDB Atlas集群的此值,您必须联系Atlas支持部门

processUmask

New in version 4.4.在版本4.4中新增

Available for mongod only.仅适用于mongod

Overrides the default permissions used for groups and other users when honorSystemUmask is set to false. honorSystemUmask设置为false时,覆盖用于组和其他用户的默认权限。By default, when honorSystemUmask is set to false, new files created by MongoDB have permissions set to 600. 默认情况下,当honorSystemUmask设置为false时,MongoDB创建的新文件的权限设置为600。Use the processUmask parameter to override this default with a custom umask value. 使用processUmask参数用自定义umask值覆盖此默认值。The file owner inherits permissions from the system umask.文件所有者从系统umask继承权限。

You cannot set this parameter if honorSystemUmask is set to true. 如果honorSystemUmask设置为true,则无法设置此参数。You can only set this parameter during start-up and cannot change this setting using the setParameter database command.您只能在启动期间设置此参数,不能使用 setParameter数据库命令更改此设置。

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:考虑以下示例,该示例将组和其他用户的权限设置为只读/写,并保留所有者的系统umask设置:

mongod --setParameter processUmask=011
Note注意

processUmask is not available on Windows systems.在Windows系统上不可用。

syncdelay

Available for mongod only.仅适用于mongod

Specify the interval in seconds between fsync operations where mongod flushes its working memory to disk. 指定mongod将其工作内存刷新到磁盘的fsync操作之间的间隔(秒)。By default, mongod flushes memory to disk every 60 seconds. 默认情况下,mongod每60秒将内存刷新一次磁盘。In almost every situation you should not set this value and use the default setting.在几乎所有情况下,您都不应该设置此值并使用默认设置。

Consider the following example which sets the syncdelay to 60 seconds:考虑以下将syncdelay设置为60秒的示例:

db.adminCommand( { setParameter: 1, syncdelay: 60 } )
Tip提示

WiredTiger Parameters参数

wiredTigerMaxCacheOverflowSizeGB
Note注意
Deprecated in MongoDB 4.4MongoDB 4.4中已弃用

MongoDB deprecates the wiredTigerMaxCacheOverflowSizeGB parameter. MongoDB不推荐使用wiredTigerMaxCacheOverflowSizeGB参数。The parameter has no effect starting in MongoDB 4.4.该参数在MongoDB 4.4中启动时无效。

Default默认值: 0 (No specified maximum):0(未指定最大值)

Available for mongod only.仅适用于mongod

Specify the maximum size (in GB) for the "lookaside (or cache overflow) table" file WiredTigerLAS.wt for MongoDB 4.2.1-4.2.x and 4.0.12-4.0.x. 指定MongoDB 4.2.1-4.2x和4.0.12-4.0x的“lookaside(或缓存溢出)表”文件WiredTigerLAS.wt的最大大小(以GB为单位)。The file no longer exists starting in version 4.4.从4.4版开始,该文件不再存在。

The parameter can accept the following values:该参数可以接受以下值:

ValueDescription描述
0The default value. 默认值。If set to 0, the file size is unbounded.如果设置为0,则文件大小不受限制。
number >= 0.1The maximum size (in GB). 最大大小(GB)。If the WiredTigerLAS.wt file exceeds this size, mongod exits with a fatal assertion. 如果WiredTigerLAS.wt文件超过此大小,mongod将退出,并发出致命的断言。You can clear the WiredTigerLAS.wt file and restart mongod.您可以清除WiredTigerLAS.wt文件并重新启动mongod

You can only set this parameter during runtime using the setParameter database command:只能在运行时使用setParameter数据库命令设置此参数:

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

To set the maximum size during start up, use the storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB instead.要在启动期间设置最大大小,请改用storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB

Available starting in MongoDB 4.2.1 (and 4.0.12)从MongoDB 4.2.1(和4.0.12)开始可用

wiredTigerConcurrentReadTransactions

Available for mongod only.仅适用于mongod

Available for the WiredTiger storage engine only.仅适用于WiredTiger存储引擎。

Specify the maximum number of concurrent read transactions allowed into the WiredTiger storage engine.指定允许进入WiredTiger存储引擎的最大并发读取事务数。

db.adminCommand( { setParameter: 1, wiredTigerConcurrentReadTransactions: <num> } )
Tip提示
wiredTigerConcurrentWriteTransactions

Available for mongod only.仅适用于mongod

Available for the WiredTiger storage engine only.仅适用于WiredTiger存储引擎。

Specify the maximum number of concurrent write transactions allowed into the WiredTiger storage engine.指定WiredTiger存储引擎允许的最大并发写入事务数。

db.adminCommand( { setParameter: 1, wiredTigerConcurrentWriteTransactions: <num> } )
Tip提示
wiredTigerEngineRuntimeConfig

Available for mongod only.仅适用于mongod

Specify wiredTiger storage engine configuration options for a running mongod instance. 为正在运行的mongod实例指定wiredTiger存储引擎配置选项。You can only set this parameter using the setParameter command and notusing the command line or configuration file option.只能使用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>"
})

See the WiredTiger documentation for all available WiredTiger configuration options.有关所有可用的WiredTiger配置选项,请参阅WiredTigers文档

Auditing Parameters审核参数

auditAuthorizationSuccess

Type类型: boolean

Default默认值: false

Note注意

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

Available for both mongod and mongos.mongodmongos均可使用。

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的授权失败。

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.如果存在参数,服务器将无法启动。

Tip提示
See also: 参阅:
auditConfigPollingFrequencySecs

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 behind a setAuditConfig command.使用默认值300秒,非配置节点最多可以在setAuditConfig命令后延迟5分钟。

auditEncryptionHeaderMetadataFile

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

Type类型: string

Note注意

Available only in MongoDB Enterprise. 仅在MongoDB Enterprise中可用。MongoDB Enterprise and Atlas have different configuration requirements.MongoDB Enterprise和Atlas有不同的配置要求。

Available for both mongod and mongos.mongodmongos均可使用。

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.标题也存储在审核日志中。

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

mongod --setParameter auditEncryptionHeaderMetadataFile=/auditFiles/auditHeadersMetadataFile.log
auditEncryptKeyWithKMIPGet

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

Type类型: boolean

Default默认值: false

Note注意

Available only in MongoDB Enterprise. 仅在MongoDB Enterprise中可用。MongoDB Enterprise and Atlas have different configuration requirements.MongoDB Enterprise和Atlas有不同的配置要求。

Available for both mongod and mongos.mongodmongos均可使用。

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)服务器启用审核日志加密

You can only set auditEncryptKeyWithKMIPGet during startup in the configuration file or with the --setParameter option on the command line. 您只能在启动期间在配置文件中设置auditEncryptKeyWithKMIPGet,或者在命令行上使用--setParameter选项。For example, the following sets auditEncryptKeyWithKMIPGet to true:例如,以下内容将auditEncryptKeyWithKMIPGet设置为true

mongod --setParameter auditEncryptKeyWithKMIPGet=true

Transaction Parameters事务处理参数

coordinateCommitReturnImmediatelyAfterPersistingDecision

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

Type类型: boolean

Default默认值: true

Available for mongod only.仅适用于mongod

If true, the shard transaction coordinator returns a multi-document transaction commit decision to the client as soon as the commit 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",则在将决策返回给客户机后,提交可能会回滚。

If false, the shard transaction coordinator waits for all members to acknowledge a multi-document transaction commit before returning the commit decision to the client.如果为false,则分片事务协调器将等待所有成员确认多文档事务提交,然后再将提交决策返回给客户端。

The following example sets coordinateCommitReturnImmediatelyAfterPersistingDecision to false:以下示例将coordinateCommitReturnImmediatelyAfterPersistingDecision设置为false

mongod --setParameter coordinateCommitReturnImmediatelyAfterPersistingDecision=false

During runtime, you can also set the parameter with the setParameter command:在运行时,还可以使用setParameter命令设置参数:

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

New in version 4.0.在版本4.0中新增

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秒。

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.减少事务重试频率,从而提高性能。
maxTransactionLockRequestTimeoutMillis

New in version 4.0.在版本4.0中新增

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. 也就是说,如果事务无法在5毫秒内获取锁,则事务将中止。If an operation provides a greater timeout in a lock request, maxTransactionLockRequestTimeoutMillis overrides the operation-specific timeout.如果操作在锁定请求中提供了更大的超时,maxTransactionLockRequestTimeoutMillis将覆盖操作特定的超时。

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.使用特定于操作的超时。

The following sets the maxTransactionLockRequestTimeoutMillis to 20 milliseconds:以下内容将maxTransactionLockRequestTimeoutMillis设置为20毫秒:

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

You can also set this parameter during start-up:您还可以在启动期间设置此参数:

mongod --setParameter maxTransactionLockRequestTimeoutMillis=20
shouldMultiDocTxnCreateCollectionAndIndexes

Removed in 5.0在5.0中删除

Type类型: boolean

Default默认值: true

A flag that enables or disables the creation of a collection or an index inside transactions. 启用或禁用在事务内创建集合或索引的标志。Set the parameter to:将参数设置为:

  • true to enable. 以启用。(Default默认值)
  • false to disable.以禁用。

You can set the parameter during startup or runtime.您可以在启动或运行时设置参数。

Important重要

When setting the parameter for a sharded cluster, set the parameter on all shards.为分片群集设置参数时,请在所有分片上设置该参数。

To set the parameter at startup, specify the parameter in the configuration file or with the --setParameter option on the command line. 要在启动时设置参数,请在配置文件中或使用命令行上的--setParameter选项指定参数。For example:例如:

mongod --setParameter shouldMultiDocTxnCreateCollectionAndIndexes=false

To modify during runtime, you can use the setParameter command; for example:要在运行时进行修改,可以使用setParameter命令;例如:

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

Slot-Based Execution Parameters基于时隙的执行参数

planCacheSize

New in version 5.1.在版本5.1中新增

Type类型: string

Default默认值: 5%

Available for mongod only.仅适用于mongod

Sets the size of the plan cache for the slot based query execution engine.设置基于槽的查询执行引擎的计划缓存的大小。

You can set the planCacheSize value to either:可以将planCacheSize值设置为:

  • A percentage of the system's total physical memory to allocate for the plan cache. 要分配给计划缓存的系统总物理内存的百分比。For example, "8.5%".例如,"8.5%"
  • The exact amount of data to allocate for the plan cache in either MB or GB. 要为计划缓存分配的确切数据量(MBGB)。For example, "100MB" or "1GB".例如:"100MB""1GB"

Increasing the plan cache size adds more cached query shapes for the query planner. 增加计划缓存大小会为查询计划器添加更多缓存的查询形状。This can improve query performance, but increases memory usage.这可以提高查询性能,但会增加内存使用。

The following startup command sets planCacheSize to 80 megabytes:以下启动命令将planCacheSize设置为80 MB:

mongod --setParameter planCacheSize="80MB"

You can also use the setParameter command within the MongoDB Shell:您还可以在MongoDB Shell中使用setParameter命令:

db.adminCommand( { setParameter: 1, planCacheSize: "80MB" } )
←  Configuration File Settings and Command-Line Options MappingMongoDB Limits and Thresholds →