MongoDB Server Parameters
On this page
- Synopsis
Parameters
- Authentication Parameters
- General Parameters
- Logging Parameters
- Diagnostic Parameters
- Logical Session
- Replication Parameters
- Sharding Parameters
- Storage Parameters
- WiredTiger Parameters
- Auditing Parameters
- Transaction Parameters
Synopsis
MongoDB provides a number of configuration options that you can set using:
the
setParameter
command:copycopied
db.adminCommand( { setParameter: 1, <parameter>: <value> } )
the
setParameter
configuration setting:copycopied
setParameter: <parameter1>: <value1> ...
the
--setParameter
command-line option formongod
andmongos
:copycopied
mongod --setParameter <parameter>=<value> mongos --setParameter <parameter>=<value>
For additional configuration options, see Configuration File Options, mongod
and mongos
.
Parameters
Authentication Parameters
authenticationMechanisms
Changed in version 4.0: Remove support for the deprecated
MONGODB-CR
authentication mechanism.Available for bothmongod
andmongos
.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.ValueDescriptionSCRAM-SHA-1RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.SCRAM-SHA-256RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.Requires featureCompatibilityVersion set to4.0
.New in version 4.0.MONGODB-X509MongoDB TLS/SSL certificate authentication.GSSAPI (Kerberos)External authentication using Kerberos. This mechanism is available only in MongoDB Enterprise.PLAIN (LDAP SASL)External authentication using LDAP. You can also usePLAIN
for authenticating in-database users.PLAIN
transmits passwords in plain text. This mechanism is available only in MongoDB Enterprise.You can only setauthenticationMechanisms
during start-up.For example, to specify bothPLAIN
andSCRAM-SHA-256
as the authentication mechanisms, use the following command:copycopiedmongod --setParameter authenticationMechanisms=PLAIN,SCRAM-SHA-256 --auth
clusterAuthMode
Available for both
mongod
andmongos
.Set theclusterAuthMode
to eithersendX509
orx509
. Useful during rolling upgrade to use x509 for membership authentication to minimize downtime.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .copycopieddb.adminCommand( { setParameter: 1, clusterAuthMode: "sendX509" } )
enableLocalhostAuthBypass
Available for both
mongod
andmongos
.Specify0
orfalse
to disable localhost authentication bypass. Enabled by default.enableLocalhostAuthBypass
is not available usingsetParameter
database command. Use thesetParameter
option in the configuration file or the--setParameter
option on the command line.See Localhost Exception for more information.KeysRotationIntervalSec
New in version 3.6.**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.You can only set
KeysRotationIntervalSec
during start-up, and cannot change this setting with thesetParameter
database command.ldapUserCacheInvalidationInterval
For use with MongoDB deployments using LDAP Authorization. Available for
mongod
instances only.The interval (in seconds) that themongod
instance waits between external user cache flushes. 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.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.Defaults to 30 seconds.ldapUseConnectionPool
New in version 4.0.9.Specifies whether MongoDB should use connection pooling when connecting to the LDAP server for authentication/authorization.Starting in version 4.2, MongoDB uses the following default values:true on Windows.true on Linux where MongoDB Enterprise binaries are linked against
libldap_r
.false on Linux where MongoDB Enterprise binaries are linked againstlibldap
.In earlier versions (versions 4.0.9+), the default value isfalse
.You can only setldapUseConnectionPool
during start-up, and cannot change this setting with thesetParameter
database command.ldapConnectionPoolUseLatencyForHostPriority
New in version 4.2.1 and 4.0.13**Default: trueA boolean that determines whether the LDAP connection pool (see
ldapUseConnectionPool
) should use latency of the LDAP servers to determine the connection order (from lowest latency to highest).You can only setldapConnectionPoolUseLatencyForHostPriority
during start-up, and cannot change this setting during runtime with thesetParameter
database command.ldapConnectionPoolMinimumConnectionsPerHost
New in version 4.2.1 and 4.0.13**Default: 1The minimum number of connections to keep open to each LDAP server.You can only set
ldapConnectionPoolMinimumConnectionsPerHost
during start-up, and cannot change this setting during runtime with thesetParameter
database command.ldapConnectionPoolMaximumConnectionsPerHost
New in version 4.2.1 and 4.0.13**Changed in version 4.4 Changed default value to
2
. In previous versions, the default is unset.Default: 2The maximum number of connections to keep open to each LDAP server.You can only setldapConnectionPoolMaximumConnectionsPerHost
during start-up, and cannot change this setting during runtime with thesetParameter
database command.ldapConnectionPoolMaximumConnectionsInProgressPerHost
New in version 4.2.1 and 4.0.13The maximum number of in-progress connect operations to each LDAP server.You can only set
ldapConnectionPoolMaximumConnectionsInProgressPerHost
during start-up, and cannot change this setting with thesetParameter
database command.ldapConnectionPoolHostRefreshIntervalMillis
New in version 4.2.1 and 4.0.13**Default: 60000The number of milliseconds in-between health checks of the pooled LDAP connections.You can only set
ldapConnectionPoolHostRefreshIntervalMillis
during start-up, and cannot change this setting with thesetParameter
database command.ldapConnectionPoolIdleHostTimeoutSecs
New in version 4.2.1 and 4.0.13**Default: 300The maximum number of seconds that the pooled connections to an LDAP server can remain idle before being closed.You can only set
ldapConnectionPoolIdleHostTimeoutSecs
during start-up, and cannot change this setting with thesetParameter
database command.ocspEnabled
New in version 4.4: Available on Linux and macOS.Default: trueThe flag that enables or disables OCSP.You can only set
ocspEnabled
during startup in theconfiguration file
or with the--setParameter
option on the command line. For example, the following disables OCSP:copycopiedmongod --setParameter ocspEnabled=false ...
SEE ALSOocspValidationRefreshPeriodSecs
tlsOCSPStaplingTimeoutSecs
tlsOCSPVerifyTimeoutSecs
ocspValidationRefreshPeriodSecs
New in version 4.4: Available on Linux.The number of seconds to wait before refreshing the stapled OCSP status response. Specify a number greater than or equal to 1.You can only set
ocspValidationRefreshPeriodSecs
during startup in theconfiguration file
or with the--setParameter
option on the command line. For example, the following sets the parameter to 3600 seconds:copycopiedmongod --setParameter ocspValidationRefreshPeriodSecs=3600 ...
SEE ALSOocspEnabled
tlsOCSPStaplingTimeoutSecs
tlsOCSPVerifyTimeoutSecs
opensslCipherConfig
New in version 3.6.**Changed in version 4.0: With the use of native TLS/SSL libraries, the parameter
opensslCipherConfig
is supported for Linux/BSD and no longer supported in Windows and macOS. See MongoDB 4.0 TLS/SSL.Specify the cipher string for OpenSSL when using TLS/SSL encryption. For a list of cipher strings, see https://www.openssl.org/docs/man1.0.2/apps/ciphers.htmlCIPHER-STRINGSYou can only setopensslCipherConfig
during start-up, and cannot change this setting using thesetParameter
database command.For version 4.2 and greater, the use ofTLS
options is preferred overSSL
options. The TLS options have the same functionality as theSSL
options.copycopiedmongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL@STRENGTH' --tlsMode requireTLS --tlsCertificateKeyFile Certs/server.pem
For versions 4.0 and earlier:copycopiedmongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL@STRENGTH' --sslMode requireSSL --sslPEMKeyFile Certs/server.pem
opensslDiffieHellmanParameters
New in version 3.6.**Available on Linux onlySpecify the path to the PEM file that contains the OpenSSL Diffie-Hellman parameters. Specifying the OpenSSL Diffie-Hellman parameters enables support for Ephemeral Diffie-Hellman (DHE) cipher suites during TLS/SSL encryption.Ephemeral Diffie-Hellman (DHE) cipher suites (and Ephemeral Elliptic Curve Diffie-Hellman (ECDHE) cipher suites) provide Forward Secrecy. 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.NOTEStarting in MongoDB 4.2, if
opensslDiffieHellmanParameters
is unset but ECDHE is enabled, MongoDB enables DHE usingffdhe3072
Diffie-Hellman parameter, as defined in RFC 7919appendix-A.2. Theffdhe3072
is a strong parameter (i.e. size is greater than 1024). Strong parameters are not supported with Java 6 and 7 unless extended support has been purchased from Oracle.You can only setopensslDiffieHellmanParameters
during startup, and cannot change this setting using thesetParameter
database command.If for performance reasons, you need to disable support for DHE cipher suites, use theopensslCipherConfig
parameter:copycopiedmongod --setParameter opensslCipherConfig='HIGH:!EXPORT:!aNULL:!DHE:!kDHE@STRENGTH' ...
saslauthdPath
NOTEAvailable only in MongoDB Enterprise (except MongoDB Enterprise for Windows).Available for both
mongod
andmongos
.Specify the path to the Unix Domain Socket of thesaslauthd
instance to use for proxy authentication.saslHostName
Available for both
mongod
andmongos
.saslHostName
overrides MongoDB’s default hostname detection for the purpose of configuring SASL and Kerberos authentication.saslHostName
does not affect the hostname of themongod
ormongos
instance for any purpose beyond the configuration of SASL and Kerberos.You can only setsaslHostName
during start-up, and cannot change this setting using thesetParameter
database command.NOTEsaslHostName
supports Kerberos authentication and is only included in MongoDB Enterprise. For more information, see the following:Linux: Configure MongoDB with Kerberos Authentication on LinuxWindows: Configure MongoDB with Kerberos Authentication on WindowssaslServiceName
Available for both
mongod
andmongos
.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 ismongodb
.MongoDB only permits settingsaslServiceName
at startup. ThesetParameter
command can not change this setting.saslServiceName
is only available in MongoDB Enterprise.IMPORTANTEnsure that your driver supports alternate service names.scramIterationCount
Default:
10000
Available for bothmongod
andmongos
.Changes the number of hashing iterations used for all newSCRAM-SHA-1
passwords. More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts. 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. ThescramIterationCount
value must be5000
or greater.For example, the following sets thescramIterationCount
to12000
.copycopiedmongod --setParameter scramIterationCount=12000
Or, if using thesetParameter
command within themongo
shell:copycopieddb.adminCommand( { setParameter: 1, scramIterationCount: 12000 } )
SEE ALSOdb.changeUserPassword()
db.createUser()
db.updateUser()
scramSHA256IterationCount
New in version 4.0.**Default:
15000
Available for bothmongod
andmongos
.Changes the number of hashing iterations used for all newSCRAM-SHA-256
passwords. More iterations increase the amount of time required for clients to authenticate to MongoDB, but makes passwords less susceptible to brute-force attempts. The default value is ideal for most common use cases and requirements.If you modify this value, it does not change iteration count for existing passwords. ThescramSHA256IterationCount
value must be5000
or greater.For example, the following sets thescramSHA256IterationCount
to20000
.copycopiedmongod --setParameter scramSHA256IterationCount=20000
Or, if using thesetParameter
command within themongo
shell:copycopieddb.adminCommand( { setParameter: 1, scramSHA256IterationCount: 20000 } )
SEE ALSOdb.changeUserPassword()
db.createUser()
db.updateUser()
sslMode
Available for both
mongod
andmongos
.Set thenet.ssl.mode
to eitherpreferSSL
orrequireSSL
. Useful during rolling upgrade to TLS/SSL to minimize downtime.For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .copycopieddb.adminCommand( { setParameter: 1, sslMode: "preferSSL" } )
SEE ALSOtlsMode
tlsMode
New in version 4.2.Available for both
mongod
andmongos
.Set to either:preferTLS``requireTLS
ThetlsMode
parameter is useful during rolling upgrade to TLS/SSL to minimize downtime.copycopieddb.adminCommand( { setParameter: 1, tlsMode: "preferTLS" } )
For more information about TLS/SSL and MongoDB, see Configure mongod and mongos for TLS/SSL and TLS/SSL Configuration for Clients .SEE ALSOsslMode
tlsOCSPStaplingTimeoutSecs
New in version 4.4: Available for Linux.The maximum number of seconds the
mongod
/mongos
instance should wait to receive the OCSP status response for its certificates.Specify an integer greater than or equal to (>=
) 1. If unset,tlsOCSPStaplingTimeoutSecs
uses thetlsOCSPVerifyTimeoutSecs
value.You can only settlsOCSPStaplingTimeoutSecs
during startup in theconfiguration file
or with the--setParameter
option on the command line. For example, the following sets thetlsOCSPStaplingTimeoutSecs
to 20 seconds:copycopiedmongod --setParameter tlsOCSPStaplingTimeoutSecs=20 ...
SEE ALSOocspEnabled
ocspValidationRefreshPeriodSecs
tlsOCSPVerifyTimeoutSecs
tlsOCSPVerifyTimeoutSecs
New in version 4.4: Available for Linux and Windows.Default: 5The maximum number of seconds that the
mongod
/mongos
should wait for the OCSP response when verifying client certificates.Specify an integer greater than or equal to (>=
) 1. Default is unlimited.You can only settlsOCSPVerifyTimeoutSecs
during startup in theconfiguration file
or with the--setParameter
option on the command line. For example, the following sets thetlsOCSPVerifyTimeoutSecs
to 20 seconds:copycopiedmongod --setParameter tlsOCSPVerifyTimeoutSecs=20 ...
SEE ALSOocspEnabled
ocspValidationRefreshPeriodSecs
tlsOCSPStaplingTimeoutSecs
tlsWithholdClientCertificate
Default: falseNew in version 4.2.Available for both
mongod
andmongos
.A TLS certificate is set for amongod
ormongos
either by the--tlsClusterFile
option or by the--tlsCertificateKeyFile
option when--tlsClusterFile
is not set. If the TLS certificate is set, by default, the instance sends the certificate when initiating intra-cluster communications with othermongod
ormongos
instances in the deployment. SettlsWithholdClientCertificate
to1
ortrue
to direct the instance to withhold sending its TLS certificate during these communications. Use this option with--tlsAllowConnectionsWithoutCertificates
(to allow inbound connections without certificates) on all members of the deployment.tlsWithholdClientCertificate
is mutually exclusive with--clusterAuthMode x509
.tlsX509ClusterAuthDNOverride
New in version 4.2.Available for both
mongod
andmongos
.An alternative Distinguished Name (DN) that the instance can also use to identify members of the deployment.For a MongoDB deployment that uses x.509 certificates forclusterAuthMode
, deployment members identify each other using x.509 certificates (net.tls.clusterFile
, if specified, andnet.tls.certificateKeyFile
) during intra-cluster communications. For members of the same deployment, theDN
from their certificates must have the same Organization attributes (O
’s), the Organizational Unit attributes (OU
’s), and the Domain Components (DC
’s).IftlsX509ClusterAuthDNOverride
is set for a member, the member can also use the override value when comparing theDN
components (O
’s,OU
’s, andDC
’s) of the presented certificates. That is the member checks the presented certificates against itsnet.tls.clusterFile
/net.tls.certificateKeyFile
. If the DN does not match, the member checks the presented certificate against thetlsX509ClusterAuthDNOverride
value.NOTEIf set, you must set this parameter on all members of the deployment.You can use this parameter for a rolling update of certificates to new certificates that contain a newDN
value. See Rolling Update of x.509 Cluster Certificates that Contain New DN.For more information about membership certificate requirements, see Member Certificate Requirements for details.tlsX509ExpirationWarningThresholdDays
New in version 4.4.**Default : 30Available for both
mongod
andmongos
.Starting in MongoDB 4.4,mongod
/mongos
logs a warning on connection if the presented x.509 certificate expires within30
days of themongod/mongos
system clock. Use thetlsX509ExpirationWarningThresholdDays
parameter to control the certificate expiration warning threshold: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 to0
to disable the warning.This parameter has a minimum value of0
.You can only settlsX509ExpirationWarningThresholdDays
duringmongod/mongos
startup using either:ThesetParameter
configuration setting, orThemongod --setParameter
/mongos --setParameter
command line option.See x.509 Certificates Nearing Expiry Trigger Warnings for more information on x.509 expiration warnings in MongoDB 4.4.For more information on x.509 certificate validity, see RFC 5280 4.1.2.5.sslWithholdClientCertificate
Default: falseDeprecated since version 4.2: Use
tlsWithholdClientCertificate
instead.Available for bothmongod
andmongos
.A TLS certificate is set for amongod
ormongos
either by the--tlsClusterFile
option or by the--tlsCertificateKeyFile
option when--tlsClusterFile
is not set. If the TLS certificate is set, by default, the instance sends the certificate when initiating intra-cluster communications with othermongod
ormongos
instances in the deployment. SetsslWithholdClientCertificate
to1
ortrue
to direct the instance to withhold sending its TLS certificate during these communications. Use this option with--tlsAllowConnectionsWithoutCertificates
(to allow inbound connections without certificates) on all members of the deployment.sslWithholdClientCertificate
is mutually exclusive with--clusterAuthMode x509
.userCacheInvalidationIntervalSecs
Default: 30Available for
mongos
only.On amongos
instance, specifies the interval (in seconds) at which themongos
instance checks to determine whether the in-memory cache of user objects has stale data, and if so, clears the cache. If there are no changes to user objects,mongos
will not clear the cache.This parameter has a minimum value of1
second and a maximum value of86400
seconds (24 hours).authFailedDelayMs
Default: 0Available for both
mongod
andmongos
.New in version 3.4.ENTERPRISE FEATUREAvailable in MongoDB Enterprise only.The number of milliseconds to wait before informing clients that their authentication attempt has failed. This parameter may be in the range0
to5000
, inclusive.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.allowRolesFromX509Certificates
Default: trueAvailable for both
mongod
andmongos
.Available starting in MongoDB 4.0.11 (and 3.6.14 and 3.4.22)A boolean flag that allows or disallows the retrieval of authorization roles from client x.509 certificates.You can only setallowRolesFromX509Certificates
during startup in the config file or on the command line.General Parameters
connPoolMaxShardedConnsPerHost
Default: 200Available for both
mongod
andmongos
.Sets the maximum size of the legacy connection pools for communication to the shards. The size of a pool does not prevent the creation of additional connections, but does prevent the connection pools from retaining connections above this limit.NOTEThe parameter is separate from the connections in TaskExecutor pools. SeeShardingTaskExecutorPoolMaxSize
.Increase theconnPoolMaxShardedConnsPerHost
value only if the number of connections in a connection pool has a high level of churn or if the total number of created connections increase.You can only setconnPoolMaxShardedConnsPerHost
during startup in the config file or on the command line. For example:copycopiedmongos --setParameter connPoolMaxShardedConnsPerHost=250
connPoolMaxShardedInUseConnsPerHost
New in version 3.6.3.Available for both
mongod
andmongos
.Sets the maximum number of in-use connections at any given time for the legacy sharded cluster connection pools.By default, the parameter is unset.You can only setconnPoolMaxShardedConnsPerHost
during startup in the config file or on the command line. For example:copycopiedmongos --setParameter connPoolMaxShardedInUseConnsPerHost=100
SEE ALSOconnPoolMaxShardedConnsPerHost
shardedConnPoolIdleTimeoutMinutes
New in version 3.6.3.Available for both
mongod
andmongos
.Sets the time limit that a connection in the legacy sharded cluster connection pool can remain idle before being closed.By default, the parameter is unset.You can only setshardedConnPoolIdleTimeoutMinutes
during startup in the config file or on the command line. For example:copycopiedmongos --setParameter shardedConnPoolIdleTimeoutMinutes=10
SEE ALSOconnPoolMaxShardedConnsPerHost
connPoolMaxConnsPerHost
Default: 200Available for both
mongod
andmongos
.Sets the maximum size of the legacy connection pools for outgoing connections to othermongod
instances in the global connection pool. 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 ofconnPoolMaxConnsPerHost
.NOTEThe parameter is separate from the connections in TaskExecutor pools. SeeShardingTaskExecutorPoolMaxSize
.Only adjust this setting if your driver does not pool connections and you’re using authentication in the context of a sharded cluster.You can only setconnPoolMaxConnsPerHost
during startup in the config file or on the command line. For example:copycopiedmongod --setParameter connPoolMaxConnsPerHost=250
connPoolMaxInUseConnsPerHost
New in version 3.6.3.Available for both
mongod
andmongos
.Sets the maximum number of in-use connections at any given time for for outgoing connections to othermongod
instances in the legacy global connection pool.By default, the parameter is unset.You can only setconnPoolMaxInUseConnsPerHost
during startup in the config file or on the command line. For example:copycopiedmongod --setParameter connPoolMaxInUseConnsPerHost=100
SEE ALSOconnPoolMaxConnsPerHost
globalConnPoolIdleTimeoutMinutes
New in version 3.6.3.Available for both
mongod
andmongos
.Sets the time limit that connection in the legacy global connection pool can remain idle before being closed.By default, the parameter is unset.You can only setglobalConnPoolIdleTimeoutMinutes
during startup in the config file or on the command line. For example:copycopiedmongos --setParameter globalConnPoolIdleTimeoutMinutes=10
SEE ALSOconnPoolMaxShardedConnsPerHost
cursorTimeoutMillis
Default: 600000 (i.e. 10 minutes)Available for both
mongod
andmongos
.Sets the expiration threshold in milliseconds for idle cursors before MongoDB removes them; i.e. MongoDB removes cursors that have been idle for the specifiedcursorTimeoutMillis
.For example, the following sets thecursorTimeoutMillis
to300000
milliseconds (i.e. 5 minutes).copycopiedmongod --setParameter cursorTimeoutMillis=300000
Or, if using thesetParameter
command within themongo
shell:copycopieddb.adminCommand( { setParameter: 1, cursorTimeoutMillis: 300000 } )
SettingcursorTimeoutMillis
to less than or equal to0
results in all cursors being immediately eligible for timeout. Generally, the timeout value should be greater than the average amount of time for a query to return results. Use tools like thecursor.explain()
cursor modifier to analyze the average query time and select an appropriate timeout period.failIndexKeyTooLong
Removed in 4.4IMPORTANTMongoDB 4.4 removes the deprecated
failIndexKeyTooLong
parameter. Attempting to use this parameter with MongoDB 4.4 will result in an error.MongoDB 4.2 deprecates thefailIndexKeyTooLong
parameter and removes theIndex Key Length Limit
for featureCompatibilityVersion (fCV) set to"4.2"
or greater.For MongoDB 2.6 through MongoDB versions with featureCompatibilityVersion (fCV) set to"4.0"
or earlier,Index Key Length Limit
applies. If you attempt to insert or update a document whose index field exceeds theIndex Key Length Limit
, the operation will fail and return an error to the client.To avoid this issue, consider using hashed indexes or indexing a computed value. If you have an existing data set and want to disable this behavior so you can upgrade and then gradually resolve these indexing issues, you can usefailIndexKeyTooLong
to disable this behavior.SettingfailIndexKeyTooLong
tofalse
is a temporary workaround, not a permanent solution to the problem of oversized index keys. WithfailIndexKeyTooLong
set tofalse
, queries can return incomplete results if they use indexes that skip over documents whose indexed fields exceed theIndex Key Length Limit
.failIndexKeyTooLong
defaults totrue
.Issue the following command to disable the index key length validation:copycopieddb.adminCommand( { setParameter: 1, failIndexKeyTooLong: false } )
You can also setfailIndexKeyTooLong
at startup time with the following option:copycopiedmongod --setParameter failIndexKeyTooLong=false
notablescan
Available for
mongod
only.Specify whether all queries must use indexes. If1
, MongoDB will not execute queries that require a collection scan and will return an error.Consider the following example which setsnotablescan
to1
or true:copycopieddb.adminCommand( { setParameter: 1, notablescan: 1 } )
Settingnotablescan
to1
can be useful for testing application queries, for example, to identify queries that scan an entire collection and cannot use an index.To detect unindexed queries withoutnotablescan
, consider reading the Evaluate Performance of Current Operations and Optimize Query Performance sections and using thelogLevel
parameter, mongostat and profiling.Don’t run productionmongod
instances withnotablescan
because preventing collection scans can potentially affect queries in all databases, including administrative queries.ttlMonitorEnabled
Available for
mongod
only.To support TTL Indexes,mongod
instances have a background thread that is responsible for deleting documents from collections with TTL indexes.To disable this worker thread for amongod
, setttlMonitorEnabled
tofalse
, as in the following operations:copycopieddb.adminCommand( { setParameter: 1, ttlMonitorEnabled: false } )
Alternately, you may disable the thread at startup time by starting themongod
instance with the following option:copycopiedmongod --setParameter ttlMonitorEnabled=false
tcpFastOpenServer
New in version 4.4.Available for both
mongod
andmongos
.Default:true
Enables support for accepting inbound TCP Fast Open (TFO) connections to themongod/mongos
from a client. TFO requires both the client andmongod/mongos
host machine support and enable TFO:WindowsThe following Windows operating systems support TFO:Microsoft Windows Server 2016 and later.Microsoft Windows 10 Update 1607 and later.macOSmacOS 10.11 (El Capitan) and later support TFO.LinuxLinux operating systems running Linux Kernel 3.7 or later can support inbound TFO.Set the value of/proc/sys/net/ipv4/tcp_fastopen
to enable inbound TFO connections:Set to2
to enable only inbound TFO connections.Set to3
to enable inbound and outbound TFO connections.This parameter has no effect if the host operating system does not support or is not configured to support TFO connections.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.See Support for TCP Fast Open for more information on MongoDB TFO support.SEE ALSORFC7413.tcpFastOpenClient
New in version 4.4.Available for both
mongod
andmongos
.Default:true
Linux Operating System OnlyEnables support for outbound TCP Fast Open (TFO) connections from themongod/mongos
to a client. TFO requires both the client and themongod/mongos
host machine support and enable TFO.Linux operating systems running Linux Kernel 4.11 or later can support outbound TFO.Set the value of/proc/sys/net/ipv4/tcp_fastopen
to enable outbound TFO connections:1
to enable only outbound TFO connections.3
to enable inbound and outbound TFO connections.This parameter has no effect if the host operating system does not support or is not configured to support TFO connections.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.See Support for TCP Fast Open for more information on MongoDB TFO support.SEE ALSORFC7413.tcpFastOpenQueueSize
New in version 4.4.Available for both
mongod
andmongos
.Default:1024
As part of establishing a TCP Fast Open (TFO) connection, the client submits a valid TFO cookie to themongod/mongos
before completion of the standard TCP 3-way handshake. Themongod/mongos
keeps a queue of all such pending TFO connections.ThetcpFastOpenQueueSize
parameter sets the size of the queue of pending TFO connections. While the queue is full, themongod/mongos
falls back to the normal three-way handshake for incoming client requests and ignores the presence of TFO cookies. Once the queue size falls back below the limit, themongod/mongos
begins accepting new TFO cookies.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.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.The minimum queue size is0
. A queue of0
effectively disables TFO.This parameter has no effect on host operating systems that do not support or are not configured for TFO connections. See Support for TCP Fast Open for more information on MongoDB TFO support.SEE ALSORFC7413 TCP Fast Open Section 5: Security ConsiderationsRFC7413 TCP Fast Open Section 6: TFO ApplicabilitydisableJavaScriptJIT
Changed in version 4.0: The JavaScript engine’s JIT compiler is now disabled by default.Available for
mongod
only.The MongoDB JavaScript engine uses SpiderMonkey, which implements Just-in-Time (JIT) compilation for improved performance when running scripts.To enable the JIT, setdisableJavaScriptJIT
tofalse
, as in the following example:copycopieddb.adminCommand( { setParameter: 1, disableJavaScriptJIT: false } )
NOTE$where
will reuse existing JavaScript interpreter contexts, so changes todisableJavaScriptJIT
may not take effect immediately for these operations.Alternately, you may enable the JIT at startup time by starting themongod
instance with the following option:copycopiedmongod --setParameter disableJavaScriptJIT=false
maxIndexBuildMemoryUsageMegabytes
New in version 3.4.**Default:200 (For versions 4.2.3 and later)500 (For versions 4.2.2 and earlier)Limits the amount of memory that simultaneous index builds on one collection may consume for the duration of the builds. The specified amount of memory is shared between all indexes built using a single
createIndexes
command or its shell helperdb.collection.createIndexes()
.The memory consumed by an index build is separate from the WiredTiger cache memory (seecacheSizeGB
).Index builds may be initiated either by a user command such as Create Index or by an administrative process such as an initial sync. Both are subject to the limit set bymaxIndexBuildMemoryUsageMegabytes
.An initial sync operation populates only one collection at a time and has no risk of exceeding the memory limit. However, it is possible for a user to start index builds on multiple collections in multiple databases simultaneously and potentially consume an amount of memory greater than the limit set inmaxIndexBuildMemoryUsageMegabytes
.TIPTo minimize the impact of building an index on replica sets and sharded clusters with replica set shards, use a rolling index build procedure as described on Rolling Index Builds on Replica Sets.Changed in version 4.2.For feature compatibility version (fcv)"4.2"
, the index build memory limit applies to all index builds.For feature compatibility version (fcv)"4.0"
, the index build memory limit only applies to foreground index builds.reportOpWriteConcernCountersInServerStatus
New in version 4.0.6.**Default: falseA boolean flag that determines whether the
db.serverStatus()
method andserverStatus
command returnopWriteConcernCounters
information. [1]You can only setreportOpWriteConcernCountersInServerStatus
during startup in the config file or on the command line. For example:copycopiedmongod --setParameter reportOpWriteConcernCountersInServerStatus=true
[1]EnablingreportOpWriteConcernCountersInServerStatus
can have a negative performance impact; specificaly, when running without TLS.watchdogPeriodSeconds
Available for
mongod
only.Type: integerDefault: -1 (disabled)NOTEStarting in MongoDB 4.2, the Storage Node Watchdog is available in both the Community and MongoDB Enterprise editions.In earlier versions (3.2.16+, 3.4.7+, 3.6.0+, 4.0.0+), the Storage Node Watchdog is only available in MongoDB Enterprise edition.Determines how frequent the Storage Node Watchdog checks the status of the monitored filesystems:The--dbpath
directoryThejournal
directory inside the--dbpath
directory ifjournaling
is enabledThe directory of--logpath
fileThe directory of--auditPath
fileValid values forwatchdogPeriodSeconds
are:-1
(the default), to disable/pause Storage Node Watchdog, orAn integer greater than or equal to 60.NOTEIf a filesystem on a monitored directory becomes unresponsive, it can take a maximum of nearly twice the value ofwatchdogPeriodSeconds
to terminate themongod
.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 themongod
usesstorage.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.To enable Storage Node Watchdog,watchdogPeriodSeconds
must be set during startup.copycopiedmongod --setParameter watchdogPeriodSeconds=60
You can only enable the Storage Node Watchdog at startup. However, once enabled, you can pause the Storage Node Watchdog or change thewatchdogPeriodSeconds
during runtime.Once enabled,To pause the Storage Node Watchdog during runtime, setwatchdogPeriodSeconds
to -1.copycopieddb.adminCommand( { setParameter: 1, watchdogPeriodSeconds: -1 } )
To resume or change the period during runtime, setwatchdogPeriodSeconds
to a number greater than or equal to 60.copycopieddb.adminCommand( { setParameter: 1, watchdogPeriodSeconds: 120 } )
NOTEIt is an error to setwatchdogPeriodSeconds
at runtime if the Storage Node Watchdog was not enabled at startup time.tcmallocReleaseRate
New in version 4.2.3: Also available in 3.6.17+ and 4.0.14+Default: 1.0Specifies the tcmalloc release rate (TCMALLOC_RELEASE_RATE). Per https://gperftools.github.io/gperftools/tcmalloc.htmlruntime TCMALLOC_RELEASE_RATE is described as:Rate at which we release unused memory to the system, via madvise(MADV_DONTNEED), on systems that support it. Zero means we never release memory back to the system. Increase this flag to return memory faster; decrease it to return memory slower. Reasonable rates are in the range [0,10].—https://gperftools.github.io/gperftools/tcmalloc.htmlruntimeTo modify the release rate during runtime, you can use the
setParameter
command; for example:copycopieddb.adminCommand( { setParameter: 1, tcmallocReleaseRate: 5.0 } )
You can also settcmallocReleaseRate
at startup time; for example:copycopiedmongod --setParameter "tcmallocReleaseRate=5.0"
Logging Parameters
logLevel
Available for both
mongod
andmongos
.Specify an integer between0
and5
signifying the verbosity of the logging, where5
is the most verbose. [2]The defaultlogLevel
is0
(Informational).The following example sets thelogLevel
to2
:copycopieddb.adminCommand( { setParameter: 1, logLevel: 2 } )
SEE ALSOlogComponentVerbosity
systemLog.verbosity
[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 logsD2
. In previous versions, MongoDB log messages only specifiedD
for Debug level.logComponentVerbosity
Available for both
mongod
andmongos
.Sets the verbosity levels of various components for log messages. The verbosity level determines the amount of Informational and Debug messages MongoDB outputs. [3]The verbosity level can range from0
to5
:0
is the MongoDB’s default log verbosity level, to include Informational messages.1
to5
increases the verbosity level to include Debug messages.For a component, you can also specify-1
to inherit the parent’s verbosity level.To specify the verbosity level, use a document similar to the following:copycopied{ 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:copycopied{ verbosity: <int>, <component1>: <int> , <component2>: { verbosity: <int>, <component3>: <int> } ... }
The top-levelverbosity
field corresponds tosystemLog.verbosity
which sets the default level for all components. The default value ofsystemLog.verbosity
is0
.The components correspond to the following settings:accessControl
command
control
ftdc
geo
index
network
query
replication
replication.election
replication.heartbeats
replication.initialSync
replication.rollback
recovery
sharding
storage
storage.journal
transaction
write
Unless explicitly set, the component has the verbosity level of its parent. For example,storage
is the parent ofstorage.journal
. That is, if you specify astorage
verbosity level, this level also applies to:storage.journal
components unless you specify the verbosity level forstorage.journal
.storage.recovery
components unless you specify the verbosity level forstorage.recovery
.For example, the following sets thedefault verbosity level
to1
, thequery
to2
, thestorage
to2
, and thestorage.journal
to1
.copycopieddb.adminCommand( { setParameter: 1, logComponentVerbosity: { verbosity: 1, query: { verbosity: 2 }, storage: { verbosity: 2, journal: { verbosity: 1 } } } } )
You can also set parameterlogComponentVerbosity
at startup time, passing the verbosity level document as a string.copycopiedmongod --setParameter "logComponentVerbosity={command: 3}"
Themongo
shell also 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.[3]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 logsD2
. In previous versions, MongoDB log messages only specifiedD
for Debug level.maxLogSizeKB
New in version 3.4.Available for both
mongod
andmongos
.Type: non-negative integerDefault: 10Specifies the maxium 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 themaxLogSizeKB
limit and excise field content past that limit, retaining valid JSON formating. Log entires that contain truncated attributes append atruncated
object to the end of the log entry.See log message truncation for more information.A value of0
disables truncation entirely. Negative values for this parameter are not valid.WARNINGUsing a large value, or disabling truncation with a value of0
, may adversely affect system performance and negatively impact database operations.The following example sets the maximum log line size to20
kilobytes:copycopiedmongod --setParameter maxLogSizeKB=20
quiet
Available for both
mongod
andmongos
.Sets quiet logging mode. If1
,mongod
will go into a quiet logging mode which will not log the following events/activities:connection events;thedrop
command, thedropIndexes
command, thediagLogging
command, thevalidate
command, and theclean
command; andreplication synchronization activities.Consider the following example which sets thequiet
to1
:copycopieddb.adminCommand( { setParameter: 1, quiet: 1 } )
SEE ALSOsystemLog.quiet
redactClientLogData
New in version 3.4.Available for both
mongod
andmongos
.Type: booleanENTERPRISE FEATUREAvailable in MongoDB Enterprise only.Configure themongod
ormongos
to redact any message accompanying a given log event before logging. This prevents the program from writing potentially sensitive data stored on the database to the diagnostic log. Metadata such as error or operation codes, line numbers, and source file names are still visible in the logs.UseredactClientLogData
in conjunction with Encryption at Rest and TLS/SSL (Transport Encryption) to assist compliance with regulatory requirements.To enable log redaction on a runningmongod
ormongos
, use the following command:copycopieddb.adminCommand( { setParameter: 1, redactClientLogData : true } )
SEE ALSOsecurity.redactClientLogData
traceExceptions
Available for both
mongod
andmongos
.Configuresmongod
to log full source code stack traces for every database and socket C++ exception, for use with debugging. Iftrue
,mongod
will log full stack traces.Consider the following example which sets thetraceExceptions
totrue
:copycopieddb.adminCommand( { setParameter: 1, traceExceptions: true } )
SEE ALSOsystemLog.traceAllExceptions
suppressNoTLSPeerCertificateWarning
New in version 4.0.1.Available for both
mongod
andmongos
.Type: booleanDefault: falseBy default, amongod
ormongos
with TLS/SSL enabled andnet.ssl.allowConnectionsWithoutCertificates
:true
lets clients connect without providing a certificate for validation while logging an warning. SetsuppressNoTLSPeerCertificateWarning
to1
ortrue
to suppress those warnings.The following operation setssuppressNoTLSPeerCertificateWarning
totrue
:copycopieddb.adminCommand( { setParameter: 1, suppressNoTLSPeerCertificateWarning: true} )
Diagnostic Parameters
To facilitate analysis of the MongoDB server behavior by MongoDB engineers, MongoDB logs server statistics to diagnostic files at periodic intervals.
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.
diagnosticDataCollectionEnabled
New in version 3.2.**Changed in version 3.4.14: Available for both
mongod
andmongos
.Type: booleanDefault: trueDetermines whether to enable the collecting and logging of data for diagnostic purposes. Diagnostic logging is enabled by default.For example, the following disables the diagnostic collection:copycopiedmongod --setParameter diagnosticDataCollectionEnabled=false
diagnosticDataCollectionDirectoryPath
New in version 3.4.14.**Type: StringAvailable for
mongos
only.Specify the directory for the diagnostic directory formongos
. If the directory does not exist,mongos
creates the directory.If unspecified, the diagnostic data directory is computed by truncating themongos
instance’s--logpath
orsystemLog.path
file extension(s) and concatenatingdiagnostic.data
.For example, ifmongos
has--logpath /var/log/mongodb/mongos.log.201708015
, then the diagnostic data directory is/var/log/mongodb/mongos.diagnostic.data/
.IMPORTANTIfmongos
cannot create the specified directory, e.g. a file exists with the same name in the path or the process does not have permissions to create the directory, the diagnostic data capture will be disabled for that instance.diagnosticDataCollectionDirectorySizeMB
New in version 3.2.**Changed in version 3.4: Increased default size to 200 megabytes.Changed in version 3.4.14: Available for both
mongod
andmongos
.Type: integerDefault: 200Specifies the maximum size, in megabytes, of thediagnostic.data
directory. If directory size exceeds this number, the oldest diagnostic files in the directory are automatically deleted based on the timestamp in the file name.For example, the following sets the maximum size of the directory to250
megabytes:copycopiedmongod --setParameter diagnosticDataCollectionDirectorySizeMB=250
The minimum value fordiagnosticDataCollectionDirectorySizeMB
is10
megabytes.diagnosticDataCollectionDirectorySizeMB
must be greater than maximum diagnostic file sizediagnosticDataCollectionFileSizeMB
.diagnosticDataCollectionFileSizeMB
New in version 3.2.**Changed in version 3.4.14: Available for both
mongod
andmongos
.Type: integerDefault: 10Specifies the maximum size, in megabytes, of each diagnostic file. If the file exceeds the maximum file size, MongoDB creates a new file.For example, the following sets the maximum size of each diagnostic file to20
megabytes:copycopiedmongod --setParameter diagnosticDataCollectionFileSizeMB=20
The minimum value fordiagnosticDataCollectionFileSizeMB
is1
megabyte.diagnosticDataCollectionPeriodMillis
New in version 3.2.**Changed in version 3.4.14: Available for both
mongod
andmongos
.Type: integerDefault: 1000Specifies the interval, in milliseconds, at which to collect diagnostic data.For example, the following sets the interval to5000
milliseconds or 5 seconds:copycopiedmongod --setParameter diagnosticDataCollectionPeriodMillis=5000
The minimum value fordiagnosticDataCollectionPeriodMillis
is100
milliseconds.Logical Session
logicalSessionRefreshMillis
AVAILABILITYNew in version 4.0.4 (and version 3.6.9).Available for both
mongod
andmongos
.Type: integerDefault: 300000 (i.e. 5 minutes)The interval (in milliseconds) at which the cache refreshes its logical session records against the main session store.You can only setlogicalSessionRefreshMillis
at startup and cannot change this setting with thesetParameter
command.For example, to set thelogicalSessionRefreshMillis
for amongod
instance to 10 minutes:copycopiedmongod --setParameter logicalSessionRefreshMillis=600000
localLogicalSessionTimeoutMinutes
New in version 3.6.Available for both
mongod
andmongos
.Type: integerDefault: 30FOR TESTING PURPOSES ONLYThis 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 withrefreshSessions
within this threshold are cleared from the cache. State associated with an expired session may be cleaned up by the server at any time.This parameter applies only to the instance on which it is set. To set this parameter on replica sets and sharded clusters, you must specify the same value on every member; otherwise, sessions will not function properly.You can only setlocalLogicalSessionTimeoutMinutes
at startup and cannot change this setting with thesetParameter
command.For example, to set thelocalLogicalSessionTimeoutMinutes
for a testmongod
instance to 20 minutes:copycopiedmongod --setParameter localLogicalSessionTimeoutMinutes=20
maxAcceptableLogicalClockDriftSecs
New in version 3.6.Available for both
mongod
andmongos
.Type: integerDefault: 31536000 (1 year)The maximum amount by which the current cluster time can be advanced; i.e.,maxAcceptableLogicalClockDriftSecs
is the maximum difference between the new value of the cluster time and the current cluster time. Cluster time is a logical time used for ordering of operations.You cannot advance the cluster time to a new value if the new cluster time differs from the current cluster time by more thanmaxAcceptableLogicalClockDriftSecs
,You can only setmaxAcceptableLogicalClockDriftSecs
at startup and cannot change this setting with thesetParameter
command.For example, to set themaxAcceptableLogicalClockDriftSecs
for amongod
instance to 15 minutes:copycopiedmongod --setParameter maxAcceptableLogicalClockDriftSecs=900
maxSessions
New in version 4.0.1.Available for both
mongod
andmongos
.Type: integerDefault: 1000000The maximum number of sessions that can be cached.You can only setmaxSessions
during start-up.For example, to set themaxSessions
for amongod
instance to 1000:copycopiedmongod --setParameter maxSessions=1000
TransactionRecordMinimumLifetimeMinutes
New in version 3.6.Available for
mongod
only.Type: integerDefault: 30The minimum lifetime a transaction record exists in thetransactions
collection before the record becomes eligible for cleanup.You can only setTransactionRecordMinimumLifetimeMinutes
at startup and cannot change this setting with thesetParameter
command.For example, to set theTransactionRecordMinimumLifetimeMinutes
for amongod
instance to 20 minutes:copycopiedmongod --setParameter TransactionRecordMinimumLifetimeMinutes=20
SEE ALSOlocalLogicalSessionTimeoutMinutes
Replication Parameters
enableFlowControl
New in version 4.2.**Type: booleanDefault: trueEnables or disables the mechanism that controls the rate at which the primary applies its writes with the goal of keeping the secondary members’
majority committed
lag under a configurable maximum value.NOTEFor flow control to engage, the replica set/sharded cluster must have: featureCompatibilityVersion (FCV) of4.2
and read concernmajority enabled
. That is, enabled flow control has no effect if FCV is not4.2
or if read concern majority is disabled.flowControlTargetLagSeconds
New in version 4.2.**Type: integerDefault: 10The target maximum
majority committed
lag when running with flow control. When flow control is enabled, the mechanism attempts to keep themajority committed
lag under the specified seconds. The parameter has no effect if flow control is disabled.The specified value must be greater than 0.In general, the default settings should suffice; however, if modifying from the default value, decreasing, rather than increasing, the value may prove to be more useful.flowControlWarnThresholdSeconds
New in version 4.2.**Type: integerDefault: 10The 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.
initialSyncTransientErrorRetryPeriodSeconds
New in version 4.4.**Type: integerDefault: 86400The 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.
initialSyncSourceReadPreference
New in version 4.4.**Type: StringAvailable for
mongod
only.The preferred source for performing initial sync. Specify one of the following read preference modes:primary
primaryPreferred
(Default for voting replica set members)secondary
secondaryPreferred
nearest
(Default for newly added or non-voting replica set members)If the replica set has disabledchaining
, the defaultinitialSyncSourceReadPreference
read preference mode isprimary
.You cannot specify a tag set ormaxStalenessSeconds
toinitialSyncSourceReadPreference
.If themongod
cannot find a sync source based on the specified read preference, it logs an error and restarts the initial sync process. Themongod
exits with an error if it cannot complete the initial sync process after10
attempts. For more information on sync source selection, see Initial Sync Source Selection.initialSyncSourceReadPreference
takes precedence over the replica set’ssettings.chainingAllowed
setting when selecting an initial sync source. After a replica set member successfully completes initial sync, it defers to the value ofchainingAllowed
when selecting a replication sync source.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.oplogFetcherUsesExhaust
New in version 4.4.Available for
mongod
only.Type: booleanDefault: trueEnables or disables streaming replication. Set the value totrue
to enable streaming replication.Set the value tofalse
to disable streaming replication. If disabled, secondaries fetch batches of oplog entries by issuing a request to their sync from source and waiting for a response. This requires a network roundtrip for each batch of oplog entries.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.oplogInitialFindMaxSeconds
New in version 3.6.**Type: integerDefault: 60Available for
mongod
only.Maximum time in seconds for a member of a replica set to wait for thefind
command to finish during data synchronization.replWriterThreadCount
New in version 3.2.**Type: integerDefault: 16Available for
mongod
only.Number of threads to use to apply replicated operations in parallel. Values can range from 1 to 256 inclusive. You can only setreplWriterThreadCount
at startup and cannot change this setting with thesetParameter
command.rollbackTimeLimitSecs
Type: 64-bit integerDefault: 86400 (1 day)Maximum age of data that can be rolled back. Negative values for this parameter are not valid.Starting in MongoDB 4.2+ and 4.0.13+, if the time between the end of the to-be-rolledback instance’s oplog and the first operation after the common point (the last point where the source node and the to-be-rolledback node had the same data) exceeds this value, the rollback will fail.In MongoDB 4.0.0-4.0.12, if the time between the end of the to-be-rolledback instance’s oplog and the common point (the last point where the source node and the to-be-rolledback node had the same data) exceeds this value, the rollback will fail.To effectively have an unlimited rollback period, set the value to
2147483647
which is the maximum value allowed and equivalent to roughly 68 years.New in version 4.0.waitForSecondaryBeforeNoopWriteMS
New in version 3.6.Available for
mongod
only.Type: integerDefault: 10The length of time (in milliseconds) that a secondary must wait if theafterClusterTime
is greater than the last applied time from the oplog. After thewaitForSecondaryBeforeNoopWriteMS
passes, if theafterClusterTime
is still greater than the last applied time, the secondary makes a no-op write to advance the last applied time.The following example sets thewaitForSecondaryBeforeNoopWriteMS
to 20 milliseconds:copycopiedmongod --setParameter waitForSecondaryBeforeNoopWriteMS=20
During runtime, you can also set the parameter with thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, waitForSecondaryBeforeNoopWriteMS: 20 } )
createRollbackDataFiles
Available for
mongod
only.Type: booleanDefault: trueNew in version 4.0.Flag that determines whether MongoDB creates rollback files that contains documents affected during a rollback.By default,createRollbackDataFiles
istrue
and MongoDB creates the rollback files.The following example setscreateRollbackDataFiles
to false so that the rollback files are not created:copycopiedmongod --setParameter createRollbackDataFiles=false
During runtime, you can also set the parameter with thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, createRollbackDataFiles: false } )
For more information, see Collect Rollback Data.enableElectionHandoff
New in version 4.0.2.**Type: booleanDefault: trueA flag that can reduce the downtime after the primary steps down from either the
rs.stepDown()
method or thereplSetStepDown
command. Specifically, if true, when a primary steps down afterrs.stepDown()
(or thereplSetStepDown
command without theforce: true
), it nominates an eligible secondary to call an election immediately. If false, after the step down, secondaries can wait up tosettings.electionTimeoutMillis
before calling an election.An eligible secondary must be caught up with the stepped down primary and havepriority
greater than 0. If multiple secondary members meet this criteria, the stepped down primary selects the eligible secondary with the highestpriority
. If the more than one eligible secondary members have the samepriority
, the stepped down primary selects the secondary with the lowest_id
. The stepped down primary does not wait for the effects of the handoff.The parameter has no impact if the primary steps down for reasons other thanrs.stepDown()
(or thereplSetStepDown
command without theforce: true
).replBatchLimitBytes
Default: 104857600 (100MB)Sets the maximum oplog application batch size in bytes.Values can range from 16777216 (16MB) to 104857600 (100MB) inclusive.The following example sets
replBatchLimitBytes
to 64 MB so that the rollback files are not created:copycopiedmongod --setParameter replBatchLimitBytes=67108864
During runtime, you can also set the parameter with thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, replBatchLimitBytes: 64 * 1024 * 1024 } )
New in version 4.0.10.mirrorReads
Available for
mongod
only.New in version 4.4**Type: DocumentDefault:{ samplingRate: 0.01, maxTimeMS: 1000 }
Specifies the settings for mirrored reads for themongod
instance. The settings only take effect when the member is a primary.The parametermirrorReads
takes a JSON document with the following fields:FieldDescriptionsamplingRate
The sampling rate used to mirror a subset of operations that support mirroring to a subset of electable (i.e.priority greater than 0
) secondaries. That is, the primary mirrors reads to each electable secondary at the specified sampling rate.Valid values are:0.0
Turns off mirroring.1.0
The primary mirrors all operations that supports mirroring to each electable secondary.Number between0.0
and1.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 of0.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 receives100
operations that can be mirrored, the sampling rate of0.10
may result in8
reads being mirrored to one secondary and13
reads to the other or10
to each, etc.The default value is0.01
.maxTimeMS
The maximum time in milliseconds for the mirrored reads. The default value is1000
.ThemaxTimeMS
for the mirrored reads is separate from themaxTimeMS
of the original read being mirrored.You can setmirrorReads
during startup in theconfiguration file
or with the--setParameter
option on the command line. If specifying from the configuration file or on the command line, enclose themirrorReads
document in quotes.For example, the following sets the mirror reads sampling rate to0.10
from the command line:copycopiedmongod --setParameter mirrorReads='{ samplingRate: 0.10 }'
Or, to specify in a configuration file:copycopiedsetParameter: mirrorReads: '{samplingRate: 0.10}'
Or if using thesetParameter
command in amongo
shell connected to a runningmongod
, do not enclose the document in quotes:copycopieddb.adminCommand( { setParameter: 1, mirrorReads: { samplingRate: 0.10 } } )
Sharding Parameters
NOTE
Starting in version 4.2, MongoDB removes the parameter AsyncRequestsSenderUseBaton
and always enables the performance enhancement controlled by the parameter.
disableResumableRangeDeleter
New in version 4.4.**Type: booleanDefault: falseAvailable for
mongod
only.If set on a shard’s primary, specifies if range deletion is paused on the shard. If set totrue
, cleanup of chunkranges containing :term:
orphaned documents is paused. The shard can continue to donate chunks to other shards, but the donated documents will not be removed from this shard until you set this parameter 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.rangeDeletions
collection that overlaps with the incoming chunk’s range.WhendisableResumableRangeDeleter
istrue
, 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 themongod
if it is not the shard’s primary.IMPORTANTIf you setdisableResumableRangeDeleter
parameter 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.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongod --setParameter disableResumableRangeDeleter=false
enableShardedIndexConsistencyCheck
New in version 4.4 (and 4.2.6).**Type: booleanDefault: trueAvailable for
mongod
only.If set on the config server’s primary, enables or disables the index consistency check for sharded collections. The parameter has no effect on themongod
if it is not the config server’s primary.The following example setsenableShardedIndexConsistencyCheck
tofalse
for a config server primary:copycopiedmongod --setParameter enableShardedIndexConsistencyCheck=false
During runtime, you can also set the parameter with thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, enableShardedIndexConsistencyCheck: false } )
SEE ALSOshardedIndexConsistencyCheckIntervalMS
parametershardedIndexConsistency
metrics returned by theserverStatus
command.shardedIndexConsistencyCheckIntervalMS
New in version 4.4 (and 4.2.6).**Type: integerDefault: 600000Available for
mongod
only.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 themongod
if it is not the config server’s primary.You can only set the parameter during startup, and cannot change this setting using thesetParameter
database command.For example, the following sets the interval at 300000 milliseconds (i.e. 5 minutes) at startup:copycopiedmongod --setParameter shardedIndexConsistencyCheckIntervalMS=300000
SEE ALSOenableShardedIndexConsistencyCheck
parametershardedIndexConsistency
metrics returned by theserverStatus
commandqenableFinerGrainedCatalogCacheRefresh
New in version 4.4.**Type: booleanDefault: trueAvailable for both
mongod
andmongos
.This parameter allows the catalog cache to be refreshed only if the shard needs to be refreshed. If disabled, any stale chunk will cause the entire chunk distribution for a collection to be considered stale and force all routers who contact the shard to refresh their shard catalog cache.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongod --setParameter enableFinerGrainedCatalogCacheRefresh=true mongos --setParameter enableFinerGrainedCatalogCacheRefresh=true
SEE ALSOShardingshardingStatistics.catalogCache
maxTimeMSForHedgedReads
New in version 4.4.**Type: integerDefault: 150Available for
mongos
only.Specifies the maximimum time limit (in milliseconds) for the hedged read. That is, the additional read sent to hedge the read operation uses themaxTimeMS
value ofmaxTimeMSForHedgedReads
while the read operation that is being hedged uses themaxTimeMS
value specified for the operation.For example, to set the limit to 200 milliseconds, you can issue the following during startup:copycopiedmongos --setParameter maxTimeMSForHedgedReads=200
Or if using thesetParameter
command in amongo
shell connected to a runningmongos
:copycopieddb.adminCommand( { setParameter: 1, maxTimeMSForHedgedReads: 200 } )
SEE ALSOreadHedgingMode
Hedged ReadsreadHedgingMode
New in version 4.4.**Type: stringDefault: onAvailable for
mongos
only.Specifies whethermongos
supports hedged reads for those read operations whose read preference have enabled the hedged read option.Available values are:ValueDescriptionon
Themongos
instance supports hedged reads for read operations whose read preference have enabled the hedged read option.off
Themongos
instance does not support hedged reads. That is, hedged reads are unavailable, even for read operations whose read preference have enabled the hedged read option.For example, to turn off hedged read support for amongos
instance, you can issue the following during startup:copycopiedmongos --setParameter readHedgingMode=off
Or if using thesetParameter
command in amongo
shell connected to a runningmongos
:copycopieddb.adminCommand( { setParameter: 1, readHedgingMode: "off" } )
SEE ALSOHedged ReadsmaxTimeMSForHedgedReads
replMonitorMaxFailedChecks
Available in MongoDB 3.2 onlyType: integerDefault: 30The number of times the
mongod
ormongos
instance tries to reach the replica sets in the sharded cluster (e.g. shard replica sets, config server replica set) to monitor the replica set status and topology.When the number of consecutive unsuccessful attempts exceeds this parameter value, themongod
ormongos
instance denotes the monitored replica set as unavailable. If the monitored replica set is the config server replica set:For MongoDB 3.2.0-3.2.9, the monitoringmongod
ormongos
instance will become unusable and needs to be restarted. See the v3.2 troubleshooting guide for more details.For MongoDB 3.2.10 and later 3.2-series, see alsotimeOutMonitoringReplicaSets
.timeOutMonitoringReplicaSets
Available in MongoDB 3.2.10 and later 3.2-series onlyType: integerDefault: falseThe flag that determines whether the
mongod
ormongos
instance should stop its attempt to reach the monitored replica set after unsuccessfully tryingreplMonitorMaxFailedChecks
number of times.If the monitored replica set is the config server replica set andtimeOutMonitoringReplicaSets
is set totrue
, you must restartmongod
ormongos
if themongod
ormongos
instance cannot reach any of the config servers for the specified number of times. See the v3.2 troubleshooting guide for more details.ShardingTaskExecutorPoolHostTimeoutMS
Type: integerDefault: 300000 (i.e. 5 minutes)Available for
mongos
only.Maximum time thatmongos
goes without communication to a host beforemongos
drops all connections to the host.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.If set,ShardingTaskExecutorPoolHostTimeoutMS
should be greater than the sum ofShardingTaskExecutorPoolRefreshRequirementMS
andShardingTaskExecutorPoolRefreshTimeoutMS
. Otherwise,mongos
adjusts the value ofShardingTaskExecutorPoolHostTimeoutMS
to be greater than the sum.copycopiedmongos --setParameter ShardingTaskExecutorPoolHostTimeoutMS=120000
ShardingTaskExecutorPoolMaxConnecting
New in version 3.6.Type: integerDefault: 2Available for
mongos
only.Maximum number of simultaneous initiating connections (including pending connections in setup/refresh state) each TaskExecutor connection pool can have to amongod
instance. You can set this parameter to control the rate at whichmongos
adds connections to amongod
instance.If set,ShardingTaskExecutorPoolMaxConnecting
should be less than or equal toShardingTaskExecutorPoolMaxSize
. If it is greater,mongos
ignores theShardingTaskExecutorPoolMaxConnecting
value.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongos --setParameter ShardingTaskExecutorPoolMaxConnecting=20
ShardingTaskExecutorPoolMaxSize
Type: integerDefault: 264 - 1Available for
mongos
only.Maximum number of outbound connections each TaskExecutor connection pool can open to any givenmongod
instance. The maximum possible connections to any given host across all TaskExecutor pools is:copycopiedShardingTaskExecutorPoolMaxSize * taskExecutorPoolSize
You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongos --setParameter ShardingTaskExecutorPoolMaxSize=4
mongos
can have up ton
TaskExecutor connection pools, wheren
is the number of cores. SeetaskExecutorPoolSize
.SEE ALSOShardingTaskExecutorPoolMinSize
ShardingTaskExecutorPoolMinSize
Type: integerDefault: 1Available for both
mongod
andmongos
.Minimum number of outbound connections each TaskExecutor connection pool can open to any givenmongod
instance.ShardingTaskExecutorPoolMinSize
connections are created the first time a connection to a new host is requested from the pool. While the pool is idle, the pool maintains this number of connections untilShardingTaskExecutorPoolHostTimeoutMS
milliseconds pass without any application using that pool.For amongos
using thewarmMinConnectionsInShardingTaskExecutorPoolOnStartup
parameter, theShardingTaskExecutorPoolMinSize
parameter also controls how many connections to each shard host are established on startup of themongos
instance before it begins accepting incoming client connections.NOTEIn MongoDB 4.4, thewarmMinConnectionsInShardingTaskExecutorPoolOnStartup
parameter is enabled by default for themongos
.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongos --setParameter ShardingTaskExecutorPoolMinSize=2
mongos
can have up ton
TaskExecutor connection pools, wheren
is the number of cores. SeetaskExecutorPoolSize
.SEE ALSOShardingTaskExecutorPoolMaxSize
warmMinConnectionsInShardingTaskExecutorPoolOnStartup
ShardingTaskExecutorPoolRefreshRequirementMS
Type: integerDefault: 60000 (1 minute)Available for
mongos
only.Maximum time themongos
waits before attempting to heartbeat a resting connection in the pool.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.If set,ShardingTaskExecutorPoolRefreshRequirementMS
should be greater thanShardingTaskExecutorPoolRefreshTimeoutMS
. Otherwise,mongos
adjusts the value ofShardingTaskExecutorPoolRefreshTimeoutMS
to be less thanShardingTaskExecutorPoolRefreshRequirementMS
.copycopiedmongos --setParameter ShardingTaskExecutorPoolRefreshRequirementMS=90000
ShardingTaskExecutorPoolRefreshTimeoutMS
Type: integerDefault: 20000 (20 seconds)Available for
mongos
only.Maximum time themongos
waits for a heartbeat before timing out the heartbeat.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.If set,ShardingTaskExecutorPoolRefreshTimeoutMS
should be less thanShardingTaskExecutorPoolRefreshRequirementMS
. Otherwise,mongos
adjusts the value ofShardingTaskExecutorPoolRefreshTimeoutMS
to be less thanShardingTaskExecutorPoolRefreshRequirementMS
.copycopiedmongos --setParameter ShardingTaskExecutorPoolRefreshTimeoutMS=30000
ShardingTaskExecutorPoolReplicaSetMatching
New in version 4.2.Type: stringDefault: “matchPrimaryNode”Available for
mongos
only.The policy that determines the minimum size limit of themongos
instance’s connection pools to the sharded cluster’s replica set secondaries.Available values are:Matching PolicyDescription"matchPrimaryNode"
(Default)For each replica set in the sharded cluster (i.e. shard replica set and config servers), the minimum size limit of themongos
instance’s connection pool to each secondary of that replica set is equal to the size of its connection pool to the primary.In case of primary stepdown,matchPrimaryNode
ensures that any secondary that becomes the primary can handle the current level of primary reads and writes."matchBusiestNode"
For each replica set in the sharded cluster (i.e. shard replica set and config servers), the minimum size limit of themongos
instance’s connection pool to each member of that replica set is equal to the largest among the active connections counts to the primary and each secondary members.With"matchBusiestNode"
,mongos
maintains enough connections to each secondary to handle the current level of primary and secondary reads and writes. The number of connections to maintain in the pool decreases as the number of active connections decreases."disabled"
For each replica set in the sharded cluster (i.e. shard replica set and config servers), the minimum number of connections in themongos
instance’s connection pool to each secondary is equal to theShardingTaskExecutorPoolMinSize
.The following example sets theShardingTaskExecutorPoolReplicaSetMatching
to"matchBusiestNode"
during startup:copycopiedmongod --setParameter ShardingTaskExecutorPoolReplicaSetMatching="matchBusiestNode"
During runtime, you can also set the parameter with thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, ShardingTaskExecutorPoolReplicaSetMatching: "matchBusiestNode" } )
taskExecutorPoolSize
Changed in version 4.0.Type: integerDefault: 1Available for
mongos
only.The number of Task Executor connection pools to use for a givenmongos
.If the parameter value is0
or less, the number of Task Executor connection pools is the number of cores with the following exceptions:If the number of cores is less than 4, the number of Task Executor connection pools is 4.If the number of cores is greater than 64, the number of Task Executor connection pools is 64.Starting in MongoDB 4.0, the default value oftaskExecutorPoolSize
is1
:In MongoDB 4.0 deployment, you can settaskExecutorPoolSize
to0
and, on Linux, set AsyncRequestsSenderUseBaton tofalse
for the previous behavior.In MongoDB 4.2+ deployment, MongoDB removes theAsyncRequestsSenderUseBaton
parameter and always enables the performance enhancement controlled by the parameter.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongos --setParameter taskExecutorPoolSize=6
SEE ALSOShardingTaskExecutorPoolMaxSize
ShardingTaskExecutorPoolMinSize
loadRoutingTableOnStartup
New in version 4.4.Type: booleanDefault: trueAvailable for
mongos
only.Configures amongos
instance to preload the routing table for a sharded cluster on startup. With this setting enabled, themongos
caches the cluster-wide routing table for each sharded collection as part of its startup procedure, before it begins accepting client connections.Without this setting enabled, themongos
only loads a routing table as needed for incoming client connections, and only loads the specific routing table for the namespace of a given request.Amongos
instance with theloadRoutingTableOnStartup
parameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.loadRoutingTableOnStartup
is enabled by default.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.warmMinConnectionsInShardingTaskExecutorPoolOnStartup
New in version 4.4.Type: booleanDefault: trueAvailable for
mongos
only.Configures amongos
instance to prewarm its connection pool on startup. With this parameter enabled, themongos
attempts to establishShardingTaskExecutorPoolMinSize
network connections to each shard server as part of its startup procedure, before it begins accepting client connections.A timeout for this behavior can be configured with thewarmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS
parameter. If this timeout is reached, themongos
will begin accepting client connections regardless of the size of its connection pool.Amongos
instance with this parameter enabled may experience longer startup times, but will result in faster servicing of initial client connections once started.warmMinConnectionsInShardingTaskExecutorPoolOnStartup
is enabled by default.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.SEE ALSOwarmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS
ShardingTaskExecutorPoolMinSize
warmMinConnectionsInShardingTaskExecutorPoolOnStartupWaitMS
New in version 4.4.Type: integerDefault: 2000 (i.e. 2 seconds)Available for
mongos
only.Sets the timeout threshold in milliseconds for amongos
to wait forShardingTaskExecutorPoolMinSize
connections to be established per shard host when using thewarmMinConnectionsInShardingTaskExecutorPoolOnStartup
parameter. If this timeout is reached, themongos
will begin accepting client connections regardless of the size of its connection pool.You can only set this parameter on startup, using either thesetParameter
configuration file setting or the--setParameter
command line option.SEE ALSOwarmMinConnectionsInShardingTaskExecutorPoolOnStartup
ShardingTaskExecutorPoolMinSize
migrateCloneInsertionBatchDelayMS
New in version 4.0.5: The parameter is also available starting in 3.4.18 and 3.6.10Available for
mongod
only.Type: Non-negative integerDefault: 0Time in milliseconds to wait between batches of insertions during cloning step of the migration process. This wait is in addition to thesecondaryThrottle
.The default value of0
indicates no additional wait.The following sets themigrateCloneInsertionBatchDelayMS
to 200 milliseconds:copycopiedmongod --setParameter migrateCloneInsertionBatchDelayMS=200
The parameter may also be set using thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, migrateCloneInsertionBatchDelayMS: 200 } )
migrateCloneInsertionBatchSize
New in version 4.0.5: The parameter is also available starting in 3.4.18 and 3.6.10Available for
mongod
only.Type: Non-negative integerDefault: 0The maximum number of documents to insert in a single batch during the cloning step of the migration process.The default value of0
indicates no maximum number of documents per batch. However, in practice, this results in batches that contain up to 16 MB of documents.The following sets themigrateCloneInsertionBatchSize
to 100 documents:copycopiedmongod --setParameter migrateCloneInsertionBatchSize=100
The parameter may also be set using thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, migrateCloneInsertionBatchSize: 100 } )
orphanCleanupDelaySecs
New in version 3.6.Default: 900 (15 minutes)Available for
mongod
only.Minimum delay before a migrated chunk is deleted from the source shard.Before deleting the chunk during chunk migration, MongoDB waits fororphanCleanupDelaySecs
or for in-progress queries involving the chunk to complete on the shard primary, whichever is longer.However, because the shard primary has no knowledge of in-progress queries run on the shard secondaries, queries that use the chunk but are run on secondaries may see documents disappear if these queries take longer than the time to complete the shard primary queries and theorphanCleanupDelaySecs
.NOTEThis behavior only affects in-progress queries that start before the chunk migration. Queries that start after the chunk migration starts will not use the migrating chunk.If a shard has storage constraints, consider reducing this value temporarily. If running queries that exceed 15 minutes on shard secondaries, consider increasing this value.The following sets theorphanCleanupDelaySecs
to 20 minutes:copycopiedmongod --setParameter orphanCleanupDelaySecs=1200
This may also be set using thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, orphanCleanupDelaySecs: 1200 } )
rangeDeleterBatchDelayMS
New in version 4.0.1: The parameter is also available starting in 3.4.17 and 3.6.7.Available for
mongod
only.Type: Non-negative integerDefault: 20The amount of time in milliseconds to wait before the next batch of deletion during the cleanup stage of chunk migration (or thecleanupOrphaned
command).In MongoDB 3.4, consider whether _secondaryThrottle is set before modifying therangeDeleterBatchDelayMS
. In MongoDB 3.4, the _secondaryThrottle replication delay occurs after each document deletion instead of after the batch deletion.In MongoDB 3.6+, the _secondaryThrottle replication delay occurs after each batch deletion.The following sets therangeDeleterBatchDelayMS
to 200 milliseconds:copycopiedmongod --setParameter rangeDeleterBatchDelayMS=200
The parameter may also be set using thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, rangeDeleterBatchDelayMS: 200 } )
rangeDeleterBatchSize
New in version 4.0.5: The parameter is also available starting in 3.4.19 and 3.6.10Available for
mongod
only.Type: Non-negative integerDefault: 0The maximum number of documents in each batch to delete during the cleanup stage of chunk migration (or thecleanupOrphaned
command).The default value of0
indicates that the system chooses an appropriate value, generally 128 documents.The following sets therangeDeleterBatchSize
to 100 documents:copycopiedmongod --setParameter rangeDeleterBatchSize=100
The parameter may also be set using thesetParameter
command:copycopieddb.adminCommand( { setParameter: 1, rangeDeleterBatchSize: 100 } )
skipShardingConfigurationChecks
New in version 3.6.3.Available for
mongod
only.Type: booleanDefault: falseWhentrue
, allows for starting a shard member or config server member as a standalone for maintenance operations. This parameter is mutually exclusive with the--configsvr
or--shardsvr
options.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongod --setParameter skipShardingConfigurationChecks=true
IMPORTANTOnce maintenance has completed, remove theskipShardingConfigurationChecks
parameter when restarting themongod
.The parameter is also available for MongoDB versions:MongoDB 3.2.19+MongoDB 3.4.11+Storage Parameters
journalCommitInterval
Available for
mongod
only.Specify an integer between1
and500
signifying the number of milliseconds (ms) between journal commits.Consider the following example which sets thejournalCommitInterval
to200
ms:copycopieddb.adminCommand( { setParameter: 1, journalCommitInterval: 200 } )
SEE ALSOstorage.journal.commitIntervalMs
syncdelay
Available for
mongod
only.Specify the interval in seconds between fsync operations wheremongod
flushes its working memory to disk. By default,mongod
flushes memory to disk every 60 seconds. In almost every situation you should not set this value and use the default setting.Consider the following example which sets thesyncdelay
to60
seconds:copycopieddb.adminCommand( { setParameter: 1, syncdelay: 60 } )
SEE ALSOjournalCommitInterval
storage.syncPeriodSecs
honorSystemUmask
New in version 3.6.Available for
mongod
only.Default:false
IfhonorSystemUmask
is set totrue
, new files created by MongoDB have permissions in accordance with the user’sumask
settings. You cannot setprocessUmask
ifhonorSystemUmask
is set totrue
.IfhonorSystemUmask
is 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 useprocessUmask
to override the default permissions for groups and other users on all new files created by MongoDB.You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.copycopiedmongod --setParameter honorSystemUmask=true
NOTEhonorSystemUmask
is not available on Windows systems.processUmask
New in version 4.4.Available for
mongod
only.Overrides the default permissions used for groups and other users whenhonorSystemUmask
is set tofalse
. By default, whenhonorSystemUmask
is set tofalse
, new files created by MongoDB have permissions set to600
. Use theprocessUmask
parameter to override this default with a customumask
value. The file owner inherits permissions from the systemumask
.You cannot set this parameter ifhonorSystemUmask
is set totrue
. You can only set this parameter during start-up and cannot change this setting using thesetParameter
database command.Consider the following example, which sets the permissions for groups and other users to read/write only and retains the systemumask
settings for the owner:copycopiedmongod --setParameter processUmask=011
NOTEprocessUmask
is not available on Windows systems.WiredTiger Parameters
wiredTigerMaxCacheOverflowSizeGB
DEPRECATED IN MONGODB 4.4MongoDB deprecates the
wiredTigerMaxCacheOverflowSizeGB
parameter. The parameter has no effect starting in MongoDB 4.4.Default: 0 (No specified maximum)Available formongod
only.Specify the maximum size (in GB) for the “lookaside (or cache overflow) table” fileWiredTigerLAS.wt
for MongoDB 4.2.1-4.2.x and 4.0.12-4.0.x. The file no longer exists starting in version 4.4.The parameter can accept the following values:ValueDescription0
The default value. If set to0
, the file size is unbounded.number >= 0.1The maximum size (in GB). If theWiredTigerLAS.wt
file exceeds this size,mongod
exits with a fatal assertion. You can clear theWiredTigerLAS.wt
file and restartmongod
.You can only set this parameter during runtime using thesetParameter
database command:copycopieddb.adminCommand( { setParameter: 1, wiredTigerMaxCacheOverflowSizeGB: 100 } )
To set the maximum size during start up, use thestorage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB
instead.Available starting in MongoDB 4.2.1 (and 4.0.12)wiredTigerConcurrentReadTransactions
Available for
mongod
only.Available for the WiredTiger storage engine only.Specify the maximum number of concurrent read transactions allowed into the WiredTiger storage engine.copycopieddb.adminCommand( { setParameter: 1, wiredTigerConcurrentReadTransactions: <num> } )
SEE ALSOwiredTiger.concurrentTransactions
wiredTigerConcurrentWriteTransactions
Available for
mongod
only.Available for the WiredTiger storage engine only.Specify the maximum number of concurrent write transactions allowed into the WiredTiger storage engine.copycopieddb.adminCommand( { setParameter: 1, wiredTigerConcurrentWriteTransactions: <num> } )
SEE ALSOwiredTiger.concurrentTransactions
wiredTigerEngineRuntimeConfig
Available for
mongod
only.SpecifywiredTiger
storage engine configuration options for a runningmongod
instance. You can only set this parameter using thesetParameter
command and not using the command line or configuration file option.WARNINGAvoid modifying thewiredTigerEngineRuntimeConfig
unless under the direction from MongoDB engineers as this setting has major implication across both WiredTiger and MongoDB.Consider the following operation prototype:copycopieddb.adminCommand({ "setParameter": 1, "wiredTigerEngineRuntimeConfig": "<option>=<setting>,<option>=<setting>" })
See the WiredTiger documentation for all available WiredTiger configuration options.Auditing Parameters
auditAuthorizationSuccess
Default:
false
NOTEAvailable only in MongoDB Enterprise and MongoDB Atlas.Available for bothmongod
andmongos
.Enables the auditing of authorization successes for the authCheck action.WhenauditAuthorizationSuccess
isfalse
, the audit system only logs the authorization failures forauthCheck
.To enable the audit of authorization successes, issue the following command:copycopieddb.adminCommand( { setParameter: 1, auditAuthorizationSuccess: true } )
EnablingauditAuthorizationSuccess
degrades performance more than logging only the authorization failures.
SEE ALSO
Transaction Parameters
transactionLifetimeLimitSeconds
New in version 4.0.Available for
mongod
only.Default: 60Specifies the lifetime of multi-document transactions. Transactions that exceeds this limit are considered expired and will be aborted by a periodic cleanup process. The cleanup process runs everytransactionLifetimeLimitSeconds
/2 seconds or at least once per every 60 seconds.The cleanup process helps relieve storage cache pressure.The minimum value for transactionLifetimeLimitSeconds is1
second.The following sets thetransactionLifetimeLimitSeconds
to30
seconds:copycopieddb.adminCommand( { setParameter: 1, transactionLifetimeLimitSeconds: 30 } )
You can also set parametertransactionLifetimeLimitSeconds
at startup time.copycopiedmongod --setParameter "transactionLifetimeLimitSeconds=30"
To set the parameter for a sharded cluster, the parameter must be modified for all shard replica set members.maxTransactionLockRequestTimeoutMillis
New in version 4.0.Available for
mongod
only.Type: integerDefault: 5The 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 waitingmaxTransactionLockRequestTimeoutMillis
, the transaction aborts.By default, multi-document transactions wait5
milliseconds. That is, if the transaction cannot acquire the locks within5
milliseconds, the transaction aborts. If an operation provides a greater timeout in a lock request,maxTransactionLockRequestTimeoutMillis
overrides the operation-specific timeout.You can setmaxTransactionLockRequestTimeoutMillis
to:0
such that if the transaction cannot acquire the required locks immediately, the transaction aborts.A number greater than0
to wait the specified time to acquire the required locks. This can help obviate transaction aborts on momentary concurrent lock acquisitions, like fast-running metadata operations. However, this could possibly delay the abort of deadlocked transaction operations.-1
to use the operation specific timeout.The following sets themaxTransactionLockRequestTimeoutMillis
to20
milliseconds:copycopieddb.adminCommand( { setParameter: 1, maxTransactionLockRequestTimeoutMillis: 20 } )
You can also set this parameter during start-up:copycopiedmongod --setParameter maxTransactionLockRequestTimeoutMillis=20
shouldMultiDocTxnCreateCollectionAndIndexes
New in version 4.4.**Type: booleanDefault: trueA flag that enables or disables the creation of a collection or an index inside transactions. Set the parameter to:
true
to enable. (Default)false
to disable.You can set the parameter during startup or runtime.IMPORTANTWhen setting the parameter for a sharded cluster, set the parameter on all shards.To set the parameter at startup, specify the parameter in theconfiguration file
or with the--setParameter
option on the command line. For example:copycopiedmongod --setParameter shouldMultiDocTxnCreateCollectionAndIndexes=false
To modify during runtime, you can use thesetParameter
command; for example:copycopieddb.adminCommand( { setParameter: 1, shouldMultiDocTxnCreateCollectionAndIndexes: false
参见