- Reference >
- MongoDB Server Parameters
MongoDB Server Parameters¶
On this page
Synopsis¶
MongoDB provides a number of configuration options that are accessible
via the setParameter
command or --setParameter
option.s
For additional run time configuration options, see Configuration File Options and Manual Page for mongod.
Parameters¶
Authentication Parameters¶
-
authenticationMechanisms
¶ Available for MongoDB Enterprise Only
Changed in version 2.6: Added support for the
PLAIN
andMONGODB-X509
authentication mechanisms.Available for both
mongod
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.
Value Description MONGODB-CR MongoDB challenge/response authentication. MONGODB-X509 MongoDB TLS/SSL certificate authentication. PLAIN External authentication using LDAP. You can also use PLAIN
for authenticating in-database users.PLAIN
transmits passwords in plain text. This mechanism is available only in MongoDB Enterprise.GSSAPI External authentication using Kerberos. This mechanism is available only in MongoDB Enterprise. For example, to specify
PLAIN
as the authentication mechanism, use the following command:
-
clusterAuthMode
¶ New in version 2.6.
Available for both
mongod
andmongos
.Set the
clusterAuthMode
to eithersendX509
orx509
. Useful during rolling upgrade to use x509 for membership authentication to minimize downtime.The default distribution of MongoDB does not contain support for TLS/SSL. To use TLS/SSL you can either compile MongoDB with TLS/SSL support or use MongoDB Enterprise. See Configure mongod and mongos for TLS/SSL for more information about TLS/SSL and MongoDB.
-
enableLocalhostAuthBypass
¶ New in version 2.4.
Available for both
mongod
andmongos
.Specify
0
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.
-
saslauthdPath
¶ Note
Available only in MongoDB Enterprise (except MongoDB Enterprise for Windows).
Specify the path to the Unix Domain Socket of the
saslauthd
instance to use for proxy authentication.
-
saslHostName
¶ New in version 2.4.
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 set
saslHostName
during start-up, and cannot change this setting using thesetParameter
database command.Note
saslHostName
supports Kerberos authentication and is only included in MongoDB Enterprise. For Linux systems, see Configure MongoDB with Kerberos Authentication on Linux for more information.
-
saslServiceName
¶ New in version 2.4.6.
Allows users to override the default Kerberos service name component of the Kerberos principal name, on a per-instance basis. If unspecified, the default value is
mongodb
.MongoDB only permits setting
saslServiceName
at startup. ThesetParameter
command can not change this setting.saslServiceName
is only available in MongoDB Enterprise.Important
Ensure that your driver supports alternate service names.
-
sslMode
¶ New in version 2.6.
Available for both
mongod
andmongos
.Set the
net.ssl.mode
to eitherpreferSSL
orrequireSSL
. Useful during rolling upgrade to TLS/SSL to minimize downtime.The default distribution of MongoDB does not contain support for TLS/SSL. To use TLS/SSL you can either compile MongoDB with TLS/SSL support or use MongoDB Enterprise. See Configure mongod and mongos for TLS/SSL for more information about TLS/SSL and MongoDB.
-
supportCompatibilityFormPrivilegeDocuments
¶ New in version 2.4.
Deprecated since version 2.6:
supportCompatibilityFormPrivilegeDocuments
has no effect in 2.6 and will be removed in 3.0.Available for both
mongod
andmongos
.supportCompatibilityFormPrivilegeDocuments
is not available usingsetParameter
database command. Use thesetParameter
option in the configuration file or the--setParameter
option on the command line.
-
userCacheInvalidationIntervalSecs
¶ New in version 2.6.
Default: 600.
Available for
mongos
only.On a
mongos
instance, this specifies the amount of time in seconds to allow before themongos
instance purges the in-memory cache of user objects. The cache includes the users’ credentials and roles.This parameter has a minimum value of
30
seconds and a maximum value of86400
seconds (24 hours).
General Parameters¶
-
connPoolMaxShardedConnsPerHost
¶ New in version 2.6.
Default: 200
Available for both
mongod
andmongos
.Set the maximum size of the 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.
Increase the
connPoolMaxShardedConnsPerHost
value only if the number of connections in a connection pool has a high level of churn or if the total number of created connections increase.You can only set
connPoolMaxShardedConnsPerHost
during startup in the config file or on the command line, as follows to increase the size of the connection pool:
-
connPoolMaxConnsPerHost
¶ New in version 2.6.
Default: 200
Available for both
mongod
andmongos
.Set the maximum size of the connection pools for outgoing connections to other
mongod
instances. 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
.Only adjust this setting if your driver does not pool connections and you’re using authentication in the context of a sharded cluster.
You can only set
connPoolMaxConnsPerHost
during startup in the config file or on the command line, as in the following example:
-
cursorTimeoutMillis
¶ New in version 2.6.9.
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 specified
cursorTimeoutMillis
.For example, the following sets the
cursorTimeoutMillis
to300000
milliseconds (i.e. 5 minutes).Or, if using the
setParameter
command within themongo
shell:
-
failIndexKeyTooLong
¶ New in version 2.6.
Available for
mongod
only.In MongoDB 2.6, if you attempt to insert or update a document so that the value of an indexed field is longer than the
Index Key Length Limit
, the operation will fail and return an error to the client. In previous versions of MongoDB, these operations would successfully insert or modify a document but the index or indexes would not include references to the document.To avoid this issue, consider using hashed indexes or indexing a computed value. If you have an existing data set and want to disable this behavior so you can upgrade and then gradually resolve these indexing issues, you can use
failIndexKeyTooLong
to disable this behavior.failIndexKeyTooLong
defaults totrue
. Whenfalse
, a 2.6mongod
instance will provide the 2.4 behavior.Issue the following command to disable the index key length validation: for a running:binary:~bin.mongod instance:
You can also set
failIndexKeyTooLong
at run-time with the following operation.
-
notablescan
¶ Available for
mongod
only.Specify whether all queries must use indexes. If
1
, MongoDB will not execute queries that require a collection scan and will return an error.Consider the following example which sets
notablescan
to1
or true:Setting
notablescan
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 without
notablescan
, consider reading the Evaluate Performance of Current Operations and Optimize Query Performance sections and using thelogLevel
parameter, mongostat and profiling.Don’t run production
mongod
instances withnotablescan
because preventing collection scans can potentially affect queries in all databases, including administrative queries.
-
newCollectionsUsePowerOf2Sizes
¶ New in version 2.6.
Default:
true
.Available for
mongod
only.mongod
uses an allocation strategy calledusePowerOf2Sizes
where each record has a size, in bytes that is a power of 2 (e.g. 32, 64, 128, 256, 512…16777216.) The minimum allocation for a document is 32 bytes.MongoDB stores documents in contiguous spaces on disk, and each record includes both the document itself and some additional space to allow the document to grow slightly through updates.
By default, all new collections, created after 2.6 use the
usePowerOf2Sizes
strategy. To revert to the prior exact fit allocation strategy, setnewCollectionsUsePowerOf2Sizes
tofalse
.New collections include those: created during initial sync, as well as those created by the
mongorestore
andmongoimport
tools, by runningmongod
with the--repair
option, as well as therestoreDatabase
command.Issue the following command to change the allocation strategy for a running
mongod
instance:You can also set
newCollectionsUsePowerOf2Sizes
at run-time with the following operation.
-
releaseConnectionsAfterResponse
¶ New in version 2.2.4: and 2.4.2
Available for both
mongod
andmongos
.Changes the behavior of the connection pool that
mongos
uses to connect to the shards. As a result, eachmongos
should need to maintain fewer connections to each shard. When enabled, themongos
will release a connection into the thread pool after each read operation or command.Warning
For applications that do not use the default, journaled, or replica acknowledged write concern modes of the driver,
releaseConnectionsAfterResponse
will affect the meaning ofgetLastError
.If an application allows read operations in between write operations and
getLastError
calls, the resultinggetLastError
will not report on the success of the proceeding write operation.Use with caution.
To enable, use the following command while connected to a
mongos
:Alternately, you may start the
mongos
instance with the following run-time option:To change this policy for the entire cluster, you must set
releaseConnectionsAfterResponse
on eachmongos
instance in the cluster.
-
textSearchEnabled
¶ Deprecated since version 2.6: MongoDB enables the text search feature by default. Manual enabling of this feature is unnecessary.
Available for both
mongod
andmongos
.Enables the text search feature. When manually enabling, you must enable on each and every
mongod
for replica sets.
-
ttlMonitorEnabled
¶ New in version 2.4.6.
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 a
mongod
, setttlMonitorEnabled
tofalse
, as in the following operations:Alternately, you may disable the thread at run-time by starting the
mongod
instance with the following option:
Logging Parameters¶
-
logLevel
¶ Available for both
mongod
andmongos
.Specify an integer between
0
and5
signifying the verbosity of the logging, where5
is the most verbose.Consider the following example which sets the
logLevel
to2
:The default
logLevel
is0
.See also
-
logUserIds
¶ New in version 2.4.
Available for both
mongod
andmongos
.Specify
1
to enable logging of userids.Disabled by default.
-
quiet
¶ Available for both
mongod
andmongos
.Sets quiet logging mode. If
1
,mongod
will go into a quiet logging mode which will not log the following events/activities:- connection events;
- the
drop
command, thedropIndexes
command, thediagLogging
command, thevalidate
command, and theclean
command; and - replication synchronization activities.
Consider the following example which sets the
quiet
to1
:See also
Replication Parameters¶
-
replApplyBatchSize
¶ Available for
mongod
only.Specify the number of oplog entries to apply as a single batch.
replApplyBatchSize
must be an integer between 1 and 1024. The default value is 1. This option only applies to master/slave configurations and is valid only on amongod
started with the--slave
command line option.Batch sizes must be
1
for members withslavedelay
configured.
-
replIndexPrefetch
¶ New in version 2.2.
Available for
mongod
only.Use
replIndexPrefetch
in conjunction withreplSetName
when configuring a replica set. The default value isall
and available options are:none
all
_id_only
By default secondary members of a replica set will load all indexes related to an operation into memory before applying operations from the oplog. You can modify this behavior so that the secondaries will only load the
_id
index. Specify_id_only
ornone
to prevent themongod
from loading any index into memory.
Storage Parameters¶
-
journalCommitInterval
¶ Specify an integer between
1
and500
signifying the number of milliseconds (ms) between journal commits.Consider the following example which sets the
journalCommitInterval
to200
ms:See also
-
syncdelay
¶ Available for
mongod
only.Specify the interval in seconds between fsync operations where
mongod
flushes its working memory to disk. By default,mongod
flushes memory to disk every 60 seconds. In almost every situation you should not set this value and use the default setting.Consider the following example which sets the
syncdelay
to60
seconds:See also
Auditing Parameters¶
-
auditAuthorizationSuccess
¶ Note
Available only in MongoDB Enterprise.
New in version 2.6.5.
Default:
false
Enables the auditing of authorization successes for the authCheck action.
When
auditAuthorizationSuccess
isfalse
, the audit system only logs the authorization failures forauthCheck
.To enable the audit of authorization successes, issue the following command:
Enabling
auditAuthorizationSuccess
degrades performance more than logging only the authorization failures.