Note
Starting in MongoDB 8.0, LDAP authentication and authorization is deprecated. LDAP is available and will continue to operate without changes throughout the lifetime of MongoDB 8. LDAP will be removed in a future major release.从MongoDB 8.0开始,LDAP身份验证和授权被弃用。LDAP是可用的,并将在MongoDB 8的整个生命周期内继续运行而不做任何更改。LDAP将在未来的主要版本中删除。
For details, see LDAP Deprecation.有关详细信息,请参阅LDAP弃用。
Synopsis剧情简介
MongoDB provides a number of configuration options that you can set using:MongoDB提供了许多配置选项,您可以使用以下选项进行设置:
thesetParametercommand:setParameter命令:db.adminCommand( { setParameter: 1, <parameter>: <value> } )thesetParameterconfiguration setting:setParameter配置设置:setParameter:
<parameter1>: <value1>
...the--setParametercommand-line option formongodandmongos:mongod和mongos的--setParameter命令行选项:mongod --setParameter <parameter>=<value>
mongos --setParameter <parameter>=<value>
For additional configuration options, see Self-Managed Configuration File Options, 有关其他配置选项,请参阅自我管理配置文件选项、mongod and mongos.mongod和mongos。
Parameters参数
Authentication Parameters身份验证参数
allowRolesFromX509CertificatesAvailable for both适用于mongodandmongos.mongod和mongos。Default: true
A boolean flag that allows or disallows the retrieval of authorization roles from client X.509 certificates.一个布尔标志,允许或不允许从客户端X.509证书中检索授权角色。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
authenticationMechanismsAvailable for both适用于mongodandmongos.mongod和mongos。Specifies the list of authentication mechanisms the server accepts. Set this to one or more of the following values. If you specify multiple values, use a comma-separated list and no spaces.指定服务器接受的身份验证机制列表。将其设置为以下一个或多个值。如果指定了多个值,请使用逗号分隔的列表,不要使用空格。For descriptions of the authentication mechanisms, see Authentication on Self-Managed Deployments.有关身份验证机制的描述,请参阅自我管理部署上的身份验证。Value值Description描述SCRAM-SHA-1 RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.代表使用SHA-1哈希函数的标准Salted Challenge Response认证机制。SCRAM-SHA-256 RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.代表使用SHA-256哈希函数的标准Salted Challenge Response认证机制。MONGODB-X509 MongoDB TLS/SSL certificate authentication.MongoDB TLS/SSL证书身份验证。GSSAPI(Kerberos)External authentication using Kerberos. This mechanism is available only in MongoDB Enterprise.使用Kerberos的外部身份验证。此机制仅在MongoDB Enterprise中可用。PLAIN(LDAP SASL)External authentication using LDAP. You can also use使用LDAP进行外部身份验证。您还可以使用PLAIN对数据库中的用户进行身份验证。PLAINfor authenticating in-database users.PLAINtransmits passwords in plain text. This mechanism is available only in MongoDB Enterprise.PLAIN以纯文本形式传输密码。此机制仅在MongoDB Enterprise中可用。MONGODB-OIDC OpenID Connect is an authentication layer built on top of OAuth2. This mechanism is available only in MongoDB Enterprise.OpenID Connect是建立在OAuth2之上的身份验证层。此机制仅在MongoDB企业版中可用。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, to specify both例如,要指定PLAINandSCRAM-SHA-256as the authentication mechanisms, use the following command:PLAIN和SCRAM-SHA-256作为身份验证机制,请使用以下命令:mongod --setParameter authenticationMechanisms=PLAIN,SCRAM-SHA-256 --auth
authFailedDelayMsAvailable for both适用于mongodandmongos.mongod和mongos。Default: 0
Note
Enterprise Feature企业特性Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。The number of milliseconds to wait before informing clients that their authentication attempt has failed. This parameter may be in the range在通知客户端其身份验证尝试失败之前等待的毫秒数。此参数的范围可以是0to5000, inclusive.0到5000,包括0和5000。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服务器响应的客户端仍然会消耗服务器资源,如果服务器同时拒绝访问许多其他客户端,这可能会对良性登录尝试产生不利影响。
awsSTSRetryCountChanged in version 7.0.在版本7.0中的更改。(Also starting in 6.0.7 and 5.0.18)(同样从6.0.7和5.0.18开始)In previous versions, AWS IAM authentication retried only when the server returned an HTTP 500 error.在以前的版本中,AWS IAM身份验证仅在服务器返回HTTP 500错误时重试。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 2
For MongoDB deployments using AWS IAM credentials or AWS IAM environment variables.对于使用AWS IAM凭据或AWS IAM环境变量的MongoDB部署。Maximum number of AWS IAM authentication retries after a connection failure.连接失败后AWS IAM身份验证重试的最大次数。The following example sets以下示例将awsSTSRetryCountto15retries:awsSTSRetryCount设置为15次重试:mongod --setParameter awsSTSRetryCount=15Alternatively, the following examples uses the或者,以下示例使用setParametercommand withinmongosh:mongosh中的setParameter命令:db.adminCommand( { setParameter: 1, awsSTSRetryCount: 15 } )
clusterAuthModeAvailable for both适用于mongodandmongos.mongod和mongos。Set the将clusterAuthModeto eithersendX509orx509.clusterAuthMode设置为sendX509或x509。Useful during rolling upgrade to use x509 for membership authentication to minimize downtime.在滚动升级期间,使用x509进行成员身份验证以最大限度地减少停机时间非常有用。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodandmongosfor TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .mongod和mongos以用于TLS/SSL和客户端的TLS/SSL。This parameter is only available at runtime. To set the parameter, use the此参数仅在运行时可用。要设置参数,请使用setParametercommand.setParameter命令。db.adminCommand( { setParameter: 1, clusterAuthMode: "sendX509" } )
enableLocalhostAuthBypassAvailable for both适用于mongodandmongos.mongod和mongos。Default:
trueSpecify指定0orfalseto disable localhost authentication bypass. Enabled by default.0或false以禁用本地主机身份验证绕过。默认情况下启用。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。See Localhost Exception in Self-Managed Deployments for more information.有关详细信息,请参阅自我管理部署中的本地主机异常。
enforceUserClusterSeparationAvailable for both适用于mongodandmongos.mongod和mongos。Set to设置为falseto disable theO/OU/DCcheck whenclusterAuthModeiskeyFilein your configuration file.false可在配置文件中clusterAuthMode为keyFile时禁用O/OU/DC检查。This allows clients possessing member certificates to authenticate as users stored in the这允许拥有成员证书的客户端作为存储在$externaldatabase.$external数据库中的用户进行身份验证。The server won't start if如果clusterAuthModeisn'tkeyFilein your configuration file.clusterAuthMode不是配置文件中的keyFile,服务器将不会启动。To set the要将enforceUserClusterSeparationparameter tofalse, run the following command during startup:enforceUserClusterSeparation参数设置为false,请在启动过程中运行以下命令:mongod --setParameter enforceUserClusterSeparation=false
JWKSMinimumQuiescePeriodSecsAvailable for both适用于mongodandmongos.mongod和mongos。Default: 60 seconds (1 minute)
Specifies the minimum time period that must pass between subsequent fetches of a given IdP's指定给定IdP的JWKSetURIendpoint.JWKSetURI端点的后续提取之间必须经过的最小时间段。If an RSA public key is changed multiple times within the quiesce period, that key may not work as expected for up to a minute unless the quiesce period is manually reduced. If this parameter is set to zero, there is no quiesce period and the key can be refreshed repeatedly.如果RSA公钥在静默期内多次更改,则该键可能无法按预期工作长达一分钟,除非手动缩短静默期。如果此参数设置为零,则没有停顿期,键可以重复刷新。This parameter is available at both startup and runtime. To set the parameter, use the此参数在启动和运行时都可用。要设置参数,请使用setParametersetting.setParameter设置。
KeysRotationIntervalSecAvailable for both适用于mongodandmongos.mongod和mongos。Default: 7776000 seconds (90 days)
Specifies the number of seconds for which an HMAC signing key is valid before rotating to the next one. This parameter is intended primarily to facilitate authentication testing.指定HMAC签名键在旋转到下一个键之前的有效秒数。此参数主要用于促进身份验证测试。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
ldapConnectionPoolHostRefreshIntervalMillisAvailable for仅适用于mongodonly.mongod。Default: 60000
The number of milliseconds in-between health checks of the pooled LDAP connections.池化LDAP连接的运行状况检查之间的毫秒数。You can only set您只能在启动期间设置ldapConnectionPoolHostRefreshIntervalMillisduring start-up, and cannot change this setting with thesetParameterdatabase command.ldapConnectionPoolHostRefreshIntervalMillis,并且不能使用setParameter数据库命令更改此设置。
ldapConnectionPoolIdleHostTimeoutSecsAvailable for仅适用于mongodonly.mongod。Default: 300
The maximum number of seconds that the pooled connections to an LDAP server can remain idle before being closed.与LDAP服务器的池连接在关闭之前可以保持空闲的最大秒数。You can only set您只能在启动期间设置ldapConnectionPoolIdleHostTimeoutSecsduring start-up, and cannot change this setting with thesetParameterdatabase command.ldapConnectionPoolIdleHostTimeoutSecs,并且不能使用setParameter数据库命令更改此设置。
ldapConnectionPoolMaximumConnectionsInProgressPerHostAvailable for仅适用于mongodonly.mongod。Changed starting in MongoDB versions 5.0.9 and 6.0.0从MongoDB 5.0.9和6.0.0版本开始更改Changed default value to将默认值更改为2. In previous versions, the default is unset.2。在以前的版本中,默认设置为未设置。Default: 2
The maximum number of in-progress connect operations to each LDAP server.每个LDAP服务器正在进行的连接操作的最大数量。You can only set您只能在启动期间设置ldapConnectionPoolMaximumConnectionsInProgressPerHostduring start-up, and cannot change this setting with thesetParameterdatabase command.ldapConnectionPoolMaximumConnectionsInProgressPerHost,并且不能使用setParameter数据库命令更改此设置。
ldapConnectionPoolMaximumConnectionsPerHostAvailable for仅适用于mongodonly.mongod。Changed starting in MongoDB versions 5.0.9 and 6.0.0从MongoDB 5.0.9和6.0.0版本开始更改Changed default value to已将默认值更改为2147483647. In previous versions, the default is unset.2147483647。在以前的版本中,默认设置为未设置。Default: 2147483647
The maximum number of connections to keep open to each LDAP server.对每个LDAP服务器保持打开的最大连接数。You can only set您只能在启动期间设置ldapConnectionPoolMaximumConnectionsPerHostduring start-up, and cannot change this setting during run time with thesetParameterdatabase command.ldapConnectionPoolMaximumConnectionsPerHost,并且不能在运行时使用setParameter数据库命令更改此设置。
ldapConnectionPoolMinimumConnectionsPerHostAvailable for仅适用于mongodonly.mongod。Default: 1
The minimum number of connections to keep open to each LDAP server.对每个LDAP服务器保持打开状态的最小连接数。You can only set您只能在启动期间设置ldapConnectionPoolMinimumConnectionsPerHostduring start-up, and cannot change this setting during run time with thesetParameterdatabase command.ldapConnectionPoolMinimumConnectionsPerHost,并且不能在运行时使用setParameter数据库命令更改此设置。
ldapConnectionPoolUseLatencyForHostPriorityAvailable for仅适用于mongodonly.mongod。Default: true
A boolean that determines whether the LDAP connection pool (see一个布尔值,用于确定LDAP连接池(请参阅ldapUseConnectionPool) should use latency of the LDAP servers to determine the connection order (from lowest latency to highest).ldapUseConnectionPool)是否应使用LDAP服务器的延迟来确定连接顺序(从最低延迟到最高延迟)。You can only set您只能在启动期间设置ldapConnectionPoolUseLatencyForHostPriorityduring start-up, and cannot change this setting during run time with thesetParameterdatabase command.ldapConnectionPoolUseLatencyForHostPriority,并且不能在运行时使用setParameter数据库命令更改此设置。
ldapForceMultiThreadModeAvailable for both适用于mongodandmongos.mongod和mongos。Default: false
Enables the performance of concurrent LDAP operations.启用并发LDAP操作的性能。Note
Only if you are certain that your instance of只有当您确信libldapis safe to use in this mode, enable this flag. You may experience crashes of the MongoDB process if thelibldapversion you are using is not thread safe.libldap实例在此模式下使用是安全的时,才启用此标志。如果您使用的libldap版本不是线程安全的,您可能会遇到MongoDB进程崩溃的情况。You must use您必须使用ldapForceMultiThreadModeto use LDAP connection pool. To enable LDAP connection pool, setldapForceMultiThreadModeandldapUseConnectionPooltotrue.ldapForceMultiThreadMode才能使用LDAP连接池。要启用LDAP连接池,请将ldapForceMultiThreadMode和ldapUseConnectionPool设置为true。Tip
If you have any concerns regarding your MongoDB version, OS version or libldap version, please contact MongoDB Support.如果您对MongoDB版本、操作系统版本或libldap版本有任何疑问,请联系MongoDB支持。
ldapQueryPasswordAvailable for仅适用于mongodonly.mongod。Type: string
The password used to bind to an LDAP server. You must use用于绑定到LDAP服务器的密码。您必须将ldapQueryUserwith this parameter.ldapQueryUser与此参数一起使用。If not set, mongod or mongos does not attempt to bind to the LDAP server.如果未设置,mongod或mongos不会尝试绑定到LDAP服务器。
ldapQueryUserAvailable for仅适用于mongodonly.mongod。Type: string
The user that binds to an LDAP server. You must use绑定到LDAP服务器的用户。您必须将ldapQueryPasswordwith this parameter.ldapQueryPassword与此参数一起使用。If not set, mongod or mongos does not attempt to bind to the LDAP server.如果未设置,mongod或mongos不会尝试绑定到LDAP服务器。
ldapRetryCountNew in version 6.1.在版本6.1中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 0
For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。Number of operation retries by the server LDAP manager after a network error.网络错误后服务器LDAP管理器重试操作的次数。For example, the following sets例如,以下将ldapRetryCountto3seconds:ldapRetryCount设置为3秒:mongod --ldapRetryCount=3Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, ldapRetryCount: 3 } )
ldapShouldRefreshUserCacheEntriesNew in version 5.2.在版本5.2中新增。Available for仅适用于mongodonly.mongod。Type: boolean
Default: true
For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on从MongoDB 5.2开始,从LDAP服务器检索到的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries:ldapShouldRefreshUserCacheEntries:If true, use如果ldapUserCacheRefreshInterval.true,则使用ldapUserCacheRefreshInterval。If false, use如果ldapUserCacheInvalidationInterval.false,则使用ldapUserCacheInvalidationInterval。
You can only set您只能在启动期间在配置文件中或使用命令行上的ldapShouldRefreshUserCacheEntriesduring startup in theconfiguration fileor with the--setParameteroption on the command line.--setParameter选项设置ldapShouldRefreshUserCacheEntries。For example, the following disables例如,以下内容禁用ldapShouldRefreshUserCacheEntries:ldapShouldRefreshUserCacheEntries:mongod --setParameter ldapShouldRefreshUserCacheEntries=false
ldapUseConnectionPoolAvailable for both适用于mongodandmongos.mongod和mongos。Specifies whether MongoDB should use connection pooling when connecting to the LDAP server for authentication/authorization.指定MongoDB在连接到LDAP服务器进行身份验证/授权时是否应使用连接池。MongoDB uses the following default values:MongoDB使用以下默认值:- true on Windows.
true on Linux where MongoDB Enterprise binaries are linked against在Linux上为libldap_r.true,MongoDB Enterprise二进制文件与libldap_r链接。false on Linux where MongoDB Enterprise binaries are linked against在Linux上为libldap.false,其中MongoDB Enterprise二进制文件与libldap链接。
You can only set您只能在启动期间设置ldapUseConnectionPoolduring start-up, and cannot change this setting with thesetParameterdatabase command.ldapUseConnectionPool,不能使用setParameter数据库命令更改此设置。
ldapUserCacheInvalidationIntervalChanged in version 5.2.在版本5.2中的更改。Available for仅适用于mongodonly.mongod。Default: 30 seconds
Note
Starting in MongoDB 5.2, the update interval for cached user information retrieved from an LDAP server depends on从MongoDB 5.2开始,从LDAP服务器检索到的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries:ldapShouldRefreshUserCacheEntries:If true, use如果为ldapUserCacheRefreshInterval.true,则使用ldapUserCacheRefreshInterval。If false, use如果为ldapUserCacheInvalidationInterval.false,则使ldapUserCacheInvalidationInterval。
For use with MongoDB deployments using LDAP Authorization on Self-Managed Deployments.用于在自我管理部署上使用LDAP授权的MongoDB部署。The interval (in seconds) that themongodinstance waits between external user cache flushes.mongod实例在外部用户缓存刷新之间等待的时间间隔(秒)。After MongoDB flushes the external user cache, MongoDB reacquires authorization data from the LDAP server the next time an LDAP-authorized user issues an operation.MongoDB刷新外部用户缓存后,下次LDAP授权用户发出操作时,MongoDB会从LDAP服务器重新获取授权数据。Increasing the value specified increases the amount of time MongoDB and the LDAP server can be out of sync, but reduces the load on the LDAP server. Conversely, decreasing the value specified decreases the time MongoDB and the LDAP server can be out of sync while increasing the load on the LDAP server.增加指定的值会增加MongoDB和LDAP服务器不同步的时间,但会减少LDAP服务器的负载。相反,减小指定的值可以减少MongoDB和LDAP服务器不同步的时间,同时增加LDAP服务器的负载。
ldapUserCacheRefreshIntervalNew in version 5.2.在版本5.2中新增。Available for仅适用于mongodonly.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从MongoDB 5.2开始,从LDAP服务器检索到的缓存用户信息的更新间隔取决于ldapShouldRefreshUserCacheEntries:ldapShouldRefreshUserCacheEntries:If true, use如果为ldapUserCacheRefreshInterval.true,则使用ldapUserCacheRefreshInterval。If false, use如果为ldapUserCacheInvalidationInterval.false,请使用ldapUserCacheInvalidationInterval。
For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。The interval in seconds thatmongodwaits 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例如,以下将ldapUserCacheRefreshIntervalto4000seconds:ldapUserCacheRefreshInterval设置为4000秒:mongod --setParameter ldapUserCacheRefreshInterval=4000Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, ldapUserCacheRefreshInterval: 4000 } )
ldapUserCacheStalenessIntervalNew in version 5.2.在版本5.2中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 90 seconds
For MongoDB deployments using LDAP Authorization on Self-Managed Deployments.对于在自我管理部署中使用LDAP授权的MongoDB部署。The interval in seconds that上次缓存刷新后mongodretains the cached LDAP user information after the last cache refresh.mongod保留缓存的LDAP用户信息的间隔(秒)。If more than如果超过ldapUserCacheStalenessIntervalseconds elapse without a successful refresh of the user information from the LDAP server, thenmongod:ldapUserCacheStalenessInterval秒后,LDAP服务器上的用户信息仍未成功刷新,则mongod:Invalidates the cached LDAP user information.使缓存的LDAP用户信息无效。Is unable to authenticate new sessions for LDAP users until在mongodconnects to the LDAP server and authorizes the LDAP user.mongod连接到LDAP服务器并授权LDAP用户之前,无法对LDAP用户的新会话进行身份验证。Authorizes any existing sessions that use previously authenticated LDAP users if如果mongodis unable to connect to the LDAP server.mongod无法连接到LDAP服务器,则授权使用以前经过身份验证的LDAP用户的任何现有会话。When当mongodreconnects to the LDAP server,mongodensures the LDAP users are correctly authorized.mongod重新连接到LDAP服务器时,mongod会确保LDAP用户得到正确授权。
The maximum interval is 86,400 seconds (24 hours).最长间隔为86400秒(24小时)。For example, the following sets例如,以下将ldapUserCacheStalenessIntervalto4000seconds:ldapUserCacheStalenessInterval设置为4000秒:mongod --setParameter ldapUserCacheStalenessInterval=4000Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, ldapUserCacheStalenessInterval: 4000 } )
maxValidateMemoryUsageMBAvailable for仅适用于mongodonly.mongod。New in version 5.0.在版本5.0中新增。Default: 200
The maximum memory usage limit in megabytes for thevalidatecommand.validate命令的最大内存使用限制(MB)。If the limit is exceeded,如果超过限制,validatereturns as many results as possible and warns that not all corruption might be reported because of the limit.validate将返回尽可能多的结果,并警告说,由于限制,可能不会报告所有损坏。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
ocspEnabledAvailable for both适用于mongodandmongos.mongod和mongos。Available on Linux and macOS.适用于Linux和macOS。Default: true
The flag that enables or disables OCSP.启用或禁用OCSP的标志。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, the following disables OCSP:例如,以下内容禁用OCSP:mongod --setParameter ocspEnabled=false ...Starting in MongoDB 6.0, if从MongoDB 6.0开始,如果在初始同步期间ocspEnabledis set totrueduring initial sync, all nodes must be able to reach the OCSP responder.ocspEnabled设置为true,则所有节点都必须能够访问OCSP响应器。If a member fails in the如果成员在STARTUP2state, settlsOCSPVerifyTimeoutSecsto a value that is less than5.STARTUP2状态下失败,请将tlsOCSPVerifyTimeoutSecs设置为小于5的值。
ocspStaplingRefreshPeriodSecsAvailable for both适用于mongodandmongos.mongod和mongos。Available on Linux.在Linux上可用。The number of seconds to wait before refreshing the stapled OCSP status response. Specify a number greater than or equal to 1.刷新装订好的OCSP状态响应之前等待的秒数。指定一个大于或等于1的数字。You can only set您只能在启动期间在配置文件中或使用命令行上的ocspStaplingRefreshPeriodSecsduring startup in theconfiguration fileor with the--setParameteroption on the command line.--setParameter选项设置ocspStaplingRefreshPeriodSecs。For example, the following sets the parameter to 3600 seconds:例如,以下将参数设置为3600秒:mongod --setParameter ocspStaplingRefreshPeriodSecs=3600 ...Starting in MongoDB 5.0, the从MongoDB 5.0开始,rotateCertificatescommand anddb.rotateCertificates()method will also refresh any stapled OCSP responses.rotateCertificates命令和db.rotateCertificates()方法也将刷新任何装订的OCSP响应。
oidcIdentityProvidersAvailable for仅适用于mongodonly.mongod。Changed in version 8.0.在版本8.0中的更改。 (Also available in 7.3 and 7.0)Use this parameter to specify identity provider (IDP) configurations when using OpenID Connect Authentication.使用OpenID连接身份验证时,使用此参数指定身份提供程序(IDP)配置。oidcIdentityProvidersaccepts an array of zero or more identity provider (IDP) configurations.接受零个或多个身份提供者(IDP)配置的数组。An empty array (default) indicates no OpenID Connect support is enabled.空数组(默认)表示未启用OpenID Connect支持。When more than one IDP is defined,当定义了多个IDP时,oidcIdentityProvidersuses thematchPatternfield to select an IDP. Array order determines the priority and the first IDP is always selected.oidcIdentityProvider使用matchPattern字段选择一个IDP。数组顺序决定了优先级,并且始终选择第一个IDP。Starting in MongoDB 8.0, when multiple identity providers (IDP) are defined, the从MongoDB 8.0开始,当定义了多个身份提供者(IDP)时,oidcIdentityProvidersparameter accepts duplicateissuervalues as long as theaudiencevalue is unique for each issuer. This is also available in versions 7.3 and 7.0.oidcIdentityProviders参数接受重复的issuer值,只要每个issuer的audience值都是唯一的。这在7.3和7.0版本中也可用。oidcIdentityProviders Fields
Field字段Necessity必要性Type类型Description描述issuerRequired必需string字符串The issuer URI of the IDP that the server should accept tokens from. This must match the服务器应从中接受令牌的IDP的颁发者URI。这必须与用于身份验证的任何JWT中的iss字段匹配。issfield in any JWT used for authentication.Starting in MongoDB 8.0, when multiple identity providers (IDP) are defined, the从MongoDB 8.0开始,当定义了多个身份提供者(IDP)时,oidcIdentityProvidersparameter accepts duplicateissuervalues as long as theaudiencevalue is unique for each issuer.oidcIdentityProviders参数接受重复的issuer值,只要每个issuer的audience值都是唯一的。This is also available in versions 7.3 and 7.0.这在7.3和7.0版本中也可用。If you specify an unreachable issuer URI, MongoDB:如果您指定了一个无法访问的颁发者URI,MongoDB:- Logs a warning.
Continues server startup, which allows you to update the issuer URI.继续服务器启动,这允许您更新颁发者URI。Reattempts issuer contact. If MongoDB reaches the issuer URI and validates the access token, authentication succeeds. If the issuer URI remains unreachable, authentication fails.重新尝试与发卡行联系。如果MongoDB到达颁发者URI并验证访问令牌,则身份验证成功。如果颁发者URI仍然无法访问,则身份验证失败。
Changed in version 8.0.在版本8.0中的更改。 (Also available in 7.3 and 7.0)authNamePrefixRequired必需string字符串Unique prefix applied to each generated应用于授权中使用的每个生成的用户名和角色名的唯一前缀。authNamePrefix只能包含以下字符:UserNameandRoleNameused in authorization.authNamePrefixcan only contain the following characters:alphanumeric characters (combination of字母数字字符(atozand0to9)a到z和0到9的组合)- hyphens (
-) - underscores (
_)
matchPatternConditional string字符串Regex pattern used to determine which IDP should be used.用于确定应使用哪个IDP的正则表达式模式。matchPatternmatches against usernames. Array order determines the priority and the first IDP is always selected.matchPattern与用户名匹配。数组顺序决定了优先级,并且始终选择第一个IDP。matchPatternis required in some configurations, depending on how the user sets在某些配置中是必需的,具体取决于用户设置supportsHumanFlows:supportsHumanFlows的方式:When only one IdP has当只有一个IdP将supportsHumanFlowsset totrue(the default),matchPatternsis optional.supportsHumanFlows设置为true(默认值)时,matchPatterns是可选的。When multiple IdP's have当多个IdP将supportsHumanFlowsset totrue(the default), each of these requiresmatchPatterns.supportsHumanFlows设置为true(默认值)时,每个IdP都需要matchPatterns。matchPatternsis optional for any IdP wheresupportsHumanFlowsis set tofalse.matchPatterns对于supportsHumanFlows设置为false的任何IdP都是可选的。
This is not a security mechanism.这不是一种安全机制。matchPatternserves only as an advisory to clients. MongoDB accepts tokens issued by the IDP whose principal names do not match this pattern.matchPattern仅作为对客户的建议。MongoDB接受IDP颁发的令牌,其主体名称与此模式不匹配。clientIdConditional string字符串ID provided by the IDP to identify the client that receives the access tokens.IDP提供的ID,用于标识接收访问令牌的客户端。Required when当supportsHumanFlowsis set totrue(the default).supportsHumanFlows设置为true(默认值)时需要。audienceRequired必需string字符串Specifies the application or service that the access token is intended for.指定访问令牌要用于的应用程序或服务。Starting in MongoDB 7.0, only one从MongoDB 7.0开始,只能为OIDC访问令牌指定一个audienceoidcIdentityProviders field can be specified for OIDC access tokens.audiencefields with empty arrays or arrays of multiple strings are invalid.audience(受众)oidcIdentityProviders字段。具有空数组或多个字符串数组的audience字段无效。When more than one IDP is defined, this must be a unique value for each configuration that shares an当定义了多个IDP时,对于共享issuer.issuer(发行者)的每个配置,这必须是一个唯一的值。requestScopesOptional可选array[ string ] Permissions and access levels that MongoDB requests from the IDP.MongoDB向IDP请求的权限和访问级别。principalNameOptional可选string字符串The claim to be extracted from the access token containing MongoDB user identifiers.从包含MongoDB用户标识符的访问令牌中提取的声明。The default value is默认值为sub(stands forsubject).sub(代表subject)。useAuthorizationClaimOptional可选boolean布尔值Determines if the确定是否需要authorizationClaimis required. The default value istrue.authorizationClaim。默认值为true。If the如果useAuthorizationClaimfield is set totrue, the server requires anauthorizationClaimfor the identity provider's config. This is the default behavior.useAuthorizationClaim字段设置为true,则服务器需要身份提供者的配置的authorizationClaim。这是默认行为。If the如果useAuthorizationClaimfield is set tofalse, theauthorizationClaimfield is optional (and ignored if provided). Instead, the server does the following:useAuthorizationClaim字段设置为false,则authorizationClaim字段是可选的(如果提供,则忽略)。相反,服务器会执行以下操作:Searches the token for a claim whose name is listed in the在令牌中搜索其名称列在principalNameClaimfield. This is typically namedsub. For example:principalNameClaim字段中的声明。这通常被称为sub。例如:sub: "spencer.jackson@example.com"Constructs the internal username by concatenating the通过连接authNamePrefix, a forward slash (/), and the contents of the claim identified byprincipalNameClaimwithin the access token. For example, with aauthNamePrefixfield value of "mdbinc", the internal username is:authNamePrefix、正斜杠(/)和访问令牌中由principalNameClaim标识的声明内容来构造内部用户名。例如,如果authNamePrefix字段值为“mdbinc”,则内部用户名为:mdbinc/spencer.jackson@example.comLooks for the user with this username and authorizes the client with the roles:查找具有此用户名的用户,并使用以下角色授权客户端:{ user: "mdbinc/spencer.jackson@example.com",
db: "$external" }
New in version 7.2.在版本7.2中新增。 (Also available in 7.0.5)authorizationClaimConditional string字符串Required, unless必需,除非useAuthorizationClaimis set tofalse.useAuthorizationClaim设置为false。Claim extracted from access token that contains MongoDB role names.从包含MongoDB角色名称的访问令牌中提取的声明。logClaimsOptional可选array[ string ] List of access token claims to include in log and audit messages upon authentication completion.身份验证完成后要包含在日志和审核消息中的访问令牌声明列表。JWKSPollSecsOptional可选integer整数Frequency, in seconds, to request an updated JSON Web Key Set (JWKS) from the IDP. A setting of 0 disables polling.从IDP请求更新的JSON Web键集(JWKS)的频率(秒)。设置为0将禁用轮询。When more than one IDP is defined, this must be the same value for each configuration that shares an当定义了多个IDP时,共享issuer.issuer(发行者)的每个配置的IDP值必须相同。supportsHumanFlowsOptional可选bool Whether the OIDC provider supports human or machine workflows. This affects theOIDC提供商是否支持人工或机器工作流程。这会影响clientIdandmatchPatternfields.clientId和matchPattern字段。You may find it useful to set this field to您可能会发现,使用机器工作负载IdP将此字段设置为falsewith machine workload IdP's to allow them to omit theclientIdwhen it's unneeded.false很有用,这样它们就可以在不需要时省略clientId。Default:
true.New in version 7.2.在版本7.2中新增。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
opensslCipherConfigAvailable for both适用于mongodandmongos.mongod和mongos。Available on Linux only仅在Linux上可用With the use of native TLS/SSL libraries, the parameter通过使用本机TLS/SSL库,参数opensslCipherConfigis supported for Linux/BSD and no longer supported in Windows and macOS.opensslCipherConfig在Linux/BSD中受支持,在Windows和macOS中不再受支持。Specify the cipher string for OpenSSL when using TLS/SSL encryption. For a list of cipher strings, see https://www.openssl.org/docs/man1.1.1/man1/ciphers.html.使用TLS/SSL加密时,指定OpenSSL的密码字符串。有关密码字符串的列表,请参阅https://www.openssl.org/docs/man1.1.1/man1/ciphers.html。Multiple cipher strings can be provided as a colon-separated list.多个密码字符串可以以冒号分隔的列表形式提供。Note
This parameter is only for use with TLS 1.2 or earlier. To specify cipher suites for use with TLS 1.3, use the此参数仅适用于TLS 1.2或更早版本。要指定与TLS 1.3一起使用的密码套件,请使用opensslCipherSuiteConfigparameter.opensslCipherSuiteConfig参数。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。The use ofTLSoptions is preferred overSSLoptions.TLS选项的使用优于SSL选项。The TLS options have the same functionality as theSSLoptions.TLS选项与SSL选项具有相同的功能。The following example configures a以下示例使用mongodwith aopensslCipherConfigcipher string of'HIGH:!EXPORT:!aNULL@STRENGTH':opensslCipherConfig密码字符串'HIGH:!EXPORT:!aNULL@STRENGTH'配置mongod:mongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL@STRENGTH' --tlsMode requireTLS --tlsCertificateKeyFile Certs/server.pem
opensslCipherSuiteConfigAvailable for both适用于mongodandmongos.mongod和mongos。New in version 5.0.在版本5.0中新增。Available on Linux only仅在Linux上可用Specify the list of supported cipher suites OpenSSL should permit when using TLS 1.3 encryption.指定使用TLS 1.3加密时OpenSSL应允许的受支持密码套件列表。For a list of cipher suites for use with TLS 1.3, see https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_cipher_list.html. Multiple cipher suites can be provided as a colon-separated list.有关与TLS 1.3一起使用的密码套件列表,请参阅https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_cipher_list.html。多个密码套件可以以冒号分隔的列表形式提供。Note
This parameter is only for use with TLS 1.3. To specify cipher strings for use with TLS 1.2 or earlier, use the此参数仅适用于TLS 1.3。要指定与TLS 1.2或更早版本一起使用的密码字符串,请使用opensslCipherConfigparameter.opensslCipherConfig参数。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, the following configures a例如,以下内容将mongodwith aopensslCipherSuiteConfigcipher suite of'TLS_AES_256_GCM_SHA384'for use with TLS 1.3:mongod配置为opensslCipherSuiteConfig密码套件'TLS_AES_256_GCM_SHA384',以与TLS 1.3一起使用:mongod --setParameter opensslCipherSuiteConfig='TLS_AES_256_GCM_SHA384' --tlsMode requireTLS --tlsCertificateKeyFile Certs/server.pem
opensslDiffieHellmanParametersAvailable for both适用于mongodandmongos.mongod和mongos。Available on Linux only仅在Linux上可用Specify the path to the PEM file that contains the OpenSSL Diffie-Hellman parameters when using TLS 1.2 or previous.使用TLS 1.2或更早版本时,指定包含OpenSSL Diffie-Hellman参数的PEM文件的路径。Specifying the OpenSSL Diffie-Hellman parameters enables support for Ephemeral Diffie-Hellman (DHE) cipher suites during TLS/SSL encryption.指定OpenSSL Diffie-Hellman参数可以在TLS/SSL加密期间支持Ephemeral Diffie-Hellman(DHE)密码套件。This parameter is not supported for use with TLS 1.3.TLS 1.3不支持使用此参数。Ephemeral Diffie-Hellman (DHE) cipher suites (and Ephemeral Elliptic Curve Diffie-Hellman (ECDHE) cipher suites) provide Forward Secrecy.瞬时Diffie-Hellman(DHE)密码套件(和瞬时椭圆曲线Diffie-Hell(ECDHE)密码套件)提供前向保密。Forward Secrecy cipher suites create an ephemeral session key that is protected by the server's private key but never transmitted.前向保密密码套件创建了一个受服务器私钥保护但从不传输的临时会话键。This ensures that even if a server's private key is compromised, you cannot decrypt past sessions with the compromised key.这确保了即使服务器的私钥被泄露,您也无法使用泄露的键解密过去的会话。Note
If如果未设置opensslDiffieHellmanParametersis unset but ECDHE is enabled, MongoDB enables DHE using theffdhe3072Diffie-Hellman parameter, as defined in RFC-7919#appendix-A.2.opensslDiffieHellmanParameters,但启用了ECDHE,则MongoDB将使用RFC-7919#appendix-A.2中定义的ffdhe3072Diffie-Hellman参数启用DHE。Theffdhe3072is a strong parameter (specifically, size is greater than 1024). Strong parameters are not supported with Java 6 and 7 unless extended support has been purchased from Oracle.ffdhe3072是一个强参数(具体来说,大小大于1024)。除非从Oracle购买了扩展支持,否则Java 6和7不支持强参数。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。If for performance reasons, you need to disable support for DHE cipher suites, use the如果出于性能原因,您需要禁用对DHE密码套件的支持,请使用opensslCipherConfigparameter:opensslCipherConfig参数:mongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL:!DHE:!kDHE@STRENGTH' ...
pessimisticConnectivityCheckForAcceptedConnectionsAvailable on Linux only仅在Linux上可用Type: boolean
Default: false
When set to当设置为true, instructs the server to check the connectivity of accepted connections before processing them and to immediately discard connections that the client terminates.true时,指示服务器在处理已接受的连接之前检查其连接,并立即丢弃客户端终止的连接。Consider enabling this parameter on smaller instance types. You can use it when you want to trade a small amount of latency on new connection establishment for reduced server work when processing new connections that have already been closed on the client side.考虑在较小的实例类型上启用此参数。当您想在处理客户端已关闭的新连接时,以新连接建立的少量延迟换取减少的服务器工作时,可以使用它。
saslauthdPathAvailable for both适用于mongodandmongos.mongod和mongos。Note
Available only in MongoDB Enterprise (except MongoDB Enterprise for Windows).仅在MongoDB Enterprise中可用(适用于Windows的MongoDB Enterprise除外)。Specify the path to the Unix Domain Socket of the指定用于代理身份验证的saslauthdinstance to use for proxy authentication.saslausted实例的Unix域套接字的路径。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
saslHostNameAvailable for both适用于mongodandmongos.mongod和mongos。saslHostNameoverrides MongoDB's default hostname detection for the purpose of configuring SASL and Kerberos authentication.覆盖MongoDB的默认主机名检测,以配置SASL和Kerberos身份验证。saslHostNamedoes not affect the hostname of themongodormongosinstance for any purpose beyond the configuration of SASL and Kerberos.saslHostName不会出于SASL和Kerberos配置之外的任何目的影响mongod或mongos实例的主机名。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。Note
saslHostNamesupports Kerberos authentication and is only included in MongoDB Enterprise. For more information, see the following:支持Kerberos身份验证,仅包含在MongoDB Enterprise中。有关更多信息,请参阅以下内容:
saslServiceNameAvailable for both适用于mongodandmongos.mongod和mongos。Allows users to override the default Kerberos service name component of the Kerberos principal name, on a per-instance basis. If unspecified, the default value is允许用户在每个实例的基础上覆盖Kerberos主体名称的默认Kerberos服务名称组件。如果未指定,默认值为mongodb.mongodb。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。saslServiceNameis only available in MongoDB Enterprise.仅在MongoDB企业版中可用。Important
Ensure that your driver supports alternate service names.确保驱动程序支持备用服务名称。
scramIterationCountAvailable for both适用于mongodandmongos.mongod和mongos。Default:
10000Changes the number of hashing iterations used for all new更改用于所有新SCRAM-SHA-1passwords. More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts.SCRAM-SHA-1密码的哈希迭代次数。更多的迭代增加了客户端向MongoDB进行身份验证所需的时间,但使密码不易受到暴力破解的影响。The default value is ideal for most common use cases and requirements.默认值非常适合最常见的用例和需求。If you modify this value, it does not change the iteration count for existing passwords. The如果修改此值,则不会更改现有密码的迭代计数。scramIterationCountvalue must be5000or greater.scramIterationCount值必须为5000或更大。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the例如,下面将scramIterationCountto12000.scramIterationCount设置为12000。mongod --setParameter scramIterationCount=12000Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, scramIterationCount: 12000 } )
scramSHA256IterationCountAvailable for both适用于mongodandmongos.mongod和mongos。Default:
15000Changes the number of hashing iterations used for all new更改用于所有新SCRAM-SHA-256passwords. More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts. The default value is ideal for most common use cases and requirements.SCRAM-SHA-256密码的哈希迭代次数。更多的迭代增加了客户端向MongoDB进行身份验证所需的时间,但使密码不易受到暴力破解的影响。默认值非常适合最常见的用例和需求。If you modify this value, it does not change iteration count for existing passwords. The如果修改此值,则不会更改现有密码的迭代计数。scramSHA256IterationCountvalue must be5000or greater.scramSHA256IterationCount值必须大于等于5000。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the例如,以下将scramSHA256IterationCountto20000.scramSHA256IterationCount设置为20000。mongod --setParameter scramSHA256IterationCount=20000Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, scramSHA256IterationCount: 20000 } )
sslModeAvailable for both适用于mongodandmongos.mongod和mongos。Set the将net.ssl.modeto eitherpreferSSLorrequireSSL. Useful during rolling upgrade to TLS/SSL to minimize downtime.net.ssl.mode设置为preferSSL或requireSSL。在滚动升级到TLS/SSL期间非常有用,可以最大限度地减少停机时间。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodandmongosfor TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .mongod和mongos以用于TLS/SSL和客户端的TLS/SSL配置。This parameter is only available at runtime. To set the parameter, use the此参数仅在运行时可用。要设置参数,请使用setParametercommand.setParameter命令。db.adminCommand( { setParameter: 1, sslMode: "preferSSL" } )Tip
tlsClusterAuthX509OverrideAvailable for both适用于mongodandmongos.mongod和mongos。New in version 7.0.在版本7.0中新增。Overrides the覆盖clusterAuthX509configuration options.clusterAuthX509配置选项。setParameter:
tlsClusterAuthX509Override: "{ attributes: 'O=MongoDB, OU=MongoDB Server' }"The parameter supports该参数支持attributesandextensionValueoverrides.attributes和extensionValue重写。When the server authenticates connections from members, it analyzes the X.509 certificate to determine whether it belongs to a cluster member.当服务器对来自成员的连接进行身份验证时,它会分析X.509证书以确定它是否属于集群成员。If the server uses the如果服务器使用attributessetting or theattributesfield on thetlsClusterAuthX509Overrideparameter, it checks the Distinguished Name (DN) values of the certificate.tlsClusterAuthX509Override参数上的attributes设置或attributes字段,它将检查证书的可分辨名称(DN)值。If the如果设置了extensionValuesetting or theextensionValuefield of thetlsClusterAuthX509Overrideparameter is set, it checks the extension values of the certificate.tlsClusterAuthX509Override参数的extensionValue设置或extensionValue字段,它将检查证书的扩展值。If it finds a match, it authorizes the connection as a peer.如果它找到匹配项,它将以对等身份授权连接。Use this parameter to rotate certificates when the new certificates have different attributes or extension values.当新证书具有不同的属性或扩展名值时,使用此参数轮换证书。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
tlsModeAvailable for both适用于mongodandmongos.mongod和mongos。Set to either:
preferTLSrequireTLS
ThetlsModeparameter is useful during rolling upgrade to TLS/SSL to minimize downtime.tlsMode参数在滚动升级到TLS/SSL期间非常有用,可以最大限度地减少停机时间。This parameter is only available at runtime. To set the parameter, use the此参数仅在运行时可用。要设置参数,请使用setParametercommand.setParameter命令。db.adminCommand( { setParameter: 1, tlsMode: "preferTLS" } )For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodandmongosfor TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .mongod和mongos以用于TLS/SSL和客户端的TLS/SSL配置。Tip
tlsOCSPStaplingTimeoutSecsAvailable for both适用于mongodandmongos.mongod和mongos。Available for Linux.适用于Linux。The maximum number of seconds themongod/mongosinstance should wait to receive the OCSP status response for its certificates.mongod/mongos实例应等待接收其证书的OCSP状态响应的最大秒数。Specify an integer greater than or equal to (指定一个大于或等于(>=) 1. If unset,tlsOCSPStaplingTimeoutSecsuses thetlsOCSPVerifyTimeoutSecsvalue.>=)1的整数。如果未设置,tlsOCSPStaplingTimeoutSecs将使用tlsOCSPVerifyTimeoutSecs值。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, the following sets the例如,以下将tlsOCSPStaplingTimeoutSecsto 20 seconds:tlsOCSPStaplingTimeoutSecs设置为20秒:mongod --setParameter tlsOCSPStaplingTimeoutSecs=20 ...
tlsOCSPVerifyTimeoutSecsAvailable for both适用于mongodandmongos.mongod和mongos。Available for Linux and Windows.
Default: 5
The maximum number of seconds that themongod/mongosshould wait for the OCSP response when verifying server certificates.mongod/mongos在验证服务器证书时等待OCSP响应的最大秒数。Specify an integer greater than or equal to (指定一个大于或等于(>=) 1.>=)1的整数。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, the following sets the例如,以下将tlsOCSPVerifyTimeoutSecsto 20 seconds:tlsOCSPVerifyTimeoutSecs设置为20秒:mongod --setParameter tlsOCSPVerifyTimeoutSecs=20 ...
tlsUseSystemCAAvailable for仅适用于mongodonly.mongod。Type: boolean
Default: false
Specifies whether MongoDB loads TLS certificates that are already available to the operating system's certificate authority.指定MongoDB是否加载操作系统证书颁发机构已经可用的TLS证书。Important
When starting a
mongodinstance with TLS/SSL enabled, you must specify a value for the--tlsCAFileflag, thenet.tls.CAFileconfiguration option, or thetlsUseSystemCAparameter.--tlsCAFile,tls.CAFile, andtlsUseSystemCAare all mutually exclusive.--tlsCAFile、tls.CAFfile和tlsUseSystemCA都是互斥的。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, to set例如,要将tlsUseSystemCAtotrue:tlsUseSystemCA设置为true:mongod --setParameter tlsUseSystemCA=trueFor more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅在自我管理部署上配置mongodandmongosfor TLS/SSL on Self-Managed Deployments and TLS/SSL Configuration for Clients .mongod和mongos以用于TLS/SSL和客户端的TLS/SSL配置。
tlsWithholdClientCertificateAvailable for both适用于mongodandmongos.mongod和mongos。Default: false
A TLS certificate is set for a通过mongodormongoseither by the--tlsClusterFileoption or by the--tlsCertificateKeyFileoption when--tlsClusterFileis not set.--tlsClusterFile选项或未设置--tlsClusterFile时的--tlsCertificateKeyFile选项为mongod或mongos设置TLS证书。If the TLS certificate is set, by default, the instance sends the certificate when initiating intra-cluster communications with other如果设置了TLS证书,默认情况下,实例在与部署中的其他mongodormongosinstances in the deployment.mongod或mongos实例发起集群内通信时会发送证书。Set将tlsWithholdClientCertificateto1ortrueto direct the instance to withhold sending its TLS certificate during these communications.tlsWithholdClientCertificate设置为1或true,以指示实例在这些通信期间拒绝发送其TLS证书。Use this option with在部署的所有成员上,将此选项与--tlsAllowConnectionsWithoutCertificates(to allow inbound connections without certificates) on all members of the deployment.--tlsAllowConnectionsWithoutCertificates一起使用(以允许没有证书的入站连接)。tlsWithholdClientCertificateis mutually exclusive with--clusterAuthMode x509.tlsWithholdClientCertificate与--clusterAuthMode x509互斥。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
tlsX509ClusterAuthDNOverrideAvailable for both适用于mongodandmongos.mongod和mongos。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对于使用X.509证书进行clusterAuthMode, deployment members identify each other using X.509 certificates (net.tls.clusterFile, if specified, andnet.tls.certificateKeyFile) during intra-cluster communications.clusterAuthMode的MongoDB部署,部署成员在集群内通信期间使用X.509证书(如果指定了net.tls.clusterFile和net.tls.certificateKeyFile)相互标识。For members of the same deployment, the对于同一部署的成员,其证书中的DNfrom 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如果为成员设置了tlsX509ClusterAuthDNOverrideis set for a member, the member can also use the override value when comparing theDNcomponents (O's,OU's, andDC's) of the presented certificates.tlsX509ClusterAuthDNOverride,则该成员在比较所提供证书的DN组件(O、OU和DC)时也可以使用重写值。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如果DN不匹配,成员将根据tlsX509ClusterAuthDNOverridevalue.tlsX509ClusterAuthDNOverride值检查提供的证书。Note
If set, you must set this parameter on all members of the deployment.如果已设置,则必须在部署的所有成员上设置此参数。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
You can use this parameter for a rolling update of certificates to new certificates that contain a new您可以使用此参数将证书滚动更新为包含新DNvalue.DN值的新证书。See Rotate X.509 Certificates without clusterAuthX509 Attributes on Self-Managed Clusters.请参阅在自管理群集上旋转不带clusterAuthX509属性的X.509证书。For more information about membership certificate requirements, see Member Certificate Requirements for details.有关会员证书要求的更多信息,请参阅会员证书要求以了解详细信息。
tlsX509ExpirationWarningThresholdDaysAvailable for both适用于mongodandmongos.mongod和mongos。Default : 30
如果所提供的X.509证书在mongod/mongoslogs a warning on connection if the presented X.509 certificate expires within30days of themongod/mongossystem clock.mongod/mongos系统时钟后30天内到期,mongod/mongos会在连接时记录警告。Use the使用tlsX509ExpirationWarningThresholdDaysparameter 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将参数设置为0to disable the warning.0以禁用警告。
This parameter has a minimum value of此参数的最小值为0.0。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For more information on X.509 certificate validity, see RFC 5280 4.1.2.5.有关X.509证书有效性的更多信息,请参阅RFC 5280 4.1.2.5。
userCacheInvalidationIntervalSecsAvailable for仅适用于mongosonly.mongos。Default: 30
On a在mongosinstance, specifies the interval (in seconds) at which themongosinstance 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,如果用户对象没有变化,mongoswill not clear the cache.mongos将不会清除缓存。This parameter has a minimum value of此参数的最小值为1second and a maximum value of86400seconds (24 hours).1秒,最大值为86400秒(24小时)。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
General Parameters通用参数
allowDiskUseByDefaultAvailable for仅适用于mongodonly.mongod。Default: True
Starting in MongoDB 6.0, pipeline stages that require more than 100 megabytes of memory to execute write temporary files to disk by default. These temporary files last for the duration of the pipeline execution and can influence storage space on your instance.从MongoDB 6.0开始,默认情况下,需要超过100兆字节内存来执行将临时文件写入磁盘的流水线阶段。这些临时文件在管道执行期间持续存在,并可能影响实例上的存储空间。In earlier versions of MongoDB, you must pass在早期版本的MongoDB中,您必须将{ allowDiskUse: true }to individualfindandaggregatecommands to enable this behavior.{ allowDiskUse: true }传递给单个find和aggregate命令以启用此行为。Individual单个findandaggregatecommands can override theallowDiskUseByDefaultparameter by either:find和aggregate命令可以通过以下任一方式覆盖allowDiskUseByDefault参数:Using当{ allowDiskUse: true }to allow writing temporary files out to disk whenallowDiskUseByDefaultis set tofalseallowDiskUseByDefault设置为false时,使用{allowDiskUse:true}允许将临时文件写入磁盘Using当{ allowDiskUse: false }to prohibit writing temporary files out to disk whenallowDiskUseByDefaultis set totrueallowDiskUseByDefault设置为true时,使用{allowDiskUse:false}禁止将临时文件写入磁盘
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
mongod --setParameter allowDiskUseByDefault=falseallowDiskUseByDefaultonly works on在mongodnotmongos.mongod起作用,对mongos不起作用。mongosnever writes temporary files to disk.从不将临时文件写入磁盘。Use the在连接到正在运行的setParametercommand in amongoshsession that is connected to a runningmongodto change the value of the parameter while the server is running:mongod的mongosh会话中使用setParameter命令,在服务器运行时更改参数的值:db.adminCommand(
{
setParameter: 1,
allowDiskUseByDefault: false
}
)
connPoolMaxConnsPerHostAvailable for both适用于mongodandmongos.mongod和mongos。Default: 200
Sets the maximum size of the legacy connection pools for outgoing connections to other为全局连接池中其他mongodinstances in the global connection pool.mongod实例的传出连接设置旧连接池的最大大小。The size of a pool does not prevent the creation of additional connections, but does prevent a connection pool from retaining connections in excess of the value of池的大小不会阻止创建其他连接,但会阻止连接池保留超过connPoolMaxConnsPerHost.connPoolMaxConnsPerHost值的连接。Note
The parameter is separate from the connections in TaskExecutor pools. See该参数与TaskExecutor池中的连接是分开的。请参阅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.仅当驱动程序没有池连接并且您在分片集群的上下文中使用身份验证时,才调整此设置。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。mongod --setParameter connPoolMaxConnsPerHost=250
connPoolMaxInUseConnsPerHostAvailable for both适用于mongodandmongos.mongod和mongos。Sets the maximum number of in-use connections at any given time for for outgoing connections to other设置在任何给定时间与遗留全局连接池中其他mongodinstances in the legacy global connection pool.mongod实例的传出连接的最大使用中连接数。By default, the parameter is unset.默认情况下,该参数未设置。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。mongod --setParameter connPoolMaxInUseConnsPerHost=100
cursorTimeoutMillisAvailable for both适用于mongodandmongos.mongod和mongos。Default: 600000 (10 minutes)
Sets the expiration threshold in milliseconds for idle cursors before MongoDB removes them; specifically, MongoDB removes cursors that have been idle for the specified设置MongoDB删除空闲游标之前的过期阈值(以毫秒为单位);具体来说,MongoDB会删除指定cursorTimeoutMillis.cursorTimeoutMillis的空闲游标。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the例如,下面将cursorTimeoutMillisto300000milliseconds (5 minutes).cursorTimeoutMillis设置为300000毫秒(5分钟)。mongod --setParameter cursorTimeoutMillis=300000Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, cursorTimeoutMillis: 300000 } )Setting将cursorTimeoutMillisto less than or equal to0results in all cursors being immediately eligible for timeout.cursorTimeoutMillis设置为小于或等于0会导致所有游标立即符合超时条件。Generally, the timeout value should be greater than the average amount of time for a query to return results.通常,超时值应大于查询返回结果的平均时间。Use tools like the使用cursor.explain()cursor modifier to analyze the average query time and select an appropriate timeout period.cursor.explain()游标修饰符等工具分析平均查询时间并选择适当的超时时间。Warning
MongoDB cleans up orphaned cursors after theMongoDB仅在孤立游标未绑定到会话的情况下,才会在cursorTimeoutMillisthreshold only if they are not tied to sessions.cursorTimeoutMillis阈值后清理孤立游标。MongoDB cleans up cursors linked to sessions with theMongoDB使用localLogicalSessionTimeoutMinuteslifecycle, regardless of thecursorTimeoutMillisvalue.localLogicalSessionTimeoutMinutes生命周期清理链接到会话的游标,而不管cursorTimeoutMillis值如何。To handle long idle periods, use要处理长时间的空闲期,请使用Mongo.startSession()and refresh the session using therefreshSessionscommand.Mongo.startSession()并使用refreshSessions命令刷新会话。For details, see Refresh a Cursor with有关详细信息,请参阅使用refreshSessions.refreshSessions刷新游标。
fassertOnLockTimeoutForStepUpDownNew in version 5.3.在版本5.3中新增。Available for both适用于mongodandmongos.mongod和mongos。Default: 15 seconds
Allows a server that receives a request to step up or step down, to terminate if it is unable to comply (for example due to faulty server disks) within the timeout. This enables a cluster to successfully elect a new primary node and thus continue to be available.允许接收到升级或降级请求的服务器在超时内无法遵守(例如由于服务器磁盘故障)时终止。这使集群能够成功选择新的主节点,从而继续可用。fassertOnLockTimeoutForStepUpDowndefaults to 15 seconds.默认为15秒。To disable nodes from fasserting, set要禁用节点插入,请将fassertOnLockTimeoutForStepUpDown=0.fassertOnLockTimeoutForStepUpDown设置为0。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example disables nodes from fasserting:以下示例禁止插入节点:mongod --setParameter fassertOnLockTimeoutForStepUpDown=0
globalConnPoolIdleTimeoutMinutesAvailable for both适用于mongodandmongos.mongod和mongos。Sets the time limit that connection in the legacy global connection pool can remain idle before being closed.设置旧全局连接池中的连接在关闭前可以保持空闲的时间限制。By default, the parameter is unset.默认情况下,该参数未设置。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。mongos --setParameter globalConnPoolIdleTimeoutMinutes=10
httpVerboseLoggingAvailable for both适用于mongodandmongos.mongod和mongos。Adds more verbose tracing for curl on Linux and macOS. Has no affect on Windows.在Linux和macOS上为curl添加了更详细的跟踪。对Windows没有影响。By default, the parameter is unset.默认情况下,该参数未设置。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
mongos --setParameter httpVerboseLogging=true
indexBuildMinAvailableDiskSpaceMBNew in version 7.1.在版本7.1中新增。Available for仅适用于mongodonly.mongod。Default: 500 MB
Sets the minimum available disk space in megabytes required for index builds.设置索引构建所需的最小可用磁盘空间(MB)。Must be greater than or equal to 0 MB, and less than or equal to 8 TB. 0 disables the minimum disk space requirement.必须大于或等于0 MB,小于或等于8 TB。0禁用最小磁盘空间要求。A new index build cannot be started and a current index build is cancelled if the available disk space is below如果可用磁盘空间低于indexBuildMinAvailableDiskSpaceMB.indexBuildMinAvailableDiskSpaceMB,则无法启动新的索引生成,并取消当前的索引生成。Warning
If you increase如果增加indexBuildMinAvailableDiskSpaceMB, ensure your server has enough available disk space.indexBuildMinAvailableDiskSpaceMB,请确保服务器有足够的可用磁盘空间。Also, if you set此外,如果将indexBuildMinAvailableDiskSpaceMBtoo high, you might needlessly prevent index builds when there is enough available disk space andindexBuildMinAvailableDiskSpaceMBcould be set lower.indexBuildMinAvailableDiskSpaceMB设置得太高,当有足够的可用磁盘空间时,可能会不必要地阻止索引构建,而indexBuildMinAvailableDiskSpaceMB可以设置得更低。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets以下示例将indexBuildMinAvailableDiskSpaceMBto 650 MB:indexBuildMinAvailableDiskSpaceMB设置为650 MB:db.adminCommand( { setParameter: 1, indexBuildMinAvailableDiskSpaceMB: 650 } )You can also set您还可以在启动时设置indexBuildMinAvailableDiskSpaceMBat startup. For example:indexBuildMinAvailableDiskSpaceMB。例如:mongod --setParameter indexBuildMinAvailableDiskSpaceMB=650
indexMaxNumGeneratedKeysPerDocumentAvailable for both适用于mongodandmongos.mongod和mongos。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限制为文档生成的最大键数,以防止内存不足错误。可以提高限制,但如果操作需要的键数超过indexMaxNumGeneratedKeysPerDocumentparameter specifies, the operation will fail.indexMaxNumGeneratedKeysPerDocument参数指定的键数,则操作将失败。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
ingressAdmissionControllerTicketPoolSizeAvailable for仅适用于mongodonly.mongod。Default:
1000000Controls the maximum number of operations admitted concurrently to the ingress queue.控制入口队列同时允许的最大操作数。The default value of默认值1000000represents the numerical equivalent of unbounded, which admits all incoming operations up to the default maximum connections that MongoDB allows.1000000表示无界的数值等效值,它允许所有传入操作达到MongoDB允许的默认最大连接数。Increasing this value while there are operations waiting on the queue unblocks as many operations as the new pool size permits. Decreasing this value does not block any currently executing operations, but incoming controllable operations are blocked until there are tickets available.在队列上有操作等待时增加此值,可以在新池大小允许的情况下取消阻止尽可能多的操作。减小此值不会阻止任何当前正在执行的操作,但会阻止传入的可控操作,直到有可用的票证为止。mongod --setParameter ingressAdmissionControllerTicketPoolSize=100000Warning
Avoid modifying除非MongoDB工程师另有指示,否则避免修改ingressAdmissionControllerTicketPoolSizeunless directed by MongoDB engineers.ingressAdmissionControllerTicketPoolSize。This setting has major implications across both WiredTiger and MongoDB.此设置对WiredTiger和MongoDB都有重大影响。
ingressConnectionEstablishmentRateLimiterEnabledNew in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default:
falseDetermines whether rate limiting for new connection establishment is enabled. When enabled, MongoDB applies rate limiting to control the number of new connections that can be established per second.确定是否启用了新连接建立的速率限制。启用后,MongoDB应用速率限制来控制每秒可以建立的新连接数量。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
ingressConnectionEstablishmentRatePerSecNew in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)Available for both适用于mongodandmongos.mongod和mongos。Type: int32
Default: disabled
Minimum: 1
Specifies the maximum number of new connections that can be established per second when rate limiting is enabled.指定启用速率限制时每秒可以建立的最大新连接数。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
ingressConnectionEstablishmentBurstCapacitySecsNew in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)Available for both适用于mongodandmongos.mongod和mongos。Type: double
Default: disabled
Minimum: 1
Describes how many seconds worth of connection establishments that the server can admit before rate limiting begins.描述在速率限制开始之前,服务器可以允许多少秒的连接建立。This allows the server to handle temporary bursts of connection requests that exceed the rate limit specified by这允许服务器处理超过ingressConnectionEstablishmentRatePerSec.ingressConnectionEstablishmentRatePerSec指定的速率限制的临时连接请求。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
ingressConnectionEstablishmentMaxQueueDepthNew in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)Available for both适用于mongodandmongos.mongod和mongos。Type: int32
Default:
0(disabled)Specifies the maximum number of connection attempts in the connection establishment queue. After the queue reaches this number of connection attempts, the server rejects new connection attempts.指定连接建立队列中的最大连接尝试次数。队列达到此连接尝试次数后,服务器将拒绝新的连接尝试。The default value of默认值0means that the server rejects all connections that will queue for establishment.0表示服务器拒绝所有将排队等待建立的连接。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
ingressConnectionEstablishmentRateLimiterBypassNew in version 8.2.在版本8.2中新增。 (also available in 8.1.1 and 8.0.12)Available for both适用于mongodandmongos.mongod和mongos。Type: string array
Default:
[]Provides a list of IP addresses and CIDR ranges that the server must exempt from the connection establishment rate limits. This allows specific trusted clients to bypass rate limiting restrictions.提供服务器必须免除连接建立速率限制的IP地址和CIDR范围列表。这允许特定的受信任客户端绕过速率限制。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
maxIndexBuildMemoryUsageMegabytesAvailable for仅适用于mongodonly.mongod。Default (absolute): 200
Minimum (absolute): 50
Maximum (percent): 0.8Limits the amount of memory that simultaneous index builds on one collection may consume for their duration.限制在一个集合上同时构建索引在其持续时间内可能消耗的内存量。The specified amount of memory is shared between all indexes built using a single指定数量的内存在使用单个createIndexescommand or its shell helperdb.collection.createIndexes().createIndexes命令或其shell助手db.collection.createIndexes()构建的所有索引之间共享。Increasing the limit improves sorting performance when the index build process generates and sorts index keys.增加限制可以提高索引构建过程生成和排序索引键时的排序性能。The memory consumed by an index build is separate from the WiredTiger cache memory (see索引构建所消耗的内存与cacheSizeGB).cacheSizeGB缓存内存是分开的(请参阅cacheSizeGB)。Set this value to 0-0.8 to limit builds to a percentage of memory.将此值设置为0-0.8,以将构建限制在内存的百分比内。Set this value to 1.0 or greater to limit builds to an absolute number of megabytes.将此值设置为1.0或更大,以将构建限制为绝对兆字节数。
If this setting allocates less than 50 MB,如果此设置分配的空间小于50 MB,mongoduses a minimum of 50 MB. If the percentage setting is greater than 0.8,mongoduses a maximum of 80% of available memory.mongod将使用至少50 MB。如果百分比设置大于0.8,mongod最多使用80%的可用内存。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
maxNumActiveUserIndexBuildsAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 3
Sets the maximum number of concurrent index builds allowed on the primary. This is a global limit that applies across all collections.设置primary上允许的并发索引构建的最大数量。这是一个适用于所有集合的全局限制。Increasing the value of增加maxNumActiveUserIndexBuildsallows additional concurrent index builds at the cost of increased pressure on the WiredTiger cache.maxNumActiveUserIndexBuilds的值允许以增加WiredTiger缓存压力为代价进行额外的并发索引构建。System indexes are not limited to系统索引不限于maxNumActiveUserIndexBuilds, however a system index build counts against the limit for user index builds.maxNumActiveUserIndexBuilds,但是系统索引构建会计入用户索引构建的限制。After the server reaches服务器达到maxNumActiveUserIndexBuilds, it blocks additional user index builds until the number of concurrent index builds drops below themaxNumActiveUserIndexBuildslimit. If an index build is blocked, the server logs this message:maxNumActiveUserIndexBuilds后,它会阻止其他用户索引构建,直到并发索引构建的数量降至maxNumActiveUserIndexBuilds限制以下。如果索引构建被阻止,服务器会记录以下消息:Too many index builds running simultaneously, waiting until the
number of active index builds is below the threshold.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following command sets a limit of 4 concurrent index builds:以下命令设置了4个并发索引构建的限制:db.adminCommand( { setParameter: 1, maxNumActiveUserIndexBuilds: 4 } )See also:另请参阅:
notablescanAvailable for仅适用于mongodonly.mongod。Prevents running some collection scans when an index could be used, whether present or not.阻止在可以使用索引(无论是否存在)时运行某些集合扫描。If如果为true, MongoDB will not execute queries that require a collection scan and will return an error. Exclusions include queries without filters and queries against capped collections, such as the oplog.true,MongoDB将不会执行需要集合扫描的查询,并将返回错误。排除项包括没有筛选器的查询和对有上限的集合(如oplog)的查询。Consider the following example which sets考虑以下将notablescantotrueor true:notablescan设置为true或true的示例:db.adminCommand( { setParameter: 1, notablescan: true } )Setting将notablescantotruecan be useful for testing application queries, for example, to identify queries that scan an entire collection and cannot use an index.notablescan设置为true对于测试应用程序查询非常有用,例如,识别扫描整个集合但不能使用索引的查询。To detect unindexed queries without要在不使用notablescan, consider reading the Analyze Query Performance section and using thelogLevelparameter,mongostatand profiling.notablescan的情况下检测未索引的查询,请考虑阅读“分析查询性能”部分,并使用logLevel参数、mongostat和分析。Don't run production不要使用mongodinstances withnotablescanbecause preventing collection scans can potentially affect queries in all databases, including administrative queries.notablescan运行生产mongod实例,因为阻止集合扫描可能会影响所有数据库中的查询,包括管理查询。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Note
notablescandoes not allow unbounded queries that use a clustered index because the queries require a full collection scan.notablescan不允许使用聚集索引的无界查询,因为这些查询需要进行完整的集合扫描。For more information, see Collection Scans.有关详细信息,请参阅集合扫描。
reportOpWriteConcernCountersInServerStatusAvailable for仅适用于mongodonly.mongod。Default: false
A boolean flag that determines whether the一个布尔标志,用于确定db.serverStatus()method andserverStatuscommand returnopWriteConcernCountersinformation.db.serverStatus()方法和serverStatus命令是否返回opWriteConcernCounters信息。[1]mongod --setParameter reportOpWriteConcernCountersInServerStatus=true[1] Enabling启用reportOpWriteConcernCountersInServerStatuscan have a negative performance impact; specifically, when running without TLS.reportOpWriteConcernCountersInServerStatus可能会对性能产生负面影响;特别是在没有TLS的情况下运行时。
slowConnectionThresholdMillisNew in version 6.3.在版本6.3中新增。Available for both适用于mongodandmongos.mongod和mongos。Default: 100
Sets the time limit in milliseconds to log the establishment of slow server connections.设置记录慢速服务器连接建立的时间限制(以毫秒为单位)。If a connection takes longer to establish than the如果建立连接所需的时间比slowConnectionThresholdMillisparameter, an event is added to the log with the messagemsgfield set to"Slow connection establishment".slowConnectionThresholdMillis参数长,则会在日志中添加一个事件,并将消息msg字段设置为"Slow connection establishment"(慢速连接建立)。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets以下示例将slowConnectionThresholdMillisto250milliseconds.slowConnectionThresholdMillis设置为250毫秒。mongod --setParameter slowConnectionThresholdMillis=250Or, if using the或者,如果在setParametercommand withinmongosh:mongosh中使用setParameter命令:db.adminCommand( { setParameter: 1, slowConnectionThresholdMillis: 250 } )
Warning
tcmallocAggressiveMemoryDecommit is deprecated in 8.0. MongoDB 8.0 uses an updated version of tcmalloc that improves memory fragmentation and management. See tcmalloc upgrade for more information. tcmallocAggressiveVemoryDecommit在8.0中已被弃用。MongoDB 8.0使用tcmalloc的更新版本,改进了内存分片和管理。有关更多信息,请参阅tcmalloc升级。To release memory back to the operating system, consider using 要将内存释放回操作系统,请考虑改用tcmallocEnableBackgroundThread instead.tcmallocEnableBackgroundThread。
tcmallocEnableBackgroundThreadAvailable for both适用于mongodandmongos.mongod和mongos。New in version 8.0.在版本8.0中新增。Type: boolean
Default: true
If set to如果设置为true,tcmallocEnableBackgroundThreadcreates a background thread that periodically releases memory back to the operating system.true,tcmallocEnableBackgroundThread将创建一个后台线程,定期将内存释放回操作系统。The value oftcmallocReleaseRatedetermines the rate, in bytes per second, at which the background thread releases memory.tcmallocReleaseRate的值决定了后台线程释放内存的速率,单位为字节每秒。Note
If如果tcmallocEnableBackgroundThreadistrueandtcmallocReleaseRateis0, MongoDB still releases memory.tcmallocEnableBackgroundThread为true,tcmallocReleaseRate为0,MongoDB仍会释放内存。For improved memory usage, we recommend using the default value of为了提高内存使用率,我们建议使用默认值true. To learn more about improvements to performance and memory management, see Upgraded TCMalloc.true。要了解有关性能和内存管理改进的更多信息,请参阅升级的TCMalloc。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。The following operation sets以下操作将tcmallocEnableBackgroundThreadtofalse:tcmallocEnableBackgroundThread设置为false:mongod --setParameter "tcmallocEnableBackgroundThread=false"
tcmallocReleaseRateAvailable for both适用于mongodandmongos.mongod和mongos。Changed in version 8.0.在版本8.0中的更改。Default: 0
Specifies the TCMalloc release rate in bytes per second. Release rate refers to the rate at which MongoDB releases unused memory to the system.指定TCMalloc释放速率,单位为字节每秒。释放速率是指MongoDB向系统释放未使用内存的速率。If如果tcmallocReleaseRateis set to0MongoDB doesn't release memory back to the system. Increase this value to return memory faster; decrease it to return memory slower.tcmallocReleaseRate设置为0,MongoDB不会将内存释放回系统。增加此值可更快地返回内存;减小它以更慢地返回内存。Note
If如果tcmallocEnableBackgroundThreadistrueandtcmallocReleaseRateis0, MongoDB still releases memory.tcmallocEnableBackgroundThread为true,tcmallocReleaseRate为0,MongoDB仍会释放内存。Starting in MongoDB 8.0, the default value of从MongoDB 8.0开始,由于tcmalloc升级优先考虑CPU性能而非内存释放,tcmallocReleaseRateis reduced to0due to a tcmalloc upgrade that prioritizes CPU performance over memory release.tcmallocReleaseRate的默认值降低为0。In earlier versions, MongoDB used an older version of在早期版本中,MongoDB使用了tcmallocthat:tcmalloc的旧版本,该版本:Set the default将默认tcmallocReleaseRateto1.tcmallocReleaseRate设置为1。Accepted values fortcmallocReleaseRatebetween0and10, inclusive.tcmallocReleaseRate的接受值介于0和10之间(包括0和10)。
Important
If you run MongoDB on a platform that uses如果你在使用tcmalloc-gperfsuch as Windows, PPC, or s390x,tcmallocReleaseRatehas the same behavior as earlier MongoDB versions.tcmalloc-gperf的平台上运行MongoDB,如Windows、PPC或s390x,tcmallocReleaseRate的行为与早期的MongoDB版本相同。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
To modify the release rate during run time, you can use the要在运行时修改释放速率,可以使用setParametercommand. For example:setParameter命令。例如:db.adminCommand( { setParameter: 1, tcmallocReleaseRate: 2097152 } )You can also set您还可以在启动时设置tcmallocReleaseRateat startup time; for example:tcmallocReleaseRate;例如:mongod --setParameter "tcmallocReleaseRate=2097152"
tcpFastOpenClientAvailable for both适用于mongodandmongos.mongod和mongos。Default:
trueLinux Operating System Only
Enables support for outbound TCP Fast Open (TFO) connections from the支持从mongod/mongosto a client. TFO requires both the client and themongod/mongoshost machine support and enable TFO.mongod/mongos到客户端的出站TCP快速开放(TFO)连接。TFO需要客户端和mongod/mongos主机的支持,并启用TFO。Linux operating systems running Linux Kernel 4.11 or later can support outbound TFO.运行Linux Kernel 4.11或更高版本的Linux操作系统可以支持出站TFO。Set the value of设置/proc/sys/net/ipv4/tcp_fastopento enable outbound TFO connections:/proc/sys/net/ipv4/tcp_fastopen的值以启用出站TFO连接:1to enable only outbound TFO connections.仅启用出站TFO连接。3to enable inbound and outbound TFO connections.以启用入站和出站TFO连接。
This parameter has no effect if the host operating system does not support or is not configured to support TFO connections.如果主机操作系统不支持或未配置为支持TFO连接,则此参数无效。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。Tip
tcpFastOpenQueueSizeAvailable for both适用于mongodandmongos.mongod和mongos。Default:
1024As part of establishing a TCP Fast Open (TFO) connection, the client submits a valid TFO cookie to the作为建立TCP快速开放(TFO)连接的一部分,客户端在完成标准TCP三次握手之前向mongod/mongosbefore completion of the standard TCP 3-way handshake.mongod/mongos提交一个有效的TFO cookie。Themongod/mongoskeeps a queue of all such pending TFO connections.mongod/mongos保留了一个所有此类未决TFO连接的队列。ThetcpFastOpenQueueSizeparameter sets the size of the queue of pending TFO connections.tcpFastOpenQueueSize参数设置挂起的TFO连接的队列大小。While the queue is full, the当队列已满时,mongod/mongosfalls 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/mongosbegins accepting new TFO cookies.mongod/mongos就开始接受新的TFO Cookie。Increasing the default queue size may improve the effect of TFO on network performance. However, large queue sizes also increase the risk of server resource exhaustion due to excessive incoming TFO requests.增加默认队列大小可能会改善TFO对网络性能的影响。但是,由于传入的TFO请求过多,较大的队列大小也会增加服务器资源耗尽的风险。Decreasing the default queue size may reduce the risk of resource server resource exhaustion due to excessive incoming TFO requests. However, small queue sizes may also reduce the effect of TFO on network performance.减小默认队列大小可以降低由于传入TFO请求过多而导致的资源服务器资源耗尽的风险。然而,较小的队列大小也可能降低TFO对网络性能的影响。The minimum queue size is最小队列大小为0. A queue of0effectively disables TFO.0。0的队列有效地禁用了TFO。
This parameter has no effect on host operating systems that do not support or are not configured for TFO connections.此参数对不支持或未配置TFO连接的主机操作系统没有影响。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
tcpFastOpenServerAvailable for both适用于mongodandmongos.mongod和mongos。Default:
trueEnables support for accepting inbound TCP Fast Open (TFO) connections to the支持从客户端接受到mongod/mongosfrom a client. TFO requires both the client andmongod/mongoshost machine support and enable TFO:mongod/mongos的入站TCP快速开放(TFO)连接。TFO需要客户端和mongod/mongos主机支持,并启用TFO:- Windows
The following Windows operating systems support TFO:以下Windows操作系统支持TFO:Microsoft Windows Server 2016 and later.微软Windows Server 2016及更高版本。Microsoft Windows 10 Update 1607 and later.Microsoft Windows 10 Update 1607及更高版本。
- macOS
- macOS 10.11 (El Capitan) and later support TFO.
- Linux
Linux operating systems running Linux Kernel 3.7 or later can support inbound TFO.运行Linux Kernel 3.7或更高版本的Linux操作系统可以支持入站TFO。Set the value of设置/proc/sys/net/ipv4/tcp_fastopento enable inbound TFO connections:/proc/sys/net/ipv4/tcp_fastopen的值以启用入站TFO连接:Set to设置为2to enable only inbound TFO connections.2以仅启用入站TFO连接。Set to设置为3to enable inbound and outbound TFO connections.3以启用入站和出站TFO连接。
This parameter has no effect if the host operating system does not support or is not configured to support TFO connections.如果主机操作系统不支持或未配置为支持TFO连接,则此参数无效。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。Tip
ttlMonitorEnabledAvailable for仅适用于mongodonly.mongod。Default:
trueTo support TTL Indexes,为了支持TTL索引,mongodinstances have a background thread that is responsible for deleting documents from collections with TTL indexes.mongod实例有一个后台线程,负责从具有TTL索引的集合中删除文档。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
To disable this worker thread for a要为mongod, setttlMonitorEnabledtofalse, 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或者,您可以在启动时禁用线程,方法是使用以下选项启动mongodinstance with the following option:mongod实例:mongod --setParameter ttlMonitorEnabled=falseImportant
Do not run production除非在MongoDB支持的指导下,否则不要在禁用mongodinstances withttlMonitorEnableddisabled, except under guidance from MongoDB support. Preventing TTL document removal can negatively impact MongoDB internal system operations that depend on TTL Indexes.ttlMonitorEnabled的情况下运行生产mongod实例。阻止TTL文档删除可能会对依赖TTL索引的MongoDB内部系统操作产生负面影响。
watchdogPeriodSecondsAvailable for仅适用于mongodonly.mongod。Type: integer
Default: -1 (disabled)
Determines how frequent the Storage Node Watchdog checks the status of the monitored filesystems:确定存储节点监视器检查受监视文件系统状态的频率:The--dbpathdirectory--dbpath目录Thejournaldirectory inside the--dbpathdirectory--dbpath目录中的journal目录The directory of--logpathfile--logpath文件的目录The directory of--auditPathfile--auditPath文件的目录
Valid values forwatchdogPeriodSecondsare:watchdogPeriodSeconds的有效值为:-1(the default), to disable/pause Storage Node Watchdog, or(默认),禁用/暂停存储节点监视器,或An integer greater than or equal to 60.大于或等于60的整数。
Note
If a filesystem on a monitored directory becomes unresponsive, it can take a maximum of nearly twice the value of如果受监视目录上的文件系统变得没有响应,则最多需要watchdogPeriodSecondsto terminate themongod.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例如,如果mongodusesstorage.directoryPerDB: true(or--directoryperdb) and symlinks a database directory to another volume, the Storage Node Watchdog does not follow the symlink to monitor the target.mongod使用storage.directoryPerDB: true(或--directoryperdb)并将数据库目录符号链接到另一个卷,则存储节点监视器不会遵循符号链接来监视目标。
To enable Storage Node Watchdog,要启用存储节点监视器,必须在启动期间设置watchdogPeriodSecondsmust be set during startup.watchdogPeriodSeconds。mongod --setParameter watchdogPeriodSeconds=60You can only enable the Storage Node Watchdog at startup.您只能在启动时启用存储节点监视器。However, once enabled, you can pause the Storage Node Watchdog or change the但是,一旦启用,您可以在运行时暂停存储节点监视器或更改watchdogPeriodSecondsduring run time.watchdogPeriodSeconds。Once enabled,一旦启用,To pause the Storage Node Watchdog during run time, set要在运行时暂停存储节点监视器,请将watchdogPeriodSecondsto -1.watchdogPeriodSeconds设置为-1。db.adminCommand( { setParameter: 1, watchdogPeriodSeconds: -1 } )To resume or change the period during run time, set要在运行时恢复或更改周期,请将watchdogPeriodSecondsto a number greater than or equal to 60.watchdogPeriodSeconds设置为大于或等于60的数字。db.adminCommand( { setParameter: 1, watchdogPeriodSeconds: 120 } )
Note
It is an error to set如果启动时未启用存储节点监视器,则在运行时设置watchdogPeriodSecondsat run time if the Storage Node Watchdog was not enabled at startup time.watchdogPeriodSeconds是错误的。
Logging Parameters测井参数
enableDetailedConnectionHealthMetricLogLinesNew in version 7.0.在版本7.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: true
Determines whether to enable specific log messages related to cluster connection health metrics.确定是否启用与群集连接健康指标相关的特定日志消息。If如果enableDetailedConnectionHealthMetricLogLinesis set tofalse, the following log messages are turned off, but MongoDB still collects data on the cluster connection health metrics:enableDetailedConnectionHealthMetricLogLines设置为false,则以下日志消息将被关闭,但MongoDB仍会集合集群连接健康指标的数据:Log Message日志消息Description描述Accepted TLS connection from peer接受来自对等端的TLS连接Indicates that the server successfully parsed the peer certificate during the TLS handshake with an accepted ingress connection.表示服务器在与接受的入口连接进行TLS握手期间成功解析了对等端证书。Ingress TLS handshake complete入口TLS握手完成Indicates that the TLS handshake with an ingress connection is complete.表示与入口连接的TLS握手已完成。Hello completed你好,已完成Indicates that the initial connection handshake completed on an incoming client connection.表示在传入的客户端连接上完成了初始连接握手。MongoDB displays the log message only with the firstMongoDB仅使用第一个hellocommand.hello命令显示日志消息。Auth metrics report认证指标报告Specifies the completion of a step in the authentication conversation.指定身份验证对话中某个步骤的完成。Received first command on ingress connection since session start or auth handshake自会话启动或身份验证握手以来,在入口连接上收到第一个命令Indicates that an ingress connection received the first command that is not part of the handshake.表示入口连接接收到的第一个命令不是握手的一部分。Slow network response send time网络响应发送时间慢Indicates that the time spent, in milliseconds, to send the response back to the client over an ingress connection takes more time than the duration defined by the表示通过入口连接将响应发送回客户端所花费的时间(以毫秒为单位)比slowMSserver parameter.slowMS服务器参数定义的持续时间更长。Completed client-side verification of OCSP request已完成OCSP请求的客户端验证If the peer doesn't include an OCSP response to the TLS handshake when an egress TLS connection is established, the server must send an OCSP request to the certificate authority.如果在建立出口TLS连接时,对等端没有包含对TLS握手的OCSP响应,则服务器必须向证书颁发机构发送OCSP请求。MongoDB writes this log message when the certificate authority receives the OCSP response.当证书颁发机构收到OCSP响应时,MongoDB会写入此日志消息。Slow connection establishment连接建立缓慢Indicates that the time taken to send a response back to the client over an ingress connection takes longer than the threshold specified with the表示通过入口连接将响应发送回客户端所花费的时间长于使用slowConnectionThresholdMillisparameter. MongoDB also emits this log message when the connection establishment times out.slowConnectionThresholdMillis参数指定的阈值。当连接建立超时时,MongoDB也会发出此日志消息。Operation timed out while waiting to acquire connection等待获取连接时操作超时Indicates that an operation timed out while waiting to acquire an egress connection.表示在等待获取出口连接时操作超时。Acquired connection for remote operation and completed writing to wire已获取远程操作连接,并已完成对线路的写入Indicates that the server took one millisecond or longer to write an outgoing request on an egress connection, counting from the instant when the connection establishes.表示服务器在出口连接上写入传出请求需要一毫秒或更长时间,从连接建立的时刻开始计算。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
logComponentVerbosityAvailable for both适用于mongodandmongos.mongod和mongos。Default: 0
Sets the verbosity levels of various components for log messages. The verbosity level determines the amount of Informational and Debug messages MongoDB outputs.设置日志消息的各种组件的详细程度。详细程度决定了MongoDB输出的信息和调试消息的数量。[2]The verbosity level can range from详细程度可以从0to5:0到5:0是MongoDB的默认日志详细级别,用于包含信息消息。0is the MongoDB's default log verbosity level, to include Informational messages.1to5increases the verbosity level to include Debug messages.1到5会增加详细程度,以包含调试消息。
For a component, you can also specify对于组件,您还可以指定-1to 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顶级verbosityfield corresponds tosystemLog.verbositywhich sets the default level for all components.verbosity字段对应于systemLog.verbosity,它为所有组件设置默认级别。The default value ofsystemLog.verbosityis0.systemLog.verbosity的默认值为0。The components correspond to the following settings:这些组件对应于以下设置:accessControlassertcommandcontrolftdcgeoindexnetworkqueryquery.rejectedqueryStatsreplicationreplication.electionreplication.heartbeatsreplication.initialSyncreplication.rollbackrecoveryshardingstoragestorage.journaltransactionwrite
Unless explicitly set, the component has the verbosity level of its parent.除非明确设置,否则组件具有其父级的详细程度。For example,例如,storageis the parent ofstorage.journal.storage是storage.journal的父级。That is, if you specify a也就是说,如果指定了storageverbosity level, this level also applies to:storage详细程度级别,则该级别也适用于:storage.journalcomponents unless you specify the verbosity level forstorage.journal.storage.recoverycomponents unless you specify the verbosity level forstorage.recovery.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the
default verbosity levelto1, thequeryto2, thestorageto2, and thestorage.journalto1.db.adminCommand( {
setParameter: 1,
logComponentVerbosity: {
verbosity: 1,
query: { verbosity: 2 },
storage: {
verbosity: 2,
journal: {
verbosity: 1
}
}
}
} )You can also set parameter您还可以在启动时设置参数logComponentVerbosityat startup time, passing the verbosity level document as a string.logComponentVerbosity,将详细程度级别文档作为字符串传递。mongod --setParameter "logComponentVerbosity={command: 3}"mongoshalso provides thedb.setLogLevel()to set the log level for a single component. For various ways to set the log verbosity level, see Configure Log Verbosity Levels.[2] Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. For example, if the verbosity level is 2, MongoDB logs D2. In previous versions, MongoDB log messages only specifiedDfor Debug level.
logLevelAvailable for both适用于mongodandmongos.mongod和mongos。Default: 0 (informational)
Specify an integer between指定一个介于0and5signifying the verbosity of the logging, where5is the most verbose.0和5之间的整数,表示日志的详细程度,其中5是最详细的。[3]This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets the
logLevelto2:db.adminCommand( { setParameter: 1, logLevel: 2 } )[3] Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages.从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs例如,如果详细程度为2,MongoDB会记录D2. In previous versions, MongoDB log messages only specifiedDfor Debug level.D2。在以前的版本中,MongoDB日志消息仅将调试级别指定为D。
maxLogSizeKBAvailable for both适用于mongodandmongos.mongod和mongos。Type: non-negative integer
Default: 10
Specifies the maximum size, in kilobytes, for an individual attribute field in a log entry; attributes exceeding this limit are truncated.指定日志条目中单个属性字段的最大大小(以千字节为单位);超过此限制的属性将被截断。Truncated attribute fields print field content up to the截断的属性字段打印的字段内容不超过maxLogSizeKBlimit and excise field content past that limit, retaining valid JSON formatting.maxLogSizeKB限制,并删除超过该限制的字段内容,保留有效的JSON格式。Log entries that contain truncated attributes append a包含截断属性的日志条目将truncatedobject to the end of the log entry.truncated(截断)对象附加到日志条目的末尾。See log message truncation for more information.有关详细信息,请参阅日志消息截断。A value of值为0disables truncation entirely. Negative values for this parameter are not valid.0时完全禁用截断。此参数的负值无效。Warning
Using a large value, or disabling truncation with a value of使用大值或禁用值为0, may adversely affect system performance and negatively impact database operations.0的截断可能会对系统性能产生不利影响,并对数据库操作产生负面影响。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets the maximum log line size to以下示例将最大日志行大小设置为20kilobytes:20KB:mongod --setParameter maxLogSizeKB=20
quietAvailable for both适用于mongodandmongos.mongod和mongos。Sets quiet logging mode. If设置安静日志记录模式。如果为1,mongodwill go into a quiet logging mode which will not log the following events/activities:1,mongod将进入安静日志模式,不会记录以下事件/活动:connection events;连接事件;thedropcommand, thedropIndexescommand, thevalidatecommand; anddrop命令、dropIndexes命令、validate命令;和replication synchronization activities.复制同步活动。
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Consider the following example which sets the考虑以下将quietparameter to1:quiet参数设置为1的示例:db.adminCommand( { setParameter: 1, quiet: 1 } )Tip
redactClientLogDataAvailable for both适用于mongodandmongos.mongod和mongos。Type: boolean
Note
Enterprise Feature
Available in MongoDB Enterprise only.仅适用于MongoDB企业版。Configure the
mongodormongosto redact any message accompanying a given log event before logging. This prevents the program from writing potentially sensitive data stored on the database to the diagnostic log. Metadata such as error or operation codes, line numbers, and source file names are still visible in the logs.Use
redactClientLogDatain conjunction with Encryption at Rest and TLS/SSL (Transport Encryption) to assist compliance with regulatory requirements.To enable log redaction at startup, you can either:
Start
mongodwith the--redactClientLogDataoption:mongod --redactClientLogDataSet the
security.redactClientLogDataoption in the configuration file:security:
redactClientLogData: true
...
You can't use the
--setParameteroption to setredactClientLogDataat startup.To enable log redaction on a running
mongodormongos, use the following command:db.adminCommand( { setParameter: 1, redactClientLogData : true } )
redactEncryptedFieldsNew in version 6.1.0.在版本6.1.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default:
trueConfigures
mongodandmongosto redact field values of encryptedBinarydata from all log messages.- If the
redactClientLogDataparameter or thesecurity.redactClientLogDatasetting is set tofalseandredactEncryptedFieldsis set totrue(the default), encrypted fields are redacted from all log messages. - If the
redactClientLogDataparameter orsecurity.redactClientLogDatasetting is set totrue, all fields are redacted, regardless of theredactEncryptedFieldssetting.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
- If the
suppressNoTLSPeerCertificateWarningAvailable for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: false
By default, a
mongodormongoswith TLS/SSL enabled andnet.ssl.allowConnectionsWithoutCertificates:truelets clients connect without providing a certificate for validation while logging an warning. SetsuppressNoTLSPeerCertificateWarningto1ortrueto suppress those warnings.This parameter is only available at startup. To set the parameter, use the
setParametersetting.The following operation sets
suppressNoTLSPeerCertificateWarningtotrue:db.adminCommand( { setParameter: 1, suppressNoTLSPeerCertificateWarning: true} )
traceExceptionsAvailable for both适用于mongodandmongos.mongod和mongos。Configures
mongodto log full source code stack traces for every database and socket C++ exception, for use with debugging. Iftrue,mongodwill log full stack traces.This parameter is only available at runtime. To set the parameter, use thesetParametercommand.setParameterConsider the following example which sets the
traceExceptionstotrue:db.adminCommand( { setParameter: 1, traceExceptions: true } )
Diagnostic Parameters
To facilitate analysis of the MongoDB server behavior by MongoDB engineers, MongoDB logs server statistics to diagnostic files at periodic intervals.
For mongod, the diagnostic data files are stored in the diagnostic.data directory under the mongod instance's --dbpath or storage.dbPath.
For mongos, the diagnostic data files, by default, are stored in a directory under the mongos instance's --logpath or systemLog.path directory. The diagnostic data directory is computed by truncating the logpath's file extension(s) and concatenating diagnostic.data to the remaining name.
For example, if mongos has --logpath /var/log/mongodb/mongos.log.201708015, then the diagnostic data directory is /var/log/mongodb/mongos.diagnostic.data/ directory. To specify a different diagnostic data directory for mongos, set the diagnosticDataCollectionDirectoryPath parameter.
The following parameters support diagnostic data capture (FTDC):
Note
The default values for the diagnostic data capture interval and the maximum sizes are chosen to provide useful data to MongoDB engineers with minimal impact on performance and storage size. Typically, these values will only need modifications as requested by MongoDB engineers for specific diagnostic purposes.
diagnosticDataCollectionDirectoryPathAvailable for仅适用于mongosonly.mongos。Type: String
Warning
If Full Time Diagnostic Data Capture (FTDC) is disabled with
diagnosticDataCollectionEnabledor ifsystemLog.destinationis set tosyslog, you must restartmongosafter settingdiagnosticDataCollectionDirectoryPath.Specify the directory for the diagnostic directory for
mongos. If the directory does not exist,mongoscreates the directory.If unspecified, the diagnostic data directory is computed by truncating the
mongosinstance's--logpathorsystemLog.pathfile extension(s) and concatenatingdiagnostic.data.For example, if
mongoshas--logpath /var/log/mongodb/mongos.log.201708015, then the diagnostic data directory is/var/log/mongodb/mongos.diagnostic.data/.If the
mongoscannot create the specified directory, the diagnostic data capture is disabled for that instance.mongosmay not be able to create the specified directory if a file with the same name already exists in the path or if the process does not have permissions to create the directory.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
diagnosticDataCollectionDirectorySizeMBAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default:
250(500in sharded clusters)Specifies the maximum size, in megabytes, of the
diagnostic.datadirectory. If directory size exceeds this number, the oldest diagnostic files in the directory are automatically deleted based on the timestamp in the file name.Changed in version 8.0.在版本8.0中的更改。diagnosticDataCollectionDirectorySizeMBhas a default value of 400 MB formongosandmongodinstances used in sharded clusters.mongodinstances used in replica set or as standalone servers have a default value of 200 MB.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the maximum size of the directory to
250megabytes:mongod --setParameter diagnosticDataCollectionDirectorySizeMB=250The minimum value for
diagnosticDataCollectionDirectorySizeMBis10megabytes.diagnosticDataCollectionDirectorySizeMBmust be greater than maximum diagnostic file sizediagnosticDataCollectionFileSizeMB.
diagnosticDataCollectionEnabledAvailable for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: true
Determines whether to enable the collecting and logging of data for diagnostic purposes. Diagnostic logging is enabled by default.确定是否启用用于诊断目的的数据集合和记录。默认情况下启用诊断日志记录。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following disables the diagnostic collection:
mongod --setParameter diagnosticDataCollectionEnabled=false
diagnosticDataCollectionFileSizeMBAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 10
Specifies the maximum size, in megabytes, of each diagnostic file. If the file exceeds the maximum file size, MongoDB creates a new file.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the maximum size of each diagnostic file to
20megabytes:mongod --setParameter diagnosticDataCollectionFileSizeMB=20The minimum value for
diagnosticDataCollectionFileSizeMBis1megabyte.
diagnosticDataCollectionPeriodMillisAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 1000
Specifies the interval, in milliseconds, at which to collect diagnostic data.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, the following sets the interval to
5000milliseconds or 5 seconds:mongod --setParameter diagnosticDataCollectionPeriodMillis=5000The minimum value for
diagnosticDataCollectionPeriodMillisis100milliseconds.
Replication and Consistency
allowMultipleArbitersNew in version 5.3.在版本5.3中新增。Available for仅适用于mongodonly.mongod。Type: boolean
Default: false
Specifies whether the replica set allows the use of multiple arbiters.
The use of multiple arbiters is not recommended:
- Multiple arbiters prevent the reliable use of the majority write concern. MongoDB counts arbiters in calculating a membership majority, but arbiters do not store data. With the inclusion of multiple arbiters, it's possible for a majority write operation to return success before the write replicates to a majority of data bearing nodes.
- Multiple arbiters allow replica sets to accept writes even when the replica set doesn't have sufficient secondaries for data replication.
For more information, see Concerns with Multiple Arbiters.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.mongod --setParameter allowMultipleArbiters=true
connectTimeoutMsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 10000
Sets the connection timeout, in milliseconds, for the replica set monitor.
This parameter is only available at startup. If you set this parameter, it must be greater than or equal to 500.
The following example sets
connectTimeoutMsfor amongodinstance to 700 milliseconds:mongod --setParameter connectTimeoutMs=700
createRollbackDataFilesAvailable for仅适用于mongodonly.mongod。Type: boolean
Default: true
Flag that determines whether MongoDB creates rollback files that contains documents affected during a rollback.
By default,
createRollbackDataFilesistrueand MongoDB creates the rollback files.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
createRollbackDataFilesto false so that the rollback files are not created:mongod --setParameter createRollbackDataFiles=falseDuring run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, createRollbackDataFiles: false } )For more information, see Collect Rollback Data.
disableSplitHorizonIPCheckNew in version 5.0.0.在版本5.0.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: false
To configure cluster nodes for split horizon DNS, use host names instead of IP addresses.
Starting in MongoDB v5.0,
replSetInitiateandreplSetReconfigreject configurations that use IP addresses instead of hostnames.Use
disableSplitHorizonIPCheckto modify nodes that cannot be updated to use host names. The parameter only applies to the configuration commands.mongodandmongosdo not rely ondisableSplitHorizonIPCheckfor validation at startup. Legacymongodandmongosinstances that use IP addresses instead of host names can start after an upgrade.Instances that are configured with IP addresses log a warning to use host names instead of IP addresses.
To allow configuration changes using IP addresses, set
disableSplitHorizonIPCheck=trueusing the command line:/usr/local/bin/mongod --setParameter disableSplitHorizonIPCheck=true -f /etc/mongod.confThis parameter is only available at startup. To set the parameter, use the
setParametersetting.setParameter:
disableSplitHorizonIPCheck: true
enableFlowControlAvailable for both适用于mongodandmongos.mongod和mongos。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 committedlag under a configurable maximum value.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
enableOverrideClusterChainingSettingNew in version 5.0.2.在版本5.0.2中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: false
If
enableOverrideClusterChainingSettingistrue, replica set secondary members can replicate data from other secondary members even ifsettings.chainingAllowedisfalse.This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the
enableOverrideClusterChainingSettingfor amongodinstance totrue:mongod --setParameter enableOverrideClusterChainingSetting=true
flowControlTargetLagSecondsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 10
The target maximum
majority committedlag when running with flow control. When flow control is enabled, the mechanism attempts to keep themajority committedlag under the specified seconds. The parameter has no effect if flow control is disabled.The specified value must be greater than 0.
In general, the default settings should suffice; however, if modifying from the default value, decreasing, rather than increasing, the value may prove to be more useful.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
flowControlWarnThresholdSecondsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 10
The amount of time to wait to log a warning once the flow control mechanism detects the majority commit point has not moved.
The specified value must be greater than or equal to 0, with 0 to disable warnings.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
heartBeatFrequencyMsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 10000
When
replicaSetMonitorProtocolis set to'sdam',heartBeatFrequencyMsdetermines how long, in milliseconds, to wait betweenhellorequests.When
replicaSetMonitorProtocolis set to'streamable',heartBeatFrequencyMsdetermines how long, in milliseconds, to wait betweenhelloround trip time (RTT) measurements. RTT measurements are used in server selection.This parameter is only available at startup. If you set this parameter, it must be greater than or equal to 500.
The following example sets
heartBeatFrequencyMsin amongodinstance to 700 milliseconds:mongod --setParameter heartBeatFrequencyMs=700
initialSyncIndexBuildMemoryPercentageNew in version 8.2.在版本8.2中新增。Available for仅适用于mongodonly.mongod。Type: double
Default: 10.0
The percentage of system memory that MongoDB allocates for index builds during initial sync. The amount of system memory used is bound by the values of
initialSyncIndexBuildMemoryMinMBandinitialSyncIndexBuildMemoryMaxMB.You can specify a value between
0.0and80.0, inclusive.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set the
initialSyncIndexBuildMemoryPercentagefor amongodinstance to 40%:mongod --setParameter initialSyncIndexBuildMemoryPercentage=40
initialSyncIndexBuildMemoryMaxMBNew in version 8.2.在版本8.2中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 16384
The maximum amount of system memory, in megabytes, that MongoDB can use for index builds during initial sync.
You can specify a value between
50and10000000.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set the
initialSyncIndexBuildMemoryMaxMBfor amongodinstance to 20000 MB:mongod --setParameter initialSyncIndexBuildMemoryMaxMB=20000
initialSyncIndexBuildMemoryMinMBNew in version 8.2.在版本8.2中新增。Available for仅适用于mongodonly.mongod。Type: Integer
Default: 200
The minimum amount of system memory, in megabytes, that MongoDB can use for index builds during initial sync.
You can specify a value between
50and10000000.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set the
initialSyncIndexBuildMemoryMinMBfor amongodinstance to 60 MB:mongod --setParameter initialSyncIndexBuildMemoryMinMB=60
initialSyncMethodNew in version 5.2.在版本5.2中新增。Available for仅适用于mongodonly.mongod。Type: String
Default:
logicalAvailable only in MongoDB Enterprise.
Method used for initial sync.
Set to
logicalto use logical initial sync. Set tofileCopyBasedto use file copy based initial sync.This parameter only affects the sync method for the member on which it is specified. Setting this parameter on a single replica set member does not affect the sync method of any other replica set members.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.
initialSyncSourceReadPreferenceAvailable for仅适用于mongodonly.mongod。Type: String
The preferred source for performing initial sync. Specify one of the following read preference modes:
primaryprimaryPreferred(Default for voting replica set members)secondarysecondaryPreferrednearest(Default for newly added or non-voting replica set members)
If the replica set has disabled
chaining, the defaultinitialSyncSourceReadPreferenceread preference mode isprimary.You cannot specify a tag set or
maxStalenessSecondstoinitialSyncSourceReadPreference.If the
mongodcannot find a sync source based on the specified read preference, it logs an error and restarts the initial sync process. Themongodexits with an error if it cannot complete the initial sync process after10attempts. For more information on sync source selection, see Initial Sync Source Selection.initialSyncSourceReadPreferencetakes precedence over the replica set'ssettings.chainingAllowedsetting when selecting an initial sync source. After a replica set member successfully completes initial sync, it defers to the value ofchainingAllowedwhen selecting a replication sync source.This parameter is only available at startup. To set the parameter, use the
setParametersetting.
initialSyncTransientErrorRetryPeriodSecondsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 86400
The amount of time in seconds a secondary performing initial sync attempts to resume the process if interrupted by a transient network error. The default value is equivalent to 24 hours.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
localLogicalSessionTimeoutMinutesAvailable for both适用于mongodandmongos.mongod和mongos。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
refreshSessionswithin this threshold are cleared from the cache. State associated with an expired session may be cleaned up by the server at any time.This parameter applies only to the instance on which it is set. To set this parameter on replica sets and sharded clusters, you must specify the same value on every member; otherwise, sessions will not function properly.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the
localLogicalSessionTimeoutMinutesfor a testmongodinstance to 20 minutes:mongod --setParameter localLogicalSessionTimeoutMinutes=20
localThresholdMsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 15
Defines the length of the latency window used in server selection in milliseconds.
This parameter is only available at startup. If you set this parameter, it must be greater than or equal to 0.
The following example sets
localThresholdMsfor amongodinstance to 20 milliseconds:mongod --setParameter localThresholdMs=20
logicalSessionRefreshMillisAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 300000 (5 minutes)
The interval (in milliseconds) at which the cache refreshes its logical session records against the main session store.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the
logicalSessionRefreshMillisfor amongodinstance to 10 minutes:mongod --setParameter logicalSessionRefreshMillis=600000
maxAcceptableLogicalClockDriftSecsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 31536000 (1 year)
The maximum amount by which the current cluster time can be advanced; specifically,
maxAcceptableLogicalClockDriftSecsis the maximum difference between the new value of the cluster time and the current cluster time. Cluster time is a logical time used for ordering of operations.You cannot advance the cluster time to a new value if the new cluster time differs from the current cluster time by more than
maxAcceptableLogicalClockDriftSecs.This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the
maxAcceptableLogicalClockDriftSecsfor amongodinstance to 15 minutes:mongod --setParameter maxAcceptableLogicalClockDriftSecs=900
maxNumSyncSourceChangesPerHourAvailable for both适用于mongodandmongos.mongod和mongos。New in version 5.0.在版本5.0中新增。Type: integer
Default: 3
Sync sources are evaluated each time a sync source is updated and each time a node fetches a batch of oplog entries. If there are more than
maxNumSyncSourceChangesPerHoursource changes in an hour, the node temporarily stops re-evaluating that sync source. If this parameter is set with a high value, the node may make unnecessary source changes.This parameter will not prevent a node from starting to sync from another node if it doesn't have a sync source. The node will re-evaluate if a sync source becomes invalid. Similarly, if the primary changes and chaining is disabled, the node will update to sync from the new primary.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
maxSessionsAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 1000000
The maximum number of sessions that can be cached.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the
maxSessionsfor amongodinstance to 1000:mongod --setParameter maxSessions=1000
mirrorReadsAvailable for仅适用于mongodonly.mongod。Type: Document
Default:
{ samplingRate: 0.01, maxTimeMS: 1000 }Specifies the settings for mirrored reads for the
mongodinstance. The settings only take effect when the member is a primary.The parameter
mirrorReadstakes a JSON document with the following fields:Field字段Description描述samplingRateThe sampling rate used to mirror a subset of operations that support mirroring to a subset of electable (specifically,
priority greater than 0) secondaries. That is, the primary mirrors reads to each electable secondary at the specified sampling rate.Valid values are:
0.0Turns off mirroring. 1.0The primary mirrors all operations that supports mirroring to each electable secondary. Number between 0.0and1.0(exclusive)The primary randomly samples each electable secondary at the specified rate to be sent mirrored reads. For example, given a replica set with a primary and two electable secondaries and a sampling rate of
0.10, the primary mirrors reads to each electable secondary at the sampling rate of 10 percent such that one read may be mirrored to one secondary and not to the other or to both or to neither. That is, if the primary receives100operations that can be mirrored, the sampling rate of0.10may result in8reads being mirrored to one secondary and13reads to the other or10to each, etc.The default value is
0.01.maxTimeMSThe maximum time in milliseconds for the mirrored reads. The default value is
1000.The
maxTimeMSfor the mirrored reads is separate from themaxTimeMSof the original read being mirrored.targetedMirroringContains fields to configure how you target specific nodes for cache warming. For more information on targeted mirroring, see Targeted Mirrored Reads.
Includes the following fields:
tagDefaults to an empty
BSONObj. The replica set tag that you can use to target nodes for mirroring. You can configure a node for targeted mirroring using the following syntax:tag: { "<tag1>": "<string1>" }You can only supply one tag. All nodes within the same replica set that have these tags are targeted.
samplingRateType: Float
Range:
0.0to1.0(inclusive)The rate at which targeted reads are mirrored to the host or hosts. A rate of
0.0means no reads are mirrored, and a rate of1.0means all reads are mirrored. AlthoughsamplingRatedefaults to0.01, thetargetedMirroringfeature is off by default, since thetagfield defaults to empty.maxTimeMSType: int
The maximum time in milliseconds before the mirrored read times out. The minumum value for
maxTimeMSis0. Defaults to1000.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
If you specify from the configuration file or on the command line, enclose the
mirrorReadsdocument in quotes.For example, the following sets the mirror reads sampling rate to
0.10from the command line:mongod --setParameter mirrorReads='{ samplingRate: 0.10 }'Or, to specify in a configuration file:
setParameter:
mirrorReads: '{samplingRate: 0.10}'Or if using the
setParametercommand in amongoshsession that is connected to a runningmongod, do not enclose the document in quotes:db.adminCommand( { setParameter: 1, mirrorReads: { samplingRate: 0.10 } } )
mirrorReadsMaxConnPoolSizeNew in version 8.2.在版本8.2中新增。Type: int
Default: 4
Controls the maximum number of connections in the mirroring pool. This parameter affects both general and targeted mirrored reads.
mirrorReadsMaxConnPoolSizehas a minimum value of 1.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
oplogBatchDelayMillisNew in version 6.0.在版本6.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 0
The number of milliseconds to delay applying batches of oplog operations on secondary nodes. By default,
oplogBatchDelayMillisis0, meaning oplog batches are applied with no delay. When there is no delay, MongoDB may apply frequent, small oplog batches to secondaries.Increasing
oplogBatchDelayMilliscauses MongoDB to apply oplog batches less frequently on secondaries, with each batch containing larger amounts of data. This reduces IOPS on secondaries, but adds latency for writes with write concern"majority".This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, run the following command to set the
oplogBatchDelayMillisfor amongodinstance to 20 milliseconds:mongod --setParameter oplogBatchDelayMillis=20
oplogFetcherUsesExhaustAvailable for仅适用于mongodonly.mongod。Type: boolean
Default: true
Enables or disables streaming replication. Set the value to
trueto enable streaming replication.Set the value to
falseto disable streaming replication. If disabled, secondaries fetch batches of oplog entries by issuing a request to their sync from source and waiting for a response. This requires a network roundtrip for each batch of oplog entries.This parameter is only available at startup. To set the parameter, use the
setParametersetting.
oplogInitialFindMaxSecondsAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 60
Maximum time in seconds for a member of a replica set to wait for the
findcommand to finish during data synchronization.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
periodicNoopIntervalSecsAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 10
The duration in seconds between noop writes on each individual node.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.Note
To modify this value for a MongoDB Atlas cluster, you must contact Atlas Support.
The following example sets the
periodicNoopIntervalSecsto 1 second at startup:mongod --setParameter periodicNoopIntervalSecs=1
replBatchLimitBytesAvailable for both适用于mongodandmongos.mongod和mongos。Default: 104857600 (100MB)
Sets the maximum oplog application batch size in bytes.
Values can range from 16777216 (16MB) to 104857600 (100MB) inclusive.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
replBatchLimitBytesto 64 MB to limit the oplog application batch size:mongod --setParameter replBatchLimitBytes=67108864During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, replBatchLimitBytes: 64 * 1024 * 1024 } )
replicaSetMonitorProtocolAvailable for both适用于mongodandmongos.mongod和mongos。Type: string
Default: "streamable"
Determines which replica set monitor protocol to use. You can set this parameter to
"streamable", which is compliant with Server Discovery and Monitoring (SDAM) specification and allows for constanthellorequests. You can also set this parameter to"sdam", which is compliant with SDAM specification.This parameter is only available at startup.
The following example sets
replicaSetMonitorProtocolto"sdam"on amongodinstance:mongod --setParameter replicaSetMonitorProtocol='sdam'
replWriterMinThreadCountNew in version 5.0.在版本5.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 0
Minimum number of threads to use to apply replicated operations in parallel. Values can range from 0 to 256 inclusive. You can only set
replWriterMinThreadCountat startup and cannot change this setting with thesetParametercommand.Parallel application of replication operations uses up to
replWriterThreadCountthreads. IfreplWriterMinThreadCountis configured with a value less thanreplWriterThreadCount, the thread pool will timeout idle threads until the total count of threads in the thread pool is equal toreplWriterMinThreadCount.replWriterMinThreadCountmust be configured with a value that is less than or equal toreplWriterThreadCount.This parameter is only available at startup. To set the parameter, use the
setParametersetting.
replWriterThreadCountAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 16
Maximum number of threads to use to apply replicated operations in parallel. Values can range from 1 to 256 inclusive. However, the maximum number of threads used is capped at twice the number of available cores.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.
rollbackTimeLimitSecsAvailable for仅适用于mongodonly.mongod。Type: 64-bit integer
Default: 86400 (1 day)
Maximum age of data that can be rolled back. Negative values for this parameter are not valid.
If the time between the end of the to-be-rolledback instance's oplog and the first operation after the common point (the last point where the source node and the to-be-rolledback node had the same data) exceeds this value, the rollback will fail.
To effectively have an unlimited rollback period, set the value to
2147483647which is the maximum value allowed and equivalent to roughly 68 years.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
TransactionRecordMinimumLifetimeMinutesAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 30
The minimum lifetime a transaction record exists in the
transactionscollection before the record becomes eligible for cleanup.This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the
TransactionRecordMinimumLifetimeMinutesfor amongodinstance to 20 minutes:mongod --setParameter TransactionRecordMinimumLifetimeMinutes=20
waitForSecondaryBeforeNoopWriteMSAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 10
The length of time (in milliseconds) that a secondary must wait if the
afterClusterTimeis greater than the last applied time from the oplog. After thewaitForSecondaryBeforeNoopWriteMSpasses, if theafterClusterTimeis still greater than the last applied time, the secondary makes a no-op write to advance the last applied time.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets the
waitForSecondaryBeforeNoopWriteMSto 20 milliseconds:mongod --setParameter waitForSecondaryBeforeNoopWriteMS=20During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, waitForSecondaryBeforeNoopWriteMS: 20 } )
Sharding Parameters
analyzeShardKeyCharacteristicsDefaultSampleSizeNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 10000000
If
sampleRateandsampleSizeare not set when you runanalyzeShardKey, specifies the number of documents to sample when calculating shard key characteristics metrics. Must be greater than0.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
analyzeShardKeyCharacteristicsDefaultSampleSizeto10000at startup:mongod --setParameter analyzeShardKeyCharacteristicsDefaultSampleSize=10000During run time, you can set or modify the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, analyzeShardKeyCharacteristicsDefaultSampleSize: 10000 } )
analyzeShardKeyMonotonicityCorrelationCoefficientThresholdNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: double
Default: 0.7
Specifies the
RecordIdcorrelation coefficient threshold used to determine if a shard key is monotonically changing in insertion order. Must be greater than0and less than or equal to1.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
analyzeShardKeyMonotonicityCorrelationCoefficientThresholdto1at startup:mongod --setParameter analyzeShardKeyMonotonicityCorrelationCoefficientThreshold=1During run time, you can set or modify the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, analyzeShardKeyMonotonicityCorrelationCoefficientThreshold: 1 } )
analyzeShardKeyNumMostCommonValuesNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 5
Specifies the number of most common shard key values to return. If the collection contains fewer unique shard keys than this value,
analyzeShardKeyNumMostCommonValuesreturns that number of most common values. Must be greater than0and less than or equal to1000.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
analyzeShardKeyNumMostCommonValuesto3at startup:mongod --setParameter analyzeShardKeyNumMostCommonValues=3During run time, you can set or modify the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, analyzeShardKeyNumMostCommonValues: 3 } )
analyzeShardKeyNumRangesNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 100
Specifies the number of ranges to partition the shard key space into when calculating the hotness of shard key ranges. Must be greater than
0and less than or equal to10000.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
analyzeShardKeyNumRangesto50at startup:mongod --setParameter analyzeShardKeyNumRanges=50During run time, you can set or modify the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, analyzeShardKeyNumRanges: 50 } )
autoMergerIntervalSecsNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 3600
When AutoMerger is enabled, specifies the amount of time between automerging rounds, in seconds. The default value is 3600 seconds, or one hour.
autoMergerIntervalSecscan only be set on config servers.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
autoMergerIntervalSecsto 7200 seconds, or two hours, at startup:mongod --setParameter autoMergerIntervalSecs=7200During run time, you can set or modify the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, autoMergerIntervalSecs: 7200 } )
autoMergerThrottlingMSNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 15000
When AutoMerger is enabled, specifies the minimum amount time between merges initiated by the AutoMerger on the same collection, in milliseconds.
autoMergerThrottlingMScan only be set on config servers.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
autoMergerThrottlingMSto 60000 milliseconds, or one minute, at startup:mongod --setParameter autoMergerThrottlingMS=60000During run time, you can set or modify the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, autoMergerThrottlingMS: 60000 } )
balancerMigrationsThrottlingMsNew in version 7.0.在版本7.0中新增。 (Also available starting in 6.3.1, 6.0.6, 5.0.18)Available for仅适用于mongodonly.mongod。Type: integer
Default: 1000
Specifies the minimum amount of time between two consecutive balancing rounds. This allows you to throttle the balancing rate. This parameter only takes effect on config server nodes.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
balancerMigrationsThrottlingMsto 2000 milliseconds at startup:mongod --setParameter balancerMigrationsThrottlingMs=2000During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, balancerMigrationsThrottlingMs: 2000 } )
catalogCacheCollectionMaxEntriesNew in version 8.1.在版本8.1中新增。 (also available starting in 8.0.10, 7.0.22)Type: integer
Default: 10000
Available for both适用于mongodandmongos.mongod和mongos。Maximum number of entries allowed in the catalog cache for collections.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.
catalogCacheDatabaseMaxEntriesNew in version 8.1.在版本8.1中新增。 (also available starting in 8.0.10, 7.0.22)Type: integer
Default: 10000
Available for both适用于mongodandmongos.mongod和mongos。Maximum number of entries allowed in the catalog cache for databases.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.
chunkDefragmentationThrottlingMSNew in version 5.3.在版本5.3中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 0
Specifies the minimum time period (in milliseconds) between consecutive split and merge commands run by the balancer when the chunks in a sharded collection are defragmented.
chunkDefragmentationThrottlingMSlimits the rate of split and merge commands.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
chunkDefragmentationThrottlingMSto10milliseconds:mongod --setParameter chunkDefragmentationThrottlingMS=10During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, chunkDefragmentationThrottlingMS: 10 } )
disableResumableRangeDeleterAvailable for仅适用于mongodonly.mongod。Type: boolean
Default: false
If set on a shard's primary, specifies if MongoDB pauses range deletion on the shard. If set to
true, MongoDB pauses cleanup of ranges containing orphaned documents. The shard can continue to donate chunks to other shards, but the shard does not remove donated documents until you set this parameter tofalse. This shard can continue to receive chunks from other shards as long as it does not have a pending range deletion task in theconfig.rangeDeletionscollection that overlaps with the incoming chunk's range.When
disableResumableRangeDeleteristrue, chunk migrations fail if orphaned documents exist on the recipient shard's primary in the same range as the incoming chunks.The parameter has no effect on the
mongodif it is not the shard's primary.Important
If you set
disableResumableRangeDeleterparameter totrue, ensure that you apply it consistently for all members in the shard's replica set. In the event of a failover, this setting's value on the new primary dictates the behavior of the range deleter.Starting in MongoDB 8.2, you can set
disableResumableRangeDeleterduring both startup and run time.To set
disableResumableRangeDeleterat startup, use the following command:mongod --setParameter disableResumableRangeDeleter=falseTo set
disableResumableRangeDeleterduring run time, use the following command:db.adminCommand( { setParameter: 1, disableResumableRangeDeleter: false } )
enableFinerGrainedCatalogCacheRefresh-
Note
Deprecated in 8.0
Starting in MongoDB 8.0, the parameter is deprecated and doesn't cause any changes or errors.
Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: true
This parameter allows the catalog cache to be refreshed only if the shard needs to be refreshed. If disabled, any stale chunk will cause the entire chunk distribution for a collection to be considered stale and force all routers who contact the shard to refresh their shard catalog cache.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.mongod --setParameter enableFinerGrainedCatalogCacheRefresh=true
mongos --setParameter enableFinerGrainedCatalogCacheRefresh=true
enableShardedIndexConsistencyCheckAvailable for仅适用于mongodonly.mongod。Type: boolean
Default: true
If set on the config server's primary, enables or disables the index consistency check for sharded collections. The parameter has no effect on the
mongodif it is not the config server's primary.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
enableShardedIndexConsistencyChecktofalsefor a config server primary:mongod --setParameter enableShardedIndexConsistencyCheck=falseDuring run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, enableShardedIndexConsistencyCheck: false } )Tip
shardedIndexConsistencyCheckIntervalMSparametershardedIndexConsistencymetrics returned by theserverStatuscommand.
findChunksOnConfigTimeoutMSNew in version 5.0.在版本5.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: Non-negative integer
Default: 900000
The timeout in milliseconds for find operations on
chunks.If there is a large number of chunks in the cluster and chunk loading fails with the error
ExceededTimeLimit, increase the parameter value:mongod --setParameter findChunksOnConfigTimeoutMS=1000000This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
findShardsOnConfigTimeoutMSAvailable for both适用于mongodandmongos.mongod和mongos。New in version 8.3.在版本8.3中新增。Type: Non-negative integer
Default: 10000 milliseconds
The timeout in milliseconds for
findoperations against theconfig.shardsnamespace.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
findShardsOnConfigTimeoutMSto15000milliseconds during runtime:db.adminCommand( { setParameter: 1, findShardsOnConfigTimeoutMS: 15000 } )The following example sets
findShardsOnConfigTimeoutMSto15000milliseconds at startup:mongos --setParameter findShardsOnConfigTimeoutMS=15000
loadRoutingTableOnStartupAvailable for仅适用于mongosonly.mongos。Type: boolean
Default: true
Configures a
mongosinstance to preload the routing table for a sharded cluster on startup. With this setting enabled, themongoscaches the cluster-wide routing table for each sharded collection as part of its startup procedure, before it begins accepting client connections.Without this setting enabled, the
mongosonly loads a routing table as needed for incoming client connections, and only loads the specific routing table for the namespace of a given request.A
mongosinstance with theloadRoutingTableOnStartupparameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.loadRoutingTableOnStartupis enabled by default.This parameter is only available at startup. To set the parameter, use the
setParametersetting.
maxCatchUpPercentageBeforeBlockingWritesNew in version 5.0.在版本5.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 10
For
moveChunkandmoveRangeoperations, specifies the maximum percentage of untrasferred data allowed by the migration protocol (expressed in percentage of the total chunk size) to transition from thecatchupphase to thecommitphase.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
upsertanddeleteoperations.This parameter is only available at startup. To set the parameter, use the
setParametersetting.Starting in MongoDB 7.1 (and 7.0.1), you can set the parameter during runtime.
For example, to set the maximum percentage to 20, you can issue the following during startup:
mongod --setParameter maxCatchUpPercentageBeforeBlockingWrites=20Starting in MongoDB 7.1 (and 7.0.1), you can set the parameter during runtime with the
setParametercommand:db.adminCommand( { setParameter: 1, maxCatchUpPercentageBeforeBlockingWrites: 20} )
maxTimeMSForHedgedReads-
Important
Starting in MongoDB 8.1, hedged reads are removed and this parameter has no effect.
metadataRefreshInTransactionMaxWaitBehindCritSecMSDeprecated
Note
Starting in MongoDB 8.1, the old
metadataRefreshInTransactionMaxWaitBehindCritSecMSparameter is renamedmetadataRefreshInTransactionMaxWaitMS. You can continue to usemetadataRefreshInTransactionMaxWaitBehindCritSecMSas the parameter name, but it is deprecated and will be removed in a future MongoDB release.New in version 5.2.在版本5.2中新增。 (Also available starting in 5.1.0, 5.0.4)Changed in version 8.1.在版本8.1中的更改。Available for仅适用于mongodonly.mongod。Type: integer
Default: 500
Limits the time a shard waits for a critical section within a transaction.
When a query accesses a shard, a chunk migration or DDL operation may already hold the critical section for the collection. If the query finds the critical section is taken, the shard waits until the critical section has been released. When the shard returns control to
mongos,mongosretries the query. However, if a multi-shard transaction interacts with an operation that takes the critical section on multiple shards, the interaction can result in a distributed deadlock.metadataRefreshInTransactionMaxWaitBehindCritSecMSlimits the maximum time a shard waits within a transaction for the critical section to be released.To reduce the maximum wait time for the critical section within a transaction, lower the value of
metadataRefreshInTransactionMaxWaitBehindCritSecMS.Warning
If
metadataRefreshInTransactionMaxWaitBehindCritSecMSis too low,mongoscould use all of its retry attempts and return an error.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set
metadataRefreshInTransactionMaxWaitBehindCritSecMSto 400 milliseconds:db.adminCommand( { setParameter: 1, metadataRefreshInTransactionMaxWaitBehindCritSecMS: 400 } )
metadataRefreshInTransactionMaxWaitMSChanged in version 8.1.在版本8.1中的更改。Available for仅适用于mongodonly.mongod。Type: integer
Default: 500
Limits the time a shard waits for a critical section within a transaction.
Note
Starting in MongoDB 8.1, the old
metadataRefreshInTransactionMaxWaitBehindCritSecMSparameter is renamedmetadataRefreshInTransactionMaxWaitMS. You can continue to usemetadataRefreshInTransactionMaxWaitBehindCritSecMSas the parameter name, but it is deprecated and will be removed in a future MongoDB release.When a query accesses a shard, a chunk migration or DDL operation may already hold the critical section for the collection. If the query finds the critical section is taken, the shard waits until the critical section has been released. When the shard returns control to
mongos,mongosretries the query. However, if a multi-shard transaction interacts with an operation that takes the critical section on multiple shards, the interaction can result in a distributed deadlock.metadataRefreshInTransactionMaxWaitMSlimits the maximum time a shard waits within a transaction for the critical section to be released.To reduce the maximum wait time for the critical section within a transaction, lower the value of
metadataRefreshInTransactionMaxWaitMS.Warning
If
metadataRefreshInTransactionMaxWaitMSis too low,mongoscould use all of its retry attempts and return an error.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set
metadataRefreshInTransactionMaxWaitMSto 400 milliseconds:db.adminCommand( { setParameter: 1, metadataRefreshInTransactionMaxWaitMS: 400 } )
migrateCloneInsertionBatchDelayMSAvailable for仅适用于mongodonly.mongod。Type: Non-negative integer
Default: 0
Time in milliseconds to wait between batches of insertions during cloning step of the migration process. This wait is in addition to the
secondaryThrottle.The default value of
0indicates no additional wait.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following sets the
migrateCloneInsertionBatchDelayMSto 200 milliseconds:mongod --setParameter migrateCloneInsertionBatchDelayMS=200The parameter may also be set using the
setParametercommand:db.adminCommand( { setParameter: 1, migrateCloneInsertionBatchDelayMS: 200 } )
migrateCloneInsertionBatchSizeAvailable for仅适用于mongodonly.mongod。Type: Non-negative integer
Default: 0
The maximum number of documents to insert in a single batch during the cloning step of the migration process.
The default value of
0indicates no maximum number of documents per batch. However, in practice, this results in batches that contain up to 16 MB of documents.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following sets the
migrateCloneInsertionBatchSizeto 100 documents:mongod --setParameter migrateCloneInsertionBatchSize=100The parameter may also be set using the
setParametercommand:db.adminCommand( { setParameter: 1, migrateCloneInsertionBatchSize: 100 } )
mongosShutdownTimeoutMillisForSignaledShutdownNew in version 5.0.在版本5.0中新增。Available for仅适用于mongosonly.mongos。Type: integer
Default: 15000
Specifies the time (in milliseconds) to wait for any ongoing database operations to complete before initiating a shutdown of
mongosin response to aSIGTERMsignal.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set the time to 250 milliseconds, you can issue the following during startup:
mongos --setParameter mongosShutdownTimeoutMillisForSignaledShutdown=250Or if using the
setParametercommand in amongoshsession that is connected to a runningmongos:db.adminCommand( { setParameter: 1, mongosShutdownTimeoutMillisForSignaledShutdown: 250 } )
opportunisticSecondaryTargeting-
Important
Starting in MongoDB 8.1, hedged reads are removed and this parameter has no effect.
orphanCleanupDelaySecsChanged in version 8.2.在版本8.2中的更改。Available for仅适用于mongodonly.mongod。Default: 3600 (60 minutes)
Minimum delay before a migrated chunk is deleted from the source shard.
Before deleting a migrated chunk, MongoDB waits for in-progress queries involving the chunk to complete on the shard primary and then waits an additional
orphanCleanupDelaySecsseconds.Starting in 8.2, the behavior of in-progress queries on shard secondaries is determined by
terminateSecondaryReadsOnOrphanCleanup.If a shard has storage constraints, consider reducing this value temporarily. If running queries that exceed 60 minutes on shard secondaries, consider increasing this value.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following sets the
orphanCleanupDelaySecsto 20 minutes:mongod --setParameter orphanCleanupDelaySecs=1200This may also be set using the
setParametercommand:db.adminCommand( { setParameter: 1, orphanCleanupDelaySecs: 1200 } )Tip
In all versions, the new value of
orphanCleanupDelaySecsis only applied to range deletions created after the value is changed. To apply the new value to existing range deletions, force a step down.
persistedChunkCacheUpdateMaxBatchSizeNew in version 7.2.在版本7.2中新增。 (and 7.1.1, 7.0.4, 6.0.13, 5.0.25)Available for仅适用于mongodonly.mongod。Type: Integer
Default: 1000
To route and serve operations, shards must know the routing and ownership information associated with their collections. This information propogates from a shard's primary node to its secondary nodes through the replication of the internal cache collections
config.cache.collectionsandconfig.cache.chunks.<collectionName>.In previous versions, updates on the chunk cache collection were performed individually (meaning that an entry was deleted and a new entry was inserted). Starting in MongoDB 7.2, these updates are performed as a batch of deletions followed by a batch of insertions. The updated logic improves performance for collections that contain a large number of chunks.
The
persistedChunkCacheUpdateMaxBatchSizeparameter specifies the maximum batch size used for updating the persisted chunk cache.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
persistedChunkCacheUpdateMaxBatchSizeto 700 at startup:mongod --setParameter persistedChunkCacheUpdateMaxBatchSize=700You can also set
persistedChunkCacheUpdateMaxBatchSizeduring runtime:db.adminCommand( { setParameter: 1, persistedChunkCacheUpdateMaxBatchSize: 700 } )
queryAnalysisSampleExpirationSecsNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 7 * 24 * 3600
Amount of time that a sampled query document exists before being removed by the TTL monitor, in seconds. Must be greater than
0.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
queryAnalysisSampleExpirationSecsto691200(8 * 24 * 3600) at startup on amongodinstance:mongod --setParameter queryAnalysisSampleExpirationSecs=691200During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, queryAnalysisSampleExpirationSecs: 691200 } )
queryAnalysisSamplerConfigurationRefreshSecsNew in version 7.0.在版本7.0中新增。Changed in version 7.0.1.在版本7.0.1中的更改。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 10
Interval that a sampler (
mongosormongod) refreshes its query analyzer sample rates.The sample rate configured by the
configureQueryAnalyzercommand is divided amongmongosinstances in the sharded cluster ormongodinstances in the replica set based on the traffic going through them. To make the sample rate assignment for amongosormongodmore responsive to the traffic going through it, decrease this value.We recommend using the default value.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.Starting in MongoDB 7.0.1, you can set
queryAnalysisSamplerConfigurationRefreshSecsduring run time.This example sets
queryAnalysisSamplerConfigurationRefreshSecsto 60 seconds at startup on amongodinstance:mongod --setParameter queryAnalysisSamplerConfigurationRefreshSecs=60This example sets
queryAnalysisSamplerConfigurationRefreshSecsto 60 seconds at startup on amongosinstance:mongos --setParameter queryAnalysisSamplerConfigurationRefreshSecs=60To set the value to 30 seconds, run the following:
db.adminCommand( { setParameter: 1, queryAnalysisSamplerConfigurationRefreshSecs: 30 } )
queryAnalysisWriterIntervalSecsNew in version 7.0.在版本7.0中新增。Changed in version 7.0.1.在版本7.0.1中的更改。Available for仅适用于mongodonly.mongod。Type: integer
Default: 90
Interval that sampled queries are written to disk, in seconds.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.Starting in MongoDB 7.0.1, you can set
queryAnalysisWriterIntervalSecsduring run time.This example sets
queryAnalysisWriterIntervalSecsto 60 seconds at startup on amongodinstance:mongod --setParameter queryAnalysisWriterIntervalSecs=60To set the value to 60 seconds, run the following:
db.adminCommand( { setParameter: 1, queryAnalysisWriterIntervalSecs: 60 } )
queryAnalysisWriterMaxBatchSizeNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 100000
Maximum number of sampled queries to write to disk at once. Must be greater than
0and less than or equal to100000.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
queryAnalysisWriterMaxBatchSizeto1000at startup on amongodinstance:mongod --setParameter queryAnalysisWriterMaxBatchSize=1000During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, queryAnalysisWriterMaxBatchSize: 1000 } )
queryAnalysisWriterMaxMemoryUsageBytesNew in version 7.0.在版本7.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 100 * 1024 * 1024
Maximum amount of memory in bytes that the query sampling writer is allowed to use. Once the limit is reached, all new queries and diffs are discarded from sampling until the buffer is flushed. Must be greater than
0.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
This example sets
queryAnalysisWriterMaxMemoryUsageBytesto10000000at startup on amongodinstance:mongod --setParameter queryAnalysisWriterMaxMemoryUsageBytes=10000000
rangeDeleterBatchDelayMSAvailable for仅适用于mongodonly.mongod。Type: Non-negative integer
Default: 20
The amount of time in milliseconds to wait before the next batch of deletion during the cleanup stage of range migration.
The _secondaryThrottle replication delay occurs after each batch deletion.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following sets the
rangeDeleterBatchDelayMSto 200 milliseconds:mongod --setParameter rangeDeleterBatchDelayMS=200The parameter may also be set using the
setParametercommand:db.adminCommand( { setParameter: 1, rangeDeleterBatchDelayMS: 200 } )Tip
In versions prior to 6.0.3, the new value of
rangeDeleterBatchDelayMSis only applied to range deletions created after the value is changed. To apply the new value to existing range deletions, force a step down.From 6.0.3 on, the new value of the parameter is applied to all the range deletions processed after the update, regardless of when the range deletion was created.
rangeDeleterBatchSizeAvailable for仅适用于mongodonly.mongod。Type: Non-negative integer
Default: 2147483647 starting in MongoDB 5.1.2 and 5.0.6
The maximum number of documents in each batch to delete during the cleanup stage of range migration.
A value of
0indicates that the system chooses the default value.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
rangeDeleterBatchSizeto 32 documents:mongod --setParameter rangeDeleterBatchSize=32The parameter may also be set using the
setParametercommand:db.adminCommand( { setParameter: 1, rangeDeleterBatchSize: 32 } )Tip
In versions prior to 6.0.3, the new value of
rangeDeleterBatchSizeis only applied to range deletions created after the value is changed. To apply the new value to existing range deletions, force a step down.From 6.0.3 on, the new value of the parameter is applied to all the range deletions processed after the update, regardless of when the range deletion was created.
readHedgingMode-
Important
Starting in MongoDB 8.1, hedged reads are removed and this parameter has no effect.
routingTableCacheChunkBucketSizeNew in version 7.0.1.在版本7.0.1中新增。Changed in version 7.2.在版本7.2中的更改。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 500
Specifies the size of the routing table cache buckets used to implement chunk grouping optimization. Must be greater than
0.This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, to set the cache chunk bucket size to
250on amongod, issue the following command at startup:mongod --setParameter routingTableCacheChunkBucketSize=250
shardedIndexConsistencyCheckIntervalMSAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 600000
If set on the config server's primary, the interval, in milliseconds, at which the config server's primary checks the index consistency of sharded collections. The parameter has no effect on the
mongodif it is not the config server's primary.This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example, the following sets the interval at 300000 milliseconds (5 minutes) at startup:
mongod --setParameter shardedIndexConsistencyCheckIntervalMS=300000Tip
enableShardedIndexConsistencyCheckparametershardedIndexConsistencymetrics returned by theserverStatuscommand.
ShardingTaskExecutorPoolHostTimeoutMSAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 300000 (5 minutes)
Maximum time that
mongosgoes without communication to a host beforemongosdrops all connections to the host.If set,
ShardingTaskExecutorPoolHostTimeoutMSshould be greater than the sum ofShardingTaskExecutorPoolRefreshRequirementMSandShardingTaskExecutorPoolRefreshTimeoutMS. Otherwise,mongosadjusts the value ofShardingTaskExecutorPoolHostTimeoutMSto be greater than the sum.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
ShardingTaskExecutorPoolHostTimeoutMSto120000during startup:mongos --setParameter ShardingTaskExecutorPoolHostTimeoutMS=120000During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolHostTimeoutMS: 120000 } )
ShardingTaskExecutorPoolMaxConnectingAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 2
Maximum number of simultaneous initiating connections (including pending connections in setup/refresh state) each TaskExecutor connection pool can have to a
mongodinstance. You can set this parameter to control the rate at whichmongosadds connections to amongodinstance.If set,
ShardingTaskExecutorPoolMaxConnectingshould be less than or equal toShardingTaskExecutorPoolMaxSize. If it is greater,mongosignores theShardingTaskExecutorPoolMaxConnectingvalue.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
ShardingTaskExecutorPoolMaxConnectingto20during startup:mongos --setParameter ShardingTaskExecutorPoolMaxConnecting=20During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMaxConnecting: 20 } )
ShardingTaskExecutorPoolMaxSizeAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 2 64 - 1
Maximum number of outbound connections each TaskExecutor connection pool can open to any given
mongodinstance. The maximum possible connections to any given host across all TaskExecutor pools is:ShardingTaskExecutorPoolMaxSize * taskExecutorPoolSizeThis parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
ShardingTaskExecutorPoolMaxSizeto20during startup:mongos --setParameter ShardingTaskExecutorPoolMaxSize=20During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMaxSize: 20 } )mongoscan have up tonTaskExecutor connection pools, wherenis the number of cores. SeetaskExecutorPoolSize.
ShardingTaskExecutorPoolMaxSizeForConfigServersNew in version 6.0.在版本6.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: -1
Optional可选。override forShardingTaskExecutorPoolMaxSizeto set the maximum number of outbound connections each TaskExecutor connection pool can open to a configuration server.When set to:
-1,ShardingTaskExecutorPoolMaxSizeis used. This is the default.- an integer value greater than
-1, overrides the maximum number of outbound connections each TaskExecutor connection pool can open to a configuration server.
Parameter only applies to sharded deployments.
The following example sets
ShardingTaskExecutorPoolMaxSizeto2during startup, which sets the maximum number of outbound connections each TaskExecutor connection pool can open to a configuration server to2:This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
mongos --setParameter ShardingTaskExecutorPoolMaxSizeForConfigServers=2During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMaxSizeForConfigServers: 2 } )
ShardingTaskExecutorPoolMinSizeAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 1
Minimum number of outbound connections each TaskExecutor connection pool can open to any given
mongodinstance.ShardingTaskExecutorPoolMinSizeconnections 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 untilShardingTaskExecutorPoolHostTimeoutMSmilliseconds pass without any application using that pool.For a
mongosusing thewarmMinConnectionsInShardingTaskExecutorPoolOnStartupparameter, theShardingTaskExecutorPoolMinSizeparameter also controls how many connections to each shard host are established on startup of themongosinstance before it begins accepting incoming client connections.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
ShardingTaskExecutorPoolMinSizeto2during startup:mongos --setParameter ShardingTaskExecutorPoolMinSize=2During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMinSize: 2 } )mongoscan have up tonTaskExecutor connection pools, wherenis the number of cores. SeetaskExecutorPoolSize.
ShardingTaskExecutorPoolMinSizeForConfigServersNew in version 6.0.在版本6.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: -1
Optional可选。override forShardingTaskExecutorPoolMinSizeto set the minimum number of outbound connections each TaskExecutor connection pool can open to a configuration server.When set to:
-1,ShardingTaskExecutorPoolMinSizeis used. This is the default.- an integer value greater than
-1, overrides the minimum number of outbound connections each TaskExecutor connection pool can open to a configuration server.
Parameter only applies to sharded deployments.
The following example sets
ShardingTaskExecutorPoolMinSizeto2during startup, which sets the minimum number of outbound connections each TaskExecutor connection pool can open to a configuration server to2:This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
mongos --setParameter ShardingTaskExecutorPoolMinSizeForConfigServers=2During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolMinSizeForConfigServers: 2 } )
ShardingTaskExecutorPoolRefreshRequirementMSAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 60000 (1 minute)
Maximum time the
mongoswaits before attempting to heartbeat an idle connection in the pool. An idle connection may be discarded during the refresh if the pool is above its minimum size.If set,
ShardingTaskExecutorPoolRefreshRequirementMSshould be greater thanShardingTaskExecutorPoolRefreshTimeoutMS. Otherwise,mongosadjusts the value ofShardingTaskExecutorPoolRefreshTimeoutMSto be less thanShardingTaskExecutorPoolRefreshRequirementMS.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
ShardingTaskExecutorPoolRefreshRequirementMSto90000during startup:mongos --setParameter ShardingTaskExecutorPoolRefreshRequirementMS=90000During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolRefreshRequirementMS: 90000 } )
ShardingTaskExecutorPoolRefreshTimeoutMSAvailable for both适用于mongodandmongos.mongod和mongos。Type: integer
Default: 20000 (20 seconds)
Maximum time the
mongoswaits for a heartbeat before timing out the heartbeat.If set,
ShardingTaskExecutorPoolRefreshTimeoutMSshould be less thanShardingTaskExecutorPoolRefreshRequirementMS. Otherwise,mongosadjusts the value ofShardingTaskExecutorPoolRefreshTimeoutMSto be less thanShardingTaskExecutorPoolRefreshRequirementMS.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
ShardingTaskExecutorPoolRefreshTimeoutMSto30000during startup:mongos --setParameter ShardingTaskExecutorPoolRefreshTimeoutMS=30000During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolRefreshTimeoutMS: 30000 } )
ShardingTaskExecutorPoolReplicaSetMatchingChanged in version 5.0.在版本5.0中的更改。Available for both适用于mongodandmongos.mongod和mongos。Type: string
Default: "automatic"
On a
mongosinstance, this parameter sets the policy that determines the minimum size limit of its connection pools to nodes within replica sets.On a
mongodinstance, this parameter sets the policy that determines the minimum size limit of its connection pools to nodes within other replica sets.Note that this parameter only manages connections for operations that are directly related to user requests and CRUD operations.
Available values are:
Matching Policy Description描述"automatic"(Default)Starting in 5.0,
"automatic"is the new default value.When set for a
mongos, the instance follows the behavior specified for the"matchPrimaryNode"option.When set for a
mongod, the instance follows the behavior specified for the"disabled"option.WARNING: If the
ShardingTaskExecutorPoolReplicaSetMatchingis set to"automatic", thereplicaSetMatchingStrategystill describes the actual policy being used, not"automatic". To find the value of theShardingTaskExecutorPoolReplicaSetMatching, usegetParameterwhich returns the value of the server parameter."matchPrimaryNode"When set for a
mongos, the minimum size limit of the instance's connection pool to each secondary of a replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the size of its connection pool to that replica set's primary.When set for a
mongod, the minimum size limit of the instance's connection pool to each secondary of another replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the size of its connection pool to that replica set's primary.WARNING: If multiple shard servers in your topology can experience a rapid influx of cross-shard operations, do not set this option on your
mongodinstances.In case of a primary stepdown,
matchPrimaryNodeensures that any secondary that becomes the primary can handle the current level of primary reads and writes."matchBusiestNode"When set for a
mongos, the instance's minimum size limit of the connection pool to each member of a replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the largest among the active connection counts to the primary and each secondary member of that replica set.When set for a
mongod, the instance's minimum size limit of the connection pool to each member of another replica set in the sharded cluster (specifically, shard replica set and config servers) is equal to the largest among the active connection counts to the primary and each secondary member of that replica set.With
"matchBusiestNode",mongosmaintains enough connections to each secondary to handle the current level of primary and secondary reads and writes. The number of connections to maintain in the pool decreases as the number of active connections decreases."disabled"When set for a
mongos, the instance's minimum number of connections in the instance's connection pool to each node of a replica set in the sharded clusterv (specifically, shard replica set and config servers) is equal to theShardingTaskExecutorPoolMinSize.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 theShardingTaskExecutorPoolMinSize.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets the
ShardingTaskExecutorPoolReplicaSetMatchingto"automatic"during startup:mongod --setParameter ShardingTaskExecutorPoolReplicaSetMatching="automatic"During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolReplicaSetMatching: "automatic" } )
shutdownTimeoutMillisForSignaledShutdownNew in version 5.0.在版本5.0中新增。Available for仅适用于mongodonly.mongod。Type: integer
Default: 15000
Specifies the time (in milliseconds) to wait for any ongoing database operations to complete before initiating a shutdown of
mongodin response to aSIGTERMsignal.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set the time to 250 milliseconds, you can issue the following during startup:
mongod --setParameter shutdownTimeoutMillisForSignaledShutdown=250Or if using the
setParametercommand in amongoshsession that is connected to a runningmongod:db.adminCommand( { setParameter: 1, shutdownTimeoutMillisForSignaledShutdown: 250 } )
skipShardingConfigurationChecksAvailable for仅适用于mongodonly.mongod。Type: boolean
Default: false
When
true, allows for starting a shard member or config server member as a standalone for maintenance operations. This parameter is mutually exclusive with the--configsvror--shardsvroptions.This parameter is only available at startup. To set the parameter, use the
setParametersetting.mongod --setParameter skipShardingConfigurationChecks=trueImportant
Once maintenance has completed, remove the
skipShardingConfigurationChecksparameter when restarting themongod.
taskExecutorPoolSizeAvailable for仅适用于mongosonly.mongos。Type: integer
Default: 1
The number of Task Executor connection pools to use for a given
mongos.If the parameter value is
0or less, the number of Task Executor connection pools is the number of cores with the following exceptions:- If the number of cores is less than 4, the number of Task Executor connection pools is 4.
- If the number of cores is greater than 64, the number of Task Executor connection pools is 64.
The default value of
taskExecutorPoolSizeis1:This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
mongos --setParameter taskExecutorPoolSize=6
terminateSecondaryReadsOnOrphanCleanupAvailable for仅适用于mongodonly.mongod。New in version 8.2.在版本8.2中新增。Type: boolean
Default: true
Controls whether long-running read operations on secondary nodes automatically terminate before orphaned document deletion following a chunk migration.
In sharded clusters, when a chunk successfully migrates from the source shard to the destination shard, MongoDB does not immediately remove the migrated documents from the source shard. Instead, the primary of the source shard waits for any in-progress reads involving the namespace of the migrated chunk to complete, and after that, waits an additional period controlled by
orphanCleanupDelaySecs(default: 1 hour). This additional delay allows any long-running secondary reads to finish before orphaned documents are deleted from the source shard.After the orphaned documents are deleted from the source shard, any ongoing reads running on secondary nodes that started before the chunk migration may silently miss documents without returning an error unless
terminateSecondaryReadsOnOrphanCleanupis set totrue.When
terminateSecondaryReadsOnOrphanCleanupis set totrue, read operations on secondary nodes that began before the chunk migration commit are automatically terminated before the orphaned documents are removed from the secondary node. This prevents long-running secondary reads from silently missing documents that were moved during migration.When set to
false, read operations on secondary nodes continue executing even after orphaned documents are deleted. Operations may silently miss documents without returning an error. This matches the behavior in MongoDB versions before 8.2.Note
This behavior only affects read operations that start before the chunk migration commit. It applies to all read operations on secondaries, including queries, aggregations, and operations spanning multiple namespaces.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Error Response
When a read operation terminates due to
terminateSecondaryReadsOnOrphanCleanup, MongoDB returns the following error:{
code: 175,
name: QueryPlanKilled,
categories: [CursorInvalidatedError],
errmsg: "Read has been terminated due to orphan range cleanup"
}This error is not retryable by design. To learn more about handling these errors, see Long-Running Secondary Reads in Sharded Clusters.
warmMinConnectionsInShardingTaskExecutorPoolOnStartupAvailable for仅适用于mongosonly.mongos。Type: boolean
Default: true
Configures a
mongosinstance to prewarm its connection pool on startup. With this parameter enabled, themongosattempts to establishShardingTaskExecutorPoolMinSizenetwork connections to each shard server as part of its startup procedure, before it begins accepting client connections.A timeout for this behavior can be configured with the
warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMSparameter. If this timeout is reached, themongoswill begin accepting client connections regardless of the size of its connection pool.A
mongosinstance with this parameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.warmMinConnectionsInShardingTaskExecutorPoolOnStartupis enabled by default.This parameter is only available at startup. To set the parameter, use the
setParametersetting.
warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMSAvailable for仅适用于mongosonly.mongos。Type: integer
Default: 2000 (2 seconds)
Sets the timeout threshold in milliseconds for a
mongosto wait forShardingTaskExecutorPoolMinSizeconnections to be established per shard host when using thewarmMinConnectionsInShardingTaskExecutorPoolOnStartupparameter. If this timeout is reached, themongoswill begin accepting client connections regardless of the size of its connection pool.This parameter is only available at startup. To set the parameter, use the
setParametersetting.
Health Manager Parameters
activeFaultDurationSecsAvailable for仅适用于mongosonly.mongos。Type: Document
The amount of time to wait from a Health Managers Overview failure until the mongos is removed from the cluster, in seconds.
When a failure is detected and a Health Manager is configured as
critical, the server waits for the specified interval before removing themongosfrom the cluster.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For example, to set the duration from failure to crash to five minutes, issue the following at startup:
mongos --setParameter activeFaultDurationSecs=300Or if using the
setParametercommand in amongoshsession that is connected to a runningmongos:db.adminCommand(
{
setParameter: 1,
activeFaultDurationSecs: 300
}
)Parameters set with
setParameterdo not persist across restarts. See the setParameter page for details.To make this setting persistent, set
activeFaultDurationSecsin your mongos config file using thesetParameteroption as in the following example:setParameter:
activeFaultDurationSecs: 300
healthMonitoringIntensitiesAvailable for仅适用于mongosonly.mongos。Type: Array of documents
Use this parameter to set intensity levels for Health Managers.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
healthMonitoringIntensitiesaccepts an array of documents,values. Each document invaluestakes two fields:type, the Health Manager facetintensity, the intensity level
Health Managers
Facet What the Health Observer Checks configServerCluster health issues related to connectivity to the config server. dnsCluster health issues related to DNS availability and functionality. ldapCluster health issues related to LDAP availability and functionality. Intensity Levels
Intensity Level Description描述criticalThe Health Manager on this facet is enabled and has the ability to move the failing mongos out of the cluster if an error occurs. The Health Manager waits the amount of time specified by activeFaultDurationSecsbefore stopping and moving the mongos out of the cluster automatically.non-criticalThe Health Manager on this facet is enabled and logs errors, but the mongos remains in the cluster if errors are encountered. offThe Health Manager on this facet is disabled. The mongos does not perform any health checks on this facet. This is the default intensity level. For example, to set the
dnsHealth Manager facet to thecriticalintensity level, issue the following at startup:mongos --setParameter 'healthMonitoringIntensities={ values:[ { type:"dns", intensity: "critical"} ] }'Or if using the
setParametercommand in amongoshsession that is connected to a runningmongos:db.adminCommand(
{
setParameter: 1,
healthMonitoringIntensities: { values: [ { type: "dns", intensity: "critical" } ] } } )
}
)Parameters set with
setParameterdo not persist across restarts. See the setParameter page for details.To make this setting persistent, set
healthMonitoringIntensitiesin your mongos config file using thesetParameteroption as in the following example:setParameter:
healthMonitoringIntensities: "{ values:[ { type:\"dns\", intensity: \"critical\"} ] }"
healthMonitoringIntervalsAvailable for仅适用于mongosonly.mongos。Type: Array of documents
How often this Health Manager will run, in milliseconds.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
healthMonitoringIntervalsaccepts an array of documents,values. Each document invaluestakes two fields:type, the Health Manager facetinterval, the time interval it runs at, in milliseconds
Health Managers
Facet What the Health Observer Checks configServerCluster health issues related to connectivity to the config server. dnsCluster health issues related to DNS availability and functionality. ldapCluster health issues related to LDAP availability and functionality. For example, to set the
ldapHealth Manager facet to the run health checks every 30 seconds, issue the following at startup:mongos --setParameter 'healthMonitoringIntervals={ values:[ { type:"ldap", interval: "30000"} ] }'Or if using the
setParametercommand in amongoshsession that is connected to a runningmongos:db.adminCommand(
{
setParameter: 1,
healthMonitoringIntervals: { values: [ { type: "ldap", interval: "30000" } ] } } )
}
)Parameters set with
setParameterdo not persist across restarts. See the setParameter page for details.To make this setting persistent, set
healthMonitoringIntervalsin your mongos config file using thesetParameteroption as in the following example:setParameter:
healthMonitoringIntervals: "{ values: [{type: \"ldap\", interval: 200}] }"
progressMonitorAvailable for仅适用于mongosonly.mongos。Type: Document
Progress Monitor runs tests to ensure that Health Manager checks do not become stuck or unresponsive. Progress Monitor runs these tests in intervals specified by
interval. If a health check begins but does not complete within the timeout given bydeadline, Progress Monitor stops the mongos and removes it from the cluster.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
progressMonitorFieldsField字段Description描述Units intervalHow often to ensure Health Managers are not stuck or unresponsive. Milliseconds deadlineTimeout before automatically failing the mongos if a Health Manager check is not making progress. Seconds To set the
intervalto 1000 milliseconds and thedeadlineto 300 seconds, issue the following at startup:mongos --setParameter 'progressMonitor={"interval": 1000, "deadline": 300}'Or if using the
setParametercommand in amongoshsession that is connected to a runningmongos:db.adminCommand(
{
setParameter: 1,
progressMonitor: { interval: 1000, deadline: 300 } )
}
)Parameters set with
setParameterdo not persist across restarts. See the setParameter page for details.To make this setting persistent, set
progressMonitorin your mongos config file using thesetParameteroption as in the following example:setParameter:
progressMonitor: "{ interval: 1000, deadline: 300 }"
Storage Parameters
enableAutoCompactionAvailable for both适用于mongodandmongos.mongod和mongos。New in version 8.1.0.在版本8.1.0中新增。Type: boolean
Default: false
Specifies whether the instance runs automatic background compaction.
This parameter is only available at startup. To set the parameter, use the
setParametersetting.The following example enables automatic background compaction on the instance:
mongod --setParameter "enableAutoCompaction=true"
honorSystemUmaskAvailable for仅适用于mongodonly.mongod。Default:
falseIf
honorSystemUmaskis set totrue, new files created by MongoDB have permissions in accordance with the user'sumasksettings. You cannot setprocessUmaskifhonorSystemUmaskis set totrue.If
honorSystemUmaskis set tofalse, new files created by MongoDB have permissions set to600, which gives read and write permissions only to the owner. New directories have permissions set to700. You can useprocessUmaskto override the default permissions for groups and other users on all new files created by MongoDB.This parameter is only available at startup. To set the parameter, use the
setParametersetting.mongod --setParameter honorSystemUmask=trueNote
honorSystemUmaskis not available on Windows systems.
journalCommitIntervalAvailable for仅适用于mongodonly.mongod。Specify an integer between
1and500signifying the number of milliseconds (ms) between journal commits.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Consider the following example which sets the
journalCommitIntervalto200ms:db.adminCommand( { setParameter: 1, journalCommitInterval: 200 } )
minSnapshotHistoryWindowInSecondsNew in version 5.0.在版本5.0中新增。Available for仅适用于mongodonly.mongod。Default:
300The 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 specifiedminSnapshotHistoryWindowInSeconds,mongodreturns aSnapshotTooOlderror.Warning
In sharded clusters, changing the default
minSnapshotHistoryWindowInSecondsvalue on config server nodes may cause internal operations to fail.Do not set
minSnapshotHistoryWindowInSecondsto0on config server nodes. Setting this parameter to0causes internal operations conductingsnapshotreads targeting the config server with a specifiedatClusterTimeto fail.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Specify an integer greater than or equal to (
>=) 0.Consider the following example which sets the
minSnapshotHistoryWindowInSecondsto600seconds:db.adminCommand( { setParameter: 1, minSnapshotHistoryWindowInSeconds: 600 } )Note
Increasing the value of
minSnapshotHistoryWindowInSecondsincreases disk usage. For more information, see Snapshot History Retention.To modify this value for a MongoDB Atlas cluster, you must contact Atlas Support.
processUmaskAvailable for仅适用于mongodonly.mongod。Overrides the default permissions used for groups and other users when
honorSystemUmaskis set tofalse. By default, whenhonorSystemUmaskis set tofalse, new files created by MongoDB have permissions set to600. Use theprocessUmaskparameter to override this default with a customumaskvalue. The file owner inherits permissions from the systemumask.This parameter is only available at startup. To set the parameter, use the
setParametersetting.You cannot set this parameter if
honorSystemUmaskis set totrue.Consider the following example, which sets the permissions for groups and other users to read/write only and retains the system
umasksettings for the owner:mongod --setParameter processUmask=011Note
processUmaskis not available on Windows systems.
storageEngineConcurrentReadTransactionsChanged in version 7.0.在版本7.0中的更改。Available for仅适用于mongodonly.mongod。Type: integer
Specifies the maximum number of concurrent read transactions (read tickets) allowed into the storage engine.
Note
Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.
Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.
Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.
Tip
storageEngineConcurrentWriteTransactionsChanged in version 7.0.在版本7.0中的更改。Available for仅适用于mongodonly.mongod。Type: integer
Specifies the maximum number of concurrent write transactions allowed into the WiredTiger storage engine.
Note
Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.
Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.
Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.
Tip
syncdelayAvailable for仅适用于mongodonly.mongod。Default: 60
Specify the interval in seconds when
mongodflushes its working memory to disk. By default,mongodflushes memory to disk every 60 seconds. In almost every situation you should not set this value and use the default setting.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Consider the following example which sets the
syncdelayto60seconds:db.adminCommand( { setParameter: 1, syncdelay: 60 } )To provide durable data, WiredTiger uses checkpoints. For more details, see Journaling and the WiredTiger Storage Engine.
temporarilyUnavailableBackoffBaseMsAvailable for仅适用于mongodonly.mongod。Default: 1000
Specifies the initial delay before retying a write operation that was rolled back due to cache pressure.
In rare circumstances, a write can fail due to cache pressure. When this happens MongoDB issues a
TemporarilyUnavailableerror and increments thetemporarilyUnavailableErrorscounter in two places: the slow query log and the Full Time Diagnostic Data Capture (FTDC).Individual operations within multi-document transactions never return
TemporarilyUnavailableerrors.Adjust the write retry properties by modifying the
temporarilyUnavailableBackoffBaseMsandtemporarilyUnavailableMaxRetriesparameters.The parameter accepts:
Value Description描述integer >= 0Defaults to 1 second. The initial delay between retries. The value increases with each retry to a maximum of 55 seconds. A larger value increases the chance that the cache pressure will be reduced before the next retry.
To configure number of retries, use
temporarilyUnavailableMaxRetries.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
To set a new value, use
db.adminCommand():db.adminCommand( { setParameter: 1, temporarilyUnavailableBackoffBaseMs: 3 } )New in version 6.1.0.在版本6.1.0中新增。
temporarilyUnavailableMaxRetriesAvailable for仅适用于mongodonly.mongod。Default: 10
Specifies the maximum number of retries when a write operation is rolled back due to cache pressure.
In rare circumstances, a write can fail due to cache pressure. When this happens MongoDB issues a
TemporarilyUnavailableerror and increments thetemporarilyUnavailableErrorscounter in two places: the slow query log and the Full Time Diagnostic Data Capture (FTDC).Individual operations within multi-document transactions never return
TemporarilyUnavailableerrors.Adjust the write retry properties by modifying the
temporarilyUnavailableBackoffBaseMsandtemporarilyUnavailableMaxRetriesparameters.The parameter accepts:
Value Description描述integer >= 0The maximum number of retries.
There is an increasing delay between retries. To configure the backoff time, use
temporarilyUnavailableBackoffBaseMs.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
To set a new value, use
db.adminCommand():db.adminCommand( { setParameter: 1, temporarilyUnavailableMaxRetries: 5 } )New in version 6.1.0.在版本6.1.0中新增。
upsertMaxRetryAttemptsOnDuplicateKeyErrorAvailable for both适用于mongodandmongos.mongod和mongos。New in version 8.1.0.在版本8.1.0中新增。Maximum number of retry attempts when an
upsertoperation encounters a duplicate key error.Type: Integer
Default: 100
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
Important
Starting in MongoDB 8.1, if an
upsertoperation runs in a multidocument transaction, then theupsertdoes not retry when it encounters a duplicate key error.The following example sets the maximum number of times the server retries an
upsertoperation when encountering a duplicate key error to50.mongod --setParameter "upsertMaxRetryAttemptsOnDuplicateKeyError=50"During run time, you can also set the parameter with the
setParametercommand:db.adminCommand( {
setParameter: 1,
upsertMaxRetryAttemptsOnDuplicateKeyError: 50
} )
WiredTiger Parameters
wiredTigerConcurrentReadTransactionsAvailable for仅适用于mongodonly.mongod。Type: integer
Specifies the maximum number of concurrent read transactions (read tickets) allowed into the storage engine.
Note
Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.
Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.
Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.
Changed in version 6.0.在版本6.0中的更改。The
wiredTigerConcurrentReadTransactionsparameter was renamed tostorageEngineConcurrentReadTransactions.
wiredTigerConcurrentWriteTransactionsAvailable for仅适用于mongodonly.mongod。Type: integer
Specifies the maximum number of concurrent write transactions allowed into the WiredTiger storage engine.
Note
Starting in version 7.0, MongoDB dynamically adjusts the number of tickets to optimize performance, with a highest possible value of 128.
Modifying this value can cause performance issues or errors. To determine if disabling the dynamic concurrent storage engine transactions algorithm is optimal for the cluster, contact MongoDB Support.
Starting in MongoDB 7.0, this parameter is available for all storage engines. In earlier versions, this parameter is available for the WiredTiger storage engine only.
Changed in version 6.0.在版本6.0中的更改。The
wiredTigerConcurrentWriteTransactionsparameter was renamed tostorageEngineConcurrentWriteTransactions.
wiredTigerEngineRuntimeConfigAvailable for仅适用于mongodonly.mongod。Specify
wiredTigerstorage engine configuration options for a runningmongodinstance.This parameter is only available at runtime. To set the parameter, use thesetParametercommand.setParameterWarning
Avoid modifying the除非在MongoDB工程师的指导下,否则避免修改wiredTigerEngineRuntimeConfigunless under the direction from MongoDB engineers as this setting has major implication across both WiredTiger and MongoDB.wiredTigerEngineRuntimeConfig,因为此设置对WiredTiger和MongoDB都有重大影响。Consider the following operation prototype:考虑以下操作原型:db.adminCommand({
"setParameter": 1,
"wiredTigerEngineRuntimeConfig": "<option>=<setting>,<option>=<setting>"
})
wiredTigerFileHandleCloseIdleTimeAvailable for仅适用于mongodonly.mongod。Type: integer
Default: 600
Specifies the amount of time in seconds that a file handle in指定wiredTigercan remain idle before being closed.wiredTiger中的文件句柄在关闭之前可以保持空闲的时间量(秒)。If you set如果将wiredTigerFileHandleCloseIdleTimeto0, idle handles are not closed.wiredTigerFileHandleCloseIdleTime设置为0,则空闲句柄不会关闭。Tip
This parameter is case sensitive. If you capitalize the此参数区分大小写。如果将winwiredTigerFileHandleCloseIdleTimeand run the parameter, the operation returns the following error message:wiredTigerFileHandleCloseIdleTime中的w大写并运行该参数,则操作将返回以下错误消息:{ "code":2,"codeName":"BadValue","errmsg":"Unknown --setParameter 'WiredTigerFileHandleCloseIdleTime'" }This parameter is only available at startup. To set the parameter, use the
setParametersetting.For example:例如:mongod --setParameter wiredTigerFileHandleCloseIdleTime=100000
wiredTigerSessionMaxNew in version 8.1.在版本8.1中新增。Type: 32-bit integer
Default: 33000
Available for仅适用于mongodonly.mongod。Maximum number of sessions allowed by WiredTiger.WiredTiger允许的最大会话数。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
See the WiredTiger documentation for all available WiredTiger configuration options.有关所有可用的WiredTiger配置选项,请参阅WiredTiger文档。
Auditing Parameters
auditAuthorizationSuccessAvailable for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: false
Note
Available only in MongoDB Enterprise and MongoDB Atlas.
Enables the auditing of authorization successes for the authCheck action.启用authCheck操作的授权成功审核。When当auditAuthorizationSuccessisfalse, the audit system only logs the authorization failures forauthCheck.auditAuthorizationSuccess为false时,审核系统仅记录authCheck的授权失败。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
To enable the audit of authorization successes, issue the following command:要启用对授权成功的审核,请发出以下命令:db.adminCommand( { setParameter: 1, auditAuthorizationSuccess: true } )Enabling启用auditAuthorizationSuccessdegrades performance more than logging only the authorization failures.auditAuthorizationSuccess比仅记录授权失败更会降低性能。If runtime audit configuration is enabled, the如果启用了运行时审核配置,则auditAuthorizationSuccessparameter should not appear in themongodormongosconfiguration file.auditAuthorizationSuccess参数不应出现在mongod或mongos配置文件中。The server will fail to start if the parameter is present.如果参数存在,服务器将无法启动。Tip
auditConfigPollingFrequencySecsAvailable for both适用于mongodandmongos.mongod和mongos。New in version 5.0.在版本5.0中新增。Type: integer
Default: 300
A sharded cluster may have servers which maintain audit configuration settings for the cluster. Set the interval, in seconds, for non-configured servers to poll a config server for the current audit generation.分片集群可能具有维护集群审计配置设置的服务器。设置未配置服务器轮询当前审核生成的配置服务器的间隔(秒)。If this value returned differs from the previously known value, the initiating node will request the current configuration and update its internal state.如果返回的值与先前已知的值不同,则发起节点将请求当前配置并更新其内部状态。Note
Using the default value of 300 seconds, non-config nodes may lag up to 5 minutes after you set the使用默认值300秒,在设置auditConfigcluster parameter.auditConfig集群参数后,非配置节点可能会延迟长达5分钟。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。
auditEncryptionHeaderMetadataFileNew in version 6.0.在版本6.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: string
Note
Available only in MongoDB Enterprise. MongoDB Enterprise and Atlas have different configuration requirements.仅在MongoDB企业版中可用。MongoDB企业版和Atlas有不同的配置要求。Path and file name for logging metadata audit headers for audit log encryption.用于审计日志加密的日志元数据审计头的路径和文件名。A header is placed at the top of each audit log file and contains metadata for decrypting the audit log. The headers are also stored in the audit log.每个审计日志文件的顶部都有一个标题,其中包含用于解密审计日志的元数据。标头也存储在审核日志中。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。For example, the following sets the path and file for例如,以下设置auditEncryptionHeaderMetadataFile:auditEncryptionHeaderMetadataFile的路径和文件:mongod --setParameter auditEncryptionHeaderMetadataFile=/auditFiles/auditHeadersMetadataFile.log
auditEncryptKeyWithKMIPGetNew in version 6.0.在版本6.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Type: boolean
Default: false
Note
Available only in MongoDB Enterprise. MongoDB Enterprise and Atlas have different configuration requirements.仅在MongoDB Enterprise中可用。MongoDB Enterprise和Atlas有不同的配置要求。Enables audit log encryption for Key Management Interoperability Protocol (KMIP) servers that only support KMIP protocol version 1.0 or 1.1.为仅支持KMIP协议版本1.0或1.1的KMIP服务器启用审计日志加密。This parameter is only available at startup. To set the parameter, use the此参数仅在启动时可用。要设置参数,请使用setParametersetting.setParameter设置。The following example sets以下示例将auditEncryptKeyWithKMIPGettotrue:auditEncryptKeyWithKMIPGet设置为true:mongod --setParameter auditEncryptKeyWithKMIPGet=true
Transaction Parameters事务参数
AbortExpiredTransactionsSessionCheckoutTimeoutNew in version 8.1.在版本8.1中新增。 (also available in 8.0.13)Available for仅适用于mongodonly.mongod。Type: integer
Default: 100 milliseconds
A session is checked out from a session pool to run database operations.从会话池中签出会话以运行数据库操作。AbortExpiredTransactionsSessionCheckoutTimeoutsets the maximum number of milliseconds for a session to be checked out when attempting to end an expired transaction.If the expired transaction is successfully ended, MongoDB increments
metrics.abortExpiredTransactions.successfulKills. If the transaction isn't successfully ended because it timed out when attempting to check out a session, MongoDB incrementsmetrics.abortExpiredTransactions.timedOutKills.This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets
AbortExpiredTransactionsSessionCheckoutTimeoutto120milliseconds:db.adminCommand( { setParameter: 1, AbortExpiredTransactionsSessionCheckoutTimeout: 120 } )You can also set this parameter during startup. For example:您还可以在启动过程中设置此参数。例如:mongod --setParameter AbortExpiredTransactionsSessionCheckoutTimeout=120
coordinateCommitReturnImmediatelyAfterPersistingDecisionNew in version 5.0.在版本5.0中新增。Updated in version 6.1在6.1版本中更新Available for仅适用于mongodonly.mongod。Type: boolean
Default: false
When set to当设置为false, the shard transaction coordinator waits for all participating shards to acknowledge the decision to either commit or cancel a multi-document transaction before returning the result to the client.false时,分片事务协调器会等待所有参与的分片确认提交或取消多文档事务的决定,然后再将结果返回给客户端。When set to当设置为true, the shard transaction coordinator returns a multi-document transaction commit decision to the client as soon as the decision is made durable with the requested transaction write concern.true时,分片事务协调器会在所请求的事务写入关注使多文档事务提交决策持久后,立即向客户端返回该决策。If the client requested a write concern that is less than如果客户端请求的写入关注度低于"majority", the commit may roll back after the decision is returned to the client."majority",则提交可能会在决定返回给客户端后回滚。Transactions may not have "read your writes" consistency. That is, a read operation may not show the results of write operations that preceded it. This can happen if:事务可能没有“读写”一致性。也就是说,读取操作可能不会显示之前的写入操作的结果。如果发生以下情况,可能会发生这种情况:A transaction has to write to multiple shards.一个事务必须写入多个分片。The read and the earlier write take place in different sessions.阅读和之前的写作发生在不同的会话中。
Causal consistency only guarantees the causal relationship of reads and writes that occur within the same session.因果一致性仅保证在同一会话中发生的读写之间的因果关系。
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets以下示例将coordinateCommitReturnImmediatelyAfterPersistingDecisiontotrue:coordinateCommitReturnImmediatelyAfterPersistingDecision设置为true:mongod --setParameter coordinateCommitReturnImmediatelyAfterPersistingDecision=trueDuring run time, you can also set the parameter with the在运行时,您还可以使用setParametercommand:setParameter命令设置参数:db.adminCommand( { setParameter: 1, coordinateCommitReturnImmediatelyAfterPersistingDecision: true } )
internalSessionsReapThresholdNew in version 6.0.在版本6.0中新增。Available for both适用于mongodandmongos.mongod和mongos。Default: 1000
Session limit for internal session metadata deletion. The metadata:删除内部会话元数据的会话限制。元数据:Contains session transaction information for user operations.包含用户操作的会话事务信息。Is stored in the存储在config.transactionscollection.config.transactions集合中。
When the number of internal sessions is greater than当内部会话数大于internalSessionsReapThreshold, the metadata is deleted.internalSessionsReapThreshold时,元数据将被删除。If you set如果将internalSessionsReapThresholdto0, the internal session metadata is only deleted when the user session ends.internalSessionsReapThreshold设置为0,则只有在用户会话结束时才会删除内部会话元数据。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following example sets以下示例将internalSessionsReapThresholdto500sessions:internalSessionsReapThreshold设置为500个会话:db.adminCommand( { setParameter: 1, internalSessionsReapThreshold: 500 } )You can also set您还可以在启动时设置内部internalSessionsReapThresholdat startup. For example:internalSessionsReapThreshold。例如:mongod --setParameter internalSessionsReapThreshold=500
transactionLifetimeLimitSecondsAvailable for仅适用于mongodonly.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 is1second.transactionLifetimeLimitSeconds的最小值为1秒。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following sets the以下将transactionLifetimeLimitSecondsto30seconds:transactionLifetimeLimitSeconds设置为30秒:db.adminCommand( { setParameter: 1, transactionLifetimeLimitSeconds: 30 } )You can also set parameter您还可以在启动时设置参数transactionLifetimeLimitSecondsat 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从MongoDB 5.0开始,如果更改transactionLifetimeLimitSecondsparameter, you must also changetransactionLifetimeLimitSecondsto the same value on all config server replica set members.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.降低事务重试频率,从而提高性能。
transactionTooLargeForCacheThresholdNew in version 6.2.在版本6.2中新增。Available for仅适用于mongodonly.mongod。Type: decimal
Default: 0.75
The threshold value for retrying transactions that fail due to cache pressure. The value is a percentage of the dirty cache size. The default value,重试因缓存压力而失败的事务的阈值。该值是脏缓存大小的百分比。默认值0.75, means 75% of the dirty cache.0.75表示75%的脏缓存。The dirty cache is limited to 20% of the total cache size. When脏缓存限制为总缓存大小的20%。当transactionTooLargeForCacheThresholdis set to0.75, the server only retries transactions that use less than 15% (0.75 * 20%) of the total storage engine cache.transactionTooLargeForCacheThreshold设置为0.75时,服务器仅重试使用总存储引擎缓存不足15%(0.75*20%)的事务。The limit only applies to retries. Large transactions can use more than该限制仅适用于重试。大型事务可以使用超过transactionTooLargeForCacheThresholdpercent of the dirty cache.transactionTooLargeForCacheThreshold百分比的脏缓存。However, if a large transaction is rolled back due to cache pressure, the server issues a但是,如果由于缓存压力而回滚了一个大型事务,服务器会发出TransactionTooLargeForCacheerror and does not retry the transaction.TransactionTooLargeForCache错误,并且不会重试该事务。To disable this behavior, set要禁用此行为,请将transactionTooLargeForCacheThresholdto1.0.transactionTooLaggeForCacheThreshold设置为1.0。This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
For more information on WiredTiger storage, see:有关WiredTiger存储的详细信息,请参阅:storage.wiredTigerOptions.storage.wiredTiger选项。
maxTransactionLockRequestTimeoutMillisAvailable for仅适用于mongodonly.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默认情况下,多文档事务等待5milliseconds.5毫秒。That is, if the transaction cannot acquire the locks within5milliseconds, the transaction aborts. If an operation provides a greater timeout in a lock request,maxTransactionLockRequestTimeoutMillisoverrides the operation-specific timeout.You can set您可以将maxTransactionLockRequestTimeoutMillisto:maxTransactionLockRequestTimeoutMillis设置为:0such that if the transaction cannot acquire the required locks immediately, the transaction aborts.这样,如果事务不能立即获取所需的锁,则事务中止。A number greater than一个大于0to 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.这可以帮助避免瞬时并发锁获取时的事务中止,如快速运行的元数据操作。然而,这可能会延迟死锁事务操作的中止。-1to use the operation specific timeout.以使用特定于操作的超时。
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following sets the
maxTransactionLockRequestTimeoutMillisto20milliseconds:db.adminCommand( { setParameter: 1, maxTransactionLockRequestTimeoutMillis: 20 } )You can also set this parameter during start-up:
mongod --setParameter maxTransactionLockRequestTimeoutMillis=20
Slot-Based Execution Parameters
planCacheSizeNew in version 6.3.在版本6.3中新增。Available for仅适用于mongodonly.mongod。Type: string
Default: 5%
Note
Although the
planCacheSizeparameter existed in prior versions of MongoDB, it had no effect on the plan cache until version 6.3.Sets the size of the plan cache only for the slot-based query execution engine.
You can set the
planCacheSizevalue to either:- A percentage of the system's total physical memory to allocate for the plan cache. For example,
"8.5%". - The exact amount of data to allocate for the plan cache in either
MBorGB. For example,"100MB"or"1GB".
Increasing the plan cache size adds more cached plan cache query shapes for the query planner. This can improve query performance, but increases memory usage.
This parameter is available both at runtime and at startup:此参数在运行时和启动时都可用:To set the parameter at runtime, use the要在运行时设置参数,请使用setParametercommand.setParameter命令。To set the parameter at startup, use the要在启动时设置参数,请使用setParametersetting.setParameter设置。
The following startup command sets
planCacheSizeto 80 megabytes:mongod --setParameter planCacheSize="80MB"You can also use the
setParametercommand within the MongoDB Shell:db.adminCommand( { setParameter: 1, planCacheSize: "80MB" } )- A percentage of the system's total physical memory to allocate for the plan cache. For example,