Docs HomeMongoDB Manual

Configuration File Options配置文件选项

The following page describes the configuration options available in MongoDB 6.0. For configuration file options for other versions of MongoDB, see the appropriate version of the MongoDB Manual.下页介绍了MongoDB 6.0中可用的配置选项。有关其他版本MongoDB的配置文件选项,请参阅相应版本的MongoDB手册。

Configuration File配置文件

You can configure mongod and mongos instances at startup using a configuration file. 您可以在启动时使用配置文件配置mongodmongos实例。The configuration file contains settings that are equivalent to the mongod and mongos command-line options. 配置文件包含与mongodmongos命令行选项等效的设置。See Configuration File Settings and Command-Line Options Mapping.请参见配置文件设置和命令行选项映射

Using a configuration file makes managing mongod and mongos options easier, especially for large-scale deployments. 使用配置文件可以更容易地管理mongodmongos选项,尤其是对于大规模部署。You can also add comments to the configuration file to explain the server's settings.您也可以在配置文件中添加注释来解释服务器的设置。

  • If you installed MongoDB with a package manager such as yum or apt on Linux or brew on macOS, or with the MSI installer on Windows, a default configuration file has been provided as part of your installation:如果您在Linux上使用诸如yumapt之类的软件包管理器安装MongoDB,或在macOS上使用brew,或在Windows上使用MSI安装程序安装,则会在安装过程中提供默认配置文件:

    PlatformMethod方法Configuration File配置文件
    Linuxapt, yum, or zypper Package Manageraptyumzypper软件包管理器/etc/mongod.conf
    macOSbrew Package Manager/usr/local/etc/mongod.conf (on Intel processors), or(在英特尔处理器上),或
    /opt/homebrew/etc/mongod.conf (on Apple M1 processors) (在Apple M1处理器上)
    WindowsMSI Installer<install directory>\bin\mongod.cfg
  • If you installed MongoDB via a downloaded TGZ or ZIP file, you will need to create your own configuration file. 如果您通过下载的TGZZIP文件安装MongoDB,则需要创建自己的配置文件。The basic example configuration is a good place to start.基本示例配置是一个很好的起点。

File Format文件格式

MongoDB configuration files use the YAML format MongoDB配置文件使用YAML格式[1].

The following sample configuration file contains several mongod settings that you may adapt to your local configuration:以下示例配置文件包含几个mongod设置,您可以根据本地配置进行调整:

Note

YAML does not support tab characters for indentation: use spaces instead.YAML不支持使用制表符进行缩进:请使用空格。

systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
logAppend: true
processManagement:
fork: true
net:
bindIp: 127.0.0.1
port: 27017
setParameter:
enableLocalhostAuthBypass: false
...

The Linux package init scripts included in the official MongoDB packages depend on specific values for systemLog.path, storage.dbPath, and processManagement.fork. If you modify these settings in the default configuration file, mongod may not start.官方MongoDB包中包含的Linux包init脚本取决于systemLog.pathstorage.dbPathprocessManagement.fork的特定值。如果在默认配置文件中修改这些设置,mongod可能不会启动。

[1] YAML is a superset of JSON.YAML是JSON的超集。

Externally Sourced Values外部来源值

New in version 4.2:4.2版新增:MongoDB supports using expansion directives in configuration files to load externally sourced values. MongoDB支持在配置文件中使用扩展指令来加载外部来源的值。Expansion directives can load values for specific configuration file options or load the entire configuration file.扩展指令可以加载特定配置文件选项的值,也可以加载整个配置文件。

The following expansion directives are available:以下扩展指令可用:

Expansion Directive扩展指令Description描述
__restAllows users to specify a REST endpoint as the external source for configuration file options or the full configuration file.允许用户将REST端点指定为配置文件选项或完整配置文件的外部源。
If the configuration file includes the __rest expansion, on Linux/macOS, the read access to the configuration file must be limited to the user running the mongod / mongos process only. 如果配置文件包括__rest扩展,则在Linux/macOS上,对配置文件的读取访问权限必须仅限于运行mongod/mongos进程的用户。
__execAllows users to specify a shell or terminal command as the external source for configuration file options or the full configuration file.允许用户将shell或终端命令指定为配置文件选项或完整配置文件的外部源。
If the configuration file includes the __exec expansion, on Linux/macOS, the write access to the configuration file must be limited to the user running the mongod / mongos process only. 如果配置文件包括__exec扩展,则在Linux/macOS上,对配置文件的写访问权限必须仅限于运行mongod/mongos进程的用户。

For complete documentation, see Externally Sourced Configuration File Values.有关完整文档,请参阅外部源配置文件值

Use the Configuration File使用配置文件

To configure mongod or mongos using a config file, specify the config file with the --config option or the -f option, as in the following examples:要使用配置文件配置mongodmongos,请使用--config选项或-f选项指定配置文件,如下例所示:

For example, the following uses mongod --config <configuration file> mongos --config <configuration file>:例如,以下使用mongod --config <configuration file> mongos --config <configuration file>

mongod --config /etc/mongod.conf

mongos --config /etc/mongos.conf

You can also use the -f alias to specify the configuration file, as in the following:您也可以使用-f别名来指定配置文件,如下所示:

mongod -f /etc/mongod.conf

mongos -f /etc/mongos.conf

If you installed from a package and have started MongoDB using your system's init script, you are already using a configuration file.如果您是从一个包中安装的,并且已经使用系统的init脚本启动了MongoDB,那么您已经在使用一个配置文件。

Expansion Directives and 扩展指令和--configExpand

If you are using expansion directives in the configuration file, you must include the --configExpand option when starting the mongod or mongos. 如果在配置文件中使用扩展指令,则在启动mongodmongos时必须包含--configExpand选项。For example:例如:

mongod --config /etc/mongod.conf  --configExpand "rest,exec"
mongos --config /etc/mongos.conf --configExpand "rest,exec"

If the configuration file includes an expansion directive and you start the mongod / mongos without specifying that directive in the --configExpand option, the mongod / mongos fails to start.如果配置文件包含一个扩展指令,并且您在没有在--configExpand选项中指定该指令的情况下启动mongod/mongos,则mongod/mongos无法启动。

For complete documentation, see Externally Sourced Configuration File Values.有关完整文档,请参阅外部源配置文件值

Core Options核心选项

systemLog Options

systemLog:
verbosity: <int>
quiet: <boolean>
traceAllExceptions: <boolean>
syslogFacility: <string>
path: <string>
logAppend: <boolean>
logRotate: <string>
destination: <string>
timeStampFormat: <string>
component:
accessControl:
verbosity: <int>
command:
verbosity: <int>

# COMMENT additional component verbosity settings omitted for brevity
systemLog.verbosity

Type: integer

Default: 0

The default log message verbosity level for components. 组件的默认日志消息详细级别。The verbosity level determines the amount of Informational and Debug messages MongoDB outputs. 详细级别决定MongoDB输出的信息和调试消息的数量。[2]

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

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

To use a different verbosity level for a named component, use the component's verbosity setting. 若要对命名组件使用不同的详细级别,请使用该组件的详细级别设置。For example, use the systemLog.component.accessControl.verbosity to set the verbosity level specifically for ACCESS components.例如,使用systemLog.component.accessControl.verbosity专门为ACCESS组件设置详细级别。

See the systemLog.component.<name>.verbosity settings for specific component verbosity settings.请参阅systemLog.component.<name>.verbosity特定组件详细信息设置的详细信息设置。

For various ways to set the log verbosity level, see Configure Log Verbosity Levels.有关设置日志详细级别的各种方法,请参阅配置日志详细级别

[2] Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. 从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs D2. 例如,如果详细级别为2,MongoDB将记录D2In previous versions, MongoDB log messages only specified D for Debug level.在以前的版本中,MongoDB日志消息只为调试级别指定了D
systemLog.quiet

Type: boolean

Default: false

Run mongos or mongod in a quiet mode that attempts to limit the amount of output.在安静模式下运行mongosmongod,尝试限制输出量。

systemLog.quiet is not recommended for production systems as it may make tracking problems during particular connections much more difficult.systemLog.quiet建议用于生产系统,因为它可能会使跟踪特定连接期间的问题更加困难。

systemLog.traceAllExceptions

Type: boolean

Default: false

Print verbose information for debugging. Use for additional logging for support-related troubleshooting.打印详细信息以进行调试。用于其他日志记录以进行与支持相关的故障排除。

systemLog.syslogFacility

Type: string

Default: user

The facility level used when logging messages to syslog. 将消息记录到系统日志时使用的设施级别。The value you specify must be supported by your operating system's implementation of syslog. 操作系统的syslog实现必须支持您指定的值。To use this option, you must set systemLog.destination to syslog.要使用此选项,必须将systemLog.destination设置为syslog

systemLog.path

Type: string

The path of the log file to which mongod or mongos should send all diagnostic logging information, rather than the standard output or the host's syslog. MongoDB creates the log file at the specified path.mongodmongos应向其发送所有诊断日志信息的日志文件的路径,而不是标准输出或主机的syslog。MongoDB在指定的路径创建日志文件。

The Linux package init scripts do not expect systemLog.path to change from the defaults. Linux包init脚本不希望systemLog.path从默认值更改。If you use the Linux packages and change systemLog.path, you will have to use your own init scripts and disable the built-in scripts.如果您使用Linux软件包并更改systemLog.path,则必须使用自己的init脚本并禁用内置脚本。

systemLog.logAppend

Type: boolean

Default: false

When true, mongos or mongod appends new entries to the end of the existing log file when the mongos or mongod instance restarts. 当为true时,mongosmongod实例重新启动时,会在现有日志文件的末尾添加新条目。Without this option, mongod will back up the existing log and create a new file.如果没有此选项,mongod将备份现有日志并创建一个新文件。

systemLog.logRotate

Type: string

Default: rename

Determines the behavior for the logRotate command when rotating the server log and/or the audit log. 确定在旋转服务器日志和/或审核日志时logRotate命令的行为。Specify either rename or reopen:指定renamereopen

  • rename renames the log file.重命名日志文件。
  • reopen closes and reopens the log file following the typical Linux/Unix log rotate behavior. 按照典型的Linux/Unix日志旋转行为关闭并重新打开日志文件。Use reopen when using the Linux/Unix logrotate utility to avoid log loss.使用Linux/Unix logrotate实用程序时请使用reopen以避免日志丢失。

    If you specify reopen, you must also set systemLog.logAppend to true.如果指定reopen,还必须将systemLog.logAppend设置为true

systemLog.destination

Type: string

The destination to which MongoDB sends all log output. MongoDB将所有日志输出发送到的目的地。Specify either file or syslog. 指定filesyslogIf you specify file, you must also specify systemLog.path.如果指定file,则还必须指定systemLog.path

If you do not specify systemLog.destination, MongoDB sends all log output to standard output.如果没有指定systemLog.destination,MongoDB会将所有日志输出发送到标准输出。

Warning

The syslog daemon generates timestamps when it logs a message, not when MongoDB issues the message. syslog守护进程在记录消息时生成时间戳,而不是在MongoDB发出消息时生成。This can lead to misleading timestamps for log entries, especially when the system is under heavy load. 这可能会导致日志条目的时间戳产生误导,尤其是当系统负载过重时。We recommend using the file option for production systems to ensure accurate timestamps.我们建议生产系统使用file选项,以确保准确的时间戳。

systemLog.timeStampFormat

Type: string

Default: iso8601-local

The time format for timestamps in log messages. Specify one of the following values:日志消息中时间戳的时间格式。指定以下值之一:

ValueDescription描述
iso8601-utcDisplays timestamps in Coordinated Universal Time (UTC) in the ISO-8601 format. 以ISO-8601格式显示协调世界时(UTC)的时间戳。For example, for New York at the start of the Epoch: 例如,大纪元初期的纽约:1970-01-01T00:00:00.000Z
iso8601-localDisplays timestamps in local time in the ISO-8601 format. 以ISO-8601格式显示本地时间的时间戳。For example, for New York at the start of the Epoch: 例如,大纪元初期的纽约:1969-12-31T19:00:00.000-05:00
Note

Starting in MongoDB 4.4, systemLog.timeStampFormat no longer supports ctime. An example of ctime formatted date is: Wed Dec 31 18:17:54.811.从MongoDB 4.4开始,systemLog.timeStampFormat不再支持ctimectime格式日期的示例是:Wed Dec 31 18:17:54.811

systemLog.component Options

systemLog:
component:
accessControl:
verbosity: <int>
command:
verbosity: <int>

# COMMENT some component verbosity settings omitted for brevity

replication:
verbosity: <int>
election:
verbosity: <int>
heartbeats:
verbosity: <int>
initialSync:
verbosity: <int>
rollback:
verbosity: <int>
storage:
verbosity: <int>
journal:
verbosity: <int>
recovery:
verbosity: <int>
write:
verbosity: <int>
Note

Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. 从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs D2. In previous versions, MongoDB log messages only specified D for Debug level.例如,如果详细级别为2,MongoDB将记录D2。在以前的版本中,MongoDB日志消息只为调试级别指定了D

systemLog.component.accessControl.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to access control. 与访问控制相关的组件的日志消息详细级别。See ACCESS components.请参阅ACCESS组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.command.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to commands. 与命令相关的组件的日志消息详细级别。See COMMAND components.请参见COMMAND组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.control.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to control operations. 与控制操作相关的组件的日志消息详细级别。See CONTROL components.请参阅CONTROL组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.ftdc.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to diagnostic data collection operations. See FTDC components.与诊断数据集合操作相关的组件的日志消息详细级别。请参阅FTDC组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.geo.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to geospatial parsing operations. 与地理空间分析操作相关的组件的日志消息详细级别。See GEO components.请参见GEO组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.index.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to indexing operations. 与索引操作相关的组件的日志消息详细级别。See INDEX components.请参见INDEX组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.network.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to networking operations. 与网络操作相关的组件的日志消息详细级别。See NETWORK components.请参阅NETWORK组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.query.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to query operations. 与查询操作相关的组件的日志消息详细级别。See QUERY components.请参阅QUERY组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.replication.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to replication. 与复制相关的组件的日志消息详细级别。See REPL components.请参见REPL组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.replication.election.verbosity

Type: integer

Default: 0

New in version 4.2. 4.2版新增。

The log message verbosity level for components related to election. See ELECTION components.与选举相关的组件的日志消息详细级别。请参见ELECTION组件。

If systemLog.component.replication.election.verbosity is unset, systemLog.component.replication.verbosity level also applies to election components.如果未设置systemLog.component.replication.election.verbosity,则systemLog.component.replication.verbosity级别也适用于选举组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.replication.heartbeats.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to heartbeats. 与检测信号相关的组件的日志消息详细级别。See REPL_HB components.请参见REPL_HB组件。

If systemLog.component.replication.heartbeats.verbosity is unset, systemLog.component.replication.verbosity level also applies to heartbeats components.如果未设置systemLog.component.replication.heartbeats.verbosity,则systemLog.component.replication.verbosity级别也适用于检测信号组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.replication.initialSync.verbosity

Type: integer

Default: 0

New in version 4.2. 4.2版新增。

The log message verbosity level for components related to initialSync. 与initialSync相关的组件的日志消息详细级别。See INITSYNC components.请参阅INITSYNC组件。

If systemLog.component.replication.initialSync.verbosity is unset, systemLog.component.replication.verbosity level also applies to initialSync components.如果未设置systemLog.component.replication.initialSync.verbosity,则systemLog.component.replication.verbosity级别也适用于initialSync组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.replication.rollback.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to rollback. 与回滚相关的组件的日志消息详细级别。See ROLLBACK components.请参见ROLLBACK组件。

If systemLog.component.replication.rollback.verbosity is unset, systemLog.component.replication.verbosity level also applies to rollback components.如果未设置systemLog.component.replication.rollback.verbosity,则systemLog.component.replication.verbosity级别也适用于回滚组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.sharding.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to sharding. 与分片相关的组件的日志消息详细级别。See SHARDING components.请参阅SHARDING组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to storage. 与存储相关的组件的日志消息详细级别。See STORAGE components.请参阅STORAGE组件。

If systemLog.component.storage.journal.verbosity is unset, systemLog.component.storage.verbosity level also applies to journaling components.如果未设置systemLog.component.storage.journal.verbosity,则systemLog.component.storage.verbosity级别也适用于日志组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.journal.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to journaling. 与日志记录相关的组件的日志消息详细级别。See JOURNAL components.请参阅JOURNAL组件。

If systemLog.component.storage.journal.verbosity is unset, the journaling components have the same verbosity level as the parent storage components: i.e. either the systemLog.component.storage.verbosity level if set or the default verbosity level.如果未设置systemLog.component.storage.journal.verbosity,则日志记录组件与父存储组件具有相同的详细级别:即,如果设置了systemLog.component.storage.verbosity级别,则为默认详细级别。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.recovery.verbosity

Type: integer

Default: 0

New in version 4.0. 4.0版新增。

The log message verbosity level for components related to recovery. 与恢复相关的组件的日志消息详细级别。See RECOVERY components.请参阅RECOVERY组件。

If systemLog.component.storage.recovery.verbosity is unset, systemLog.component.storage.verbosity level also applies to recovery components.如果未设置systemLog.component.storage.recovery.verbosity,则systemLog.component.storage.verbosity级别也适用于恢复组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity level for components related to the WiredTiger storage engine. WiredTiger存储引擎相关的组件的日志消息详细级别。See WT components.请参见WT组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtBackup.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity level for components related to backup operations performed by the WiredTiger storage engine. See WTBACKUP components.WiredTiger存储引擎执行的备份操作相关的组件的日志消息详细级别。请参阅WTBACKUP组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtCheckpoint.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to checkpoint operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的检查点操作相关的组件的日志消息详细信息。See WTCHKPT components.请参见WTCHKPT组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtCompact.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to compaction operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的压缩操作相关的组件的日志消息详细信息。See WTCMPCT components.请参阅WTCMPCT组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtEviction.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to eviction operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的逐出操作相关的组件的日志消息详细信息。See WTEVICT components.请参阅WTEVICT组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtHS.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to history store operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的历史存储操作相关的组件的日志消息详细信息。See WTHS components.请参阅WTHS组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtRecovery.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to recovery operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的恢复操作相关的组件的日志消息详细信息。See WTRECOV components.请参阅WTRECOV组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtRTS.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to rollback to stable (RTS) operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的回滚到稳定(RTS)操作相关的组件的日志消息详细信息。See WTRTS components.请参阅WTRTS组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtSalvage.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to salvage operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的回收操作相关的组件的日志消息详细信息。See WTSLVG components.请参阅WTSLVG组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtTiered.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to tiered storage operations performed by the WiredTiger storage engine.WiredTiger存储引擎执行的分层存储操作相关的组件的日志消息详细信息。 See WTTIER components.请参阅WTTIER组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtTimestamp.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to timestamps used by the WiredTiger storage engine. WiredTiger存储引擎使用的时间戳相关的组件的日志消息详细信息。See WTTS components.请参阅WTTS组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtTransaction.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to transaction operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的事务操作相关的组件的日志消息详细信息。See WTTXN components.请参阅WTTXN组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtVerify.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to verification operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的验证操作相关的组件的日志消息详细信息。See WTVRFY components.请参阅WTVRFY组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.storage.wt.wtWriteLog.verbosity

Type: integer

Default: -1

New in version 5.3. 5.3版新增。

The log message verbosity for components related to log write operations performed by the WiredTiger storage engine. WiredTiger存储引擎执行的日志写入操作相关的组件的日志消息详细信息。See WTWRTLOG components.请参阅WTWRTLOG组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.transaction.verbosity

Type: integer

Default: 0

New in version 4.0.2. 4.0.2版新增。

The log message verbosity level for components related to transaction. 与事务相关的组件的日志消息详细级别。See TXN components.请参阅TXN组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

  • 0 is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。
  • 1 to 5 increases the verbosity level to include Debug messages.15增加了详细级别以包括调试消息。
systemLog.component.write.verbosity

Type: integer

Default: 0

The log message verbosity level for components related to write operations. 与写入操作相关的组件的日志消息详细级别。See WRITE components.请参阅WRITE组件。

The verbosity level can range from 0 to 5:详细程度级别可以在05之间:

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

processManagement Options

processManagement:
fork: <boolean>
pidFilePath: <string>
timeZoneInfo: <string>
processManagement.fork

Type: boolean

Default: false

Enable a daemon mode that runs the mongos or mongod process in the background. 启用后台运行mongosmongod进程的守护程序模式。By default mongos or mongod does not run as a daemon: typically you will run mongos or mongod as a daemon, either by using processManagement.fork or by using a controlling process that handles the daemonization process (e.g. as with upstart and systemd).默认情况下,mongosmongod不作为守护进程运行:通常,您将通过使用processManagement.fork或通过使用处理守护进程的控制进程(例如,与upstartsystemd一样)将mongosmongod作为守护进程来运行。

The processManagement.fork option is not supported on Windows.Windows不支持processManagement.fork选项。

The Linux package init scripts do not expect processManagement.fork to change from the defaults. Linux包init脚本不希望processManagement.fork从默认值更改。If you use the Linux packages and change processManagement.fork, you will have to use your own init scripts and disable the built-in scripts.如果使用Linux软件包并更改processManagement.fork,则必须使用自己的init脚本并禁用内置脚本。

processManagement.pidFilePath

Type: string

Specifies a file location to store the process ID (PID) of the mongos or mongod process. 指定用于存储mongosmongod进程的进程ID(PID)的文件位置。The user running the mongod or mongos process must be able to write to this path. 运行mongodmongos进程的用户必须能够写入此路径。If the processManagement.pidFilePath option is not specified, the process does not create a PID file. 如果未指定processManagement.pidFilePath选项,则进程不会创建PID文件。This option is generally only useful in combination with the processManagement.fork setting.此选项通常只在与processManagement.fork设置结合使用时有用。

Note

Linux

On Linux, PID file management is generally the responsibility of your distro's init system: usually a service file in the /etc/init.d directory, or a systemd unit file registered with systemctl. 在Linux上,PID文件管理通常由发行版的init系统负责:通常是/etc/init.d目录中的服务文件,或者是在systemctl中注册的systemd单元文件。Only use the processManagement.pidFilePath option if you are not using one of these init systems. 只有当您没有使用这些init系统时,才使用processManagement.pidFilePath选项。For more information, please see the respective Installation Guide for your operating system.有关详细信息,请参阅相应操作系统的安装指南

Note

macOS

On macOS, PID file management is generally handled by brew. 在macOS上,PID文件管理通常由brew处理。Only use the processManagement.pidFilePath option if you are not using brew on your macOS system. 如果您的macOS系统上没有使用brew,请仅使用processManagement.pidFilePath选项。For more information, please see the respective Installation Guide for your operating system.有关详细信息,请参阅相应操作系统的《安装指南》。

processManagement.timeZoneInfo

Type: string

The full path from which to load the time zone database. 从中加载时区数据库的完整路径。If this option is not provided, then MongoDB will use its built-in time zone database.如果不提供此选项,那么MongoDB将使用其内置的时区数据库。

The configuration file included with Linux and macOS packages sets the time zone database path to /usr/share/zoneinfo by default.Linux和macOS软件包附带的配置文件默认情况下会将时区数据库路径设置为/usr/share/zoneinfo

The built-in time zone database is a copy of the Olson/IANA time zone database. 内置的时区数据库是Olson/IANA时区数据库的副本。It is updated along with MongoDB releases, but the time zone database release cycle differs from the MongoDB release cycle. 它随MongoDB版本一起更新,但时区数据库发布周期与MongoDB发布周期不同。The most recent release of the time zone database is available on our download site.下载网站上提供了时区数据库的最新版本。

Warning

MongoDB uses the third party timelib library to provide accurate conversions between timezones. Due to a recent update, timelib could create inaccurate time zone conversions in older versions of MongoDB.MongoDB使用第三方timelib库来提供时区之间的准确转换。由于最近的更新,timelib可能会在旧版本的MongoDB中创建不准确的时区转换。

To explicitly link to the time zone database in versions of MongoDB prior to 5.0, 4.4.7, and 4.2.14, download the time zone database. 要在MongoDB 5.0、4.4.7和4.2.14之前的版本中显式链接到时区数据库,请下载时区数据库and use the timeZoneInfo parameter.并使用timeZoneInfo参数。

cloud Options

New in version 4.0. 4.0版新增。

cloud:
monitoring:
free:
state: <string>
tags: <string>
cloud.monitoring.free.state

Type: string

New in version 4.0:4.0版新增:Available for MongoDB Community Edition.适用于MongoDB社区版。

Enables or disables free MongoDB Cloud monitoring. 启用或禁用免费的MongoDB云监控cloud.monitoring.free.state accepts the following values:接受以下值:

runtimeDefault. 违约You can enable or disable free monitoring during runtime.您可以在运行时启用或禁用免费监控。
To enable or disable free monitoring during runtime, see db.enableFreeMonitoring() and db.disableFreeMonitoring().要在运行时启用或禁用自由监视,请参阅db.enableFreeMonitoring()db.disableFreeMonitoring()
To enable or disable free monitoring during runtime when running with access control, users must have required privileges. 要在使用访问控制运行时启用或禁用运行时的免费监视,用户必须具有所需的权限。See db.enableFreeMonitoring() and db.disableFreeMonitoring() for details. 有关详细信息,请参阅db.enableFreeMonitoring()db.disableFreeMonitoring()
onEnables free monitoring at startup; i.e. registers for free monitoring. 启用启动时的免费监控;即注册免费监控。When enabled at startup, you cannot disable free monitoring during runtime.如果在启动时启用,则无法在运行时禁用免费监视。
offDisables free monitoring at startup, regardless of whether you have previously registered for free monitoring. 在启动时禁用免费监视,无论您以前是否注册过免费监视。 When disabled at startup, you cannot enable free monitoring during runtime.如果在启动时禁用,则无法在运行时启用免费监视。

Once enabled, the free monitoring state remains enabled until explicitly disabled. 启用后,空闲监视状态将保持启用状态,直到明确禁用为止。That is, you do not need to re-enable each time you start the server.也就是说,您不需要在每次启动服务器时重新启用。

For the corresponding command-line option, see --enableFreeMonitoring.有关相应的命令行选项,请参阅--enableFreeMonitoring

cloud.monitoring.free.tags

Type: string

New in version 4.0:4.0版新增:Available for MongoDB Community Edition.适用于MongoDB社区版。

Optional tag to describe environment context. The tag can be sent as part of the free MongoDB Cloud monitoring registration at start up.用于描述环境上下文的可选标记。该标签可以在启动时作为免费MongoDB云监控注册的一部分发送。

For the corresponding command-line option, see --freeMonitoringTag.有关相应的命令行选项,请参阅--freeMonitoringTag

net Options

Changed in version 4.2:4.2版更改:MongoDB 4.2 deprecates ssl options in favor of tls options with identical functionality.MongoDB 4.2摒弃ssl选项,转而支持具有相同功能的tls选项。

Changed in version 5.0:5.0版更改:MongoDB removes the net.serviceExecutor configuration option and the corresponding --serviceExecutor command-line option.MongoDB删除了net.serviceExecutor配置选项和相应的--serviceExecutior命令行选项。

net:
port: <int>
bindIp: <string>
bindIpAll: <boolean>
maxIncomingConnections: <int>
wireObjectCheck: <boolean>
ipv6: <boolean>
unixDomainSocket:
enabled: <boolean>
pathPrefix: <string>
filePermissions: <int>
tls:
certificateSelector: <string>
clusterCertificateSelector: <string>
mode: <string>
certificateKeyFile: <string>
certificateKeyFilePassword: <string>
clusterFile: <string>
clusterPassword: <string>
CAFile: <string>
clusterCAFile: <string>
clusterAuthX509:
attributes: <string>
extensionValue: <string>
CRLFile: <string>
allowConnectionsWithoutCertificates: <boolean>
allowInvalidCertificates: <boolean>
allowInvalidHostnames: <boolean>
disabledProtocols: <string>
FIPSMode: <boolean>
logVersions: <string>
compression:
compressors: <string>
net.port

Type: integer

Default:

The TCP port on which the MongoDB instance listens for client connections.MongoDB实例侦听客户端连接的TCP端口。

net.bindIp

Type: string

Default: localhost

The hostnames and/or IP addresses and/or full Unix domain socket paths on which mongos or mongod should listen for client connections. mongosmongod应在其上侦听客户端连接的主机名和/或IP地址和/或完整Unix域套接字路径。You may attach mongos or mongod to any interface. 您可以将mongosmongod附加到任何接口。To bind to multiple addresses, enter a list of comma-separated values.要绑定到多个地址,请输入逗号分隔的值列表。

Example

localhost,/tmp/mongod.sock

You can specify both IPv4 and IPv6 addresses, or hostnames that resolve to an IPv4 or IPv6 address.可以指定IPv4和IPv6地址,也可以指定解析为IPv4或IPv6地址的主机名。

Example

localhost, 2001:0DB8:e132:ba26:0d5c:2774:e7f9:d513

Note

If specifying an IPv6 address or a hostname that resolves to an IPv6 address to net.bindIp, you must start mongos or mongod with net.ipv6 : true to enable IPv6 support. 如果指定IPv6地址或解析为net.bindIp的IPv6地址的主机名,则必须使用net.ipv6 : true启动mongosmongod才能启用IPv6支持。Specifying an IPv6 address to net.bindIp does not enable IPv6 support.net.bindIp指定IPv6地址不会启用IPv6支持。

If specifying a link-local IPv6 address (fe80::/10), you must append the zone index to that address (i.e. fe80::<address>%<adapter-name>).如果指定链接本地IPv6地址fe80::/10),则必须将区域索引附加到该地址(即fe80::<address>%<adapter-name>)。

Example

localhost,fe80::a00:27ff:fee0:1fcf%enp0s3

Important

To avoid configuration updates due to IP address changes, use DNS hostnames instead of IP addresses. 若要避免由于IP地址更改而导致配置更新,请使用DNS主机名而不是IP地址。It is particularly important to use a DNS hostname instead of an IP address when configuring replica set members or sharded cluster members.在配置复制集成员或分片集群成员时,使用DNS主机名而不是IP地址尤为重要。

Use hostnames instead of IP addresses to configure clusters across a split network horizon. 使用主机名而不是IP地址来跨拆分的网络范围配置群集。Starting in MongoDB 5.0, nodes that are only configured with an IP address will fail startup validation and will not start.从MongoDB 5.0开始,只配置了IP地址的节点将无法通过启动验证,也不会启动。

Warning

Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. 在将实例绑定到可公开访问的IP地址之前,必须保护群集不受未经授权的访问。For a complete list of security recommendations, see Security Checklist. 有关安全建议的完整列表,请参阅安全检查表At minimum, consider enabling authentication and hardening network infrastructure.至少,考虑启用身份验证强化网络基础设施

For more information about IP Binding, refer to the IP Binding documentation.有关IP绑定的更多信息,请参阅IP绑定文档。

To bind to all IPv4 addresses, enter 0.0.0.0.要绑定到所有IPv4地址,请输入0.0.0.0

To bind to all IPv4 and IPv6 addresses, enter ::,0.0.0.0 or starting in MongoDB 4.2, an asterisk "*" (enclose the asterisk in quotes to distinguish from YAML alias nodes). 要绑定到所有IPv4和IPv6地址,请输入::,0.0.0.0,或者从MongoDB 4.2开始,输入星号"*"(用引号括起星号以区别于YAML别名节点)。Alternatively, use the net.bindIpAll setting.或者,使用net.bindIpAll设置。

Note
  • net.bindIp and net.bindIpAll are mutually exclusive. That is, you can specify one or the other, but not both.net.bindIpnet.bindIpAll是互斥的。也就是说,您可以指定一个或另一个,但不能同时指定两者。
  • The command-line option --bind_ip overrides the configuration file setting net.bindIp.命令行选项--bind_ip覆盖配置文件设置net.bindIp

To configure cluster nodes for split horizon DNS, use host names instead of IP addresses.要为拆分范围DNS配置群集节点,请使用主机名而不是IP地址。

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

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

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

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

net.bindIpAll

Type: boolean

Default: false

If true, the mongos or mongod instance binds to all IPv4 addresses (i.e. 0.0.0.0). 如果为truemongosmongod实例将绑定到所有IPv4地址(即0.0.0.0)。If mongos or mongod starts with net.ipv6 : true, net.bindIpAll also binds to all IPv6 addresses (i.e. ::).如果mongosmongodnet.ipv6 : true开头,那么net.bindIpAll也会绑定到所有IPv6地址(即::)。

mongos or mongod only supports IPv6 if started with net.ipv6 : true. mongosmongod仅支持以net.ipv6 : true启动的IPv6。Specifying net.bindIpAll alone does not enable IPv6 support.单独指定net.bindIpAll并不能启用IPv6支持。

Warning

Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. 在将实例绑定到可公开访问的IP地址之前,必须保护群集不受未经授权的访问。For a complete list of security recommendations, see Security Checklist. 有关安全建议的完整列表,请参阅安全检查表At minimum, consider enabling authentication and hardening network infrastructure.至少,考虑启用身份验证强化网络基础设施

For more information about IP Binding, refer to the IP Binding documentation.有关IP绑定的更多信息,请参阅IP绑定文档。

Alternatively, set net.bindIp to ::,0.0.0.0 or, starting in MongoDB 4.2, to an asterisk "*" (enclose the asterisk in quotes to distinguish from YAML alias nodes) to bind to all IP addresses.或者,从MongoDB 4.2开始,将net.bindIp设置为::,0.0.0.0,或者设置为星号"*"(用引号括起星号以区别于YAML别名节点),以绑定到所有IP地址。

Note

net.bindIp and net.bindIpAll are mutually exclusive. Specifying both options causes mongos or mongod to throw an error and terminate.net.bindIpnet.bindIpAll是互斥的。指定这两个选项会导致mongosmongod抛出错误并终止。

net.maxIncomingConnections

Type: integer

Default: 65536

The maximum number of simultaneous connections that mongos or mongod will accept. mongosmongod将接受的最大同时连接数。This setting has no effect if it is higher than your operating system's configured maximum connection tracking threshold.如果此设置高于操作系统配置的最大连接跟踪阈值,则该设置无效。

Do not assign too low of a value to this option, or you will encounter errors during normal application operation.不要将过低的值分配给此选项,否则在正常应用程序操作过程中会遇到错误。

This is particularly useful for a mongos if you have a client that creates multiple connections and allows them to timeout rather than closing them.如果您有一个创建多个连接并允许它们超时而不是关闭的客户端,那么这对mongos来说尤其有用。

In this case, set maxIncomingConnections to a value slightly higher than the maximum number of connections that the client creates, or the maximum size of the connection pool.在这种情况下,请将maxIncomingConnections设置为略高于客户端创建的最大连接数或连接池的最大大小的值。

This setting prevents the mongos from causing connection spikes on the individual shards. Spikes like these may disrupt the operation and memory allocation of the sharded cluster.此设置可防止mongos在单个分片上造成连接尖峰。像这样的尖峰可能会破坏分片集群的操作和内存分配。

net.wireObjectCheck

Type: boolean

Default: true

When true, the mongod or mongos instance validates all requests from clients upon receipt to prevent clients from inserting malformed or invalid BSON into a MongoDB database.当为true时,mongodmongos实例在收到来自客户端的所有请求时进行验证,以防止客户端将格式错误或无效的BSON插入MongoDB数据库。

For objects with a high degree of sub-document nesting, net.wireObjectCheck can have a small impact on performance.对于具有高度子文档嵌套的对象,net.wireObjectCheck可能会对性能产生较小影响。

net.ipv6

Type: boolean

Default: false

Set net.ipv6 to true to enable IPv6 support. mongos/mongod disables IPv6 support by default.net.ipv6设置为true以启用IPv6支持。mongos/mongod默认禁用IPv6支持。

Setting net.ipv6 does not direct the mongos/mongod to listen on any local IPv6 addresses or interfaces. 设置net.ipv6不会指示mongos/mongod侦听任何本地IPv6地址或接口。To configure the mongos/mongod to listen on an IPv6 interface, you must either:要将mongos/mongod配置为在IPv6接口上侦听,您必须:

  • Configure net.bindIp with one or more IPv6 addresses or hostnames that resolve to IPv6 addresses, or使用一个或多个IPv6地址或解析为IPv6地址的主机名配置net.bindIp,或者
  • Set net.bindIpAll to true.net.bindIpAll设置为true

net.unixDomainSocket Options

net:
unixDomainSocket:
enabled: <boolean>
pathPrefix: <string>
filePermissions: <int>
net.unixDomainSocket.enabled

Type: boolean

Default: true

Enable or disable listening on the UNIX domain socket. 启用或禁用对UNIX域套接字的侦听。net.unixDomainSocket.enabled applies only to Unix-based systems.仅适用于基于Unix的系统。

When net.unixDomainSocket.enabled is true, mongos or mongod listens on the UNIX socket.net.unixDomainSocket.enabledtrue时,mongosmongod侦听UNIX套接字。

The mongos or mongod process always listens on the UNIX socket unless one of the following is true:mongosmongod进程始终侦听UNIX套接字,除非以下情况之一为真:

  • net.unixDomainSocket.enabled is false
  • --nounixsocket is set. 已设置。The command line option takes precedence over the configuration file setting.命令行选项优先于配置文件设置。
  • net.bindIp is not set未设置
  • net.bindIp does not specify localhost or its associated IP address未指定localhost或其关联的IP地址

mongos or mongod installed from official .deb and .rpm packages have the bind_ip configuration set to 127.0.0.1 by default.默认情况下,从官方.deb.rpm包安装的mongosmongodbind_ip配置设置为127.0.0.1

net.unixDomainSocket.pathPrefix

Type: string

Default: /tmp

The path for the UNIX socket. UNIX套接字的路径。net.unixDomainSocket.pathPrefix applies only to Unix-based systems.仅适用于基于Unix的系统。

If this option has no value, the mongos or mongod process creates a socket with /tmp as a prefix. 如果该选项没有值,mongosmongod进程将创建一个以/tmp为前缀的套接字。MongoDB creates and listens on a UNIX socket unless one of the following is true:MongoDB在UNIX套接字上创建和侦听,除非以下情况之一为真:

net.unixDomainSocket.filePermissions

Type: int

Default: 0700

Sets the permission for the UNIX domain socket file.设置UNIX域套接字文件的权限。

net.unixDomainSocket.filePermissions applies only to Unix-based systems.仅适用于基于Unix的系统。

net.http Options

Changed in version 3.6:3.6版更改:MongoDB 3.6 removes the deprecated net.http options. MongoDB 3.6删除了不推荐使用的net.http选项。The options have been deprecated since version 3.2.自3.2版本以来,这些选项已被弃用。

net.tls Options

New in version 4.2:4.2版新增:The tls options provide identical functionality as the previous ssl options.tls选项提供了与以前的ssl选项相同的功能。

net:
tls:
mode: <string>
certificateKeyFile: <string>
certificateKeyFilePassword: <string>
certificateSelector: <string>
clusterCertificateSelector: <string>
clusterFile: <string>
clusterPassword: <string>
clusterAuthX509:
attributes: <string>
extensionValue: <string>
CAFile: <string>
clusterCAFile: <string>
CRLFile: <string>
allowConnectionsWithoutCertificates: <boolean>
allowInvalidCertificates: <boolean>
allowInvalidHostnames: <boolean>
disabledProtocols: <string>
FIPSMode: <boolean>
logVersions: <string>
net.tls.mode

Type: string

New in version 4.2. 4.2版新增。

Enables TLS used for all network connections. 启用用于所有网络连接的TLS。The argument to the net.tls.mode setting can be one of the following:net.tls.mode设置的参数可以是以下参数之一:

ValueDescription描述
disabledThe server does not use TLS.服务器不使用TLS。
allowTLSConnections between servers do not use TLS. For incoming connections, the server accepts both TLS and non-TLS.服务器之间的连接不使用TLS。对于传入连接,服务器同时接受TLS和非TLS。
preferTLSConnections between servers use TLS. For incoming connections, the server accepts both TLS and non-TLS.服务器之间的连接使用TLS。对于传入连接,服务器同时接受TLS和非TLS。
requireTLSThe server uses and accepts only TLS encrypted connections.服务器仅使用并接受TLS加密的连接。

If --tlsCAFile or tls.CAFile is not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS-enabled server.如果未指定--tlsCAFiletls.CAFile,并且您未使用x.509身份验证,则在连接到启用TLS的服务器时将使用系统范围的CA证书存储。

If using x.509 authentication, --tlsCAFile or tls.CAFile must be specified unless using --tlsCertificateSelector.如果使用x.509身份验证,则必须指定--tlsCAFiletls.CAFile,除非使用--tlsCertificateSelector

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

net.tls.certificateKeyFile

Type: string

New in version 4.2:4.2版新增:The .pem file that contains both the TLS certificate and key.同时包含TLS证书和键的.pem文件。

Starting with MongoDB 4.0 on macOS or Windows, you can use the net.tls.certificateSelector setting to specify a certificate from the operating system's secure certificate store instead of a PEM key file. 从macOS或Windows上的MongoDB 4.0开始,您可以使用net.tls.certificateSelector设置从操作系统的安全证书存储中指定证书,而不是PEM键文件。certificateKeyFile and net.tls.certificateSelector are mutually exclusive. 相互排斥。You can only specify one.您只能指定一个。

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

net.tls.certificateKeyFilePassword

Type: string

New in version 4.2:4.2版新增:The password to de-crypt the certificate-key file (i.e. certificateKeyFile). 对证书键文件(即certificateKeyFile)进行解密的密码。Use the net.tls.certificateKeyFilePassword option only if the certificate-key file is encrypted. 仅当证书键文件已加密时,才使用net.tls.certificateKeyFilePassword选项。In all cases, the mongos or mongod will redact the password from all logging and reporting output.在所有情况下,mongosmongod都会对所有日志记录和报告输出的密码进行编辑。

Starting in MongoDB 4.0:从MongoDB 4.0开始:

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

net.tls.certificateSelector

Type: string

New in version 4.2:4.2版新增:Available on Windows and macOS as an alternative to net.tls.certificateKeyFile. 可在Windows和macOS上作为net.tls.certificateKeyFile的替代方案使用。In MongoDB 4.0, see net.ssl.certificateSelector.在MongoDB 4.0中,请参阅net.ssl.certificateSelector

Specifies a certificate property in order to select a matching certificate from the operating system's certificate store to use for TLS/SSL.指定证书属性,以便从操作系统的证书存储中选择用于TLS/SSL的匹配证书。

net.tls.certificateKeyFile and net.tls.certificateSelector options are mutually exclusive. You can only specify one.net.tls.certificateKeyFilenet.tls.certificateSelector选项是互斥的。您只能指定一个。

net.tls.certificateSelector accepts an argument of the format <property>=<value> where the property can be one of the following:接受格式为<property>=<value>的参数,其中该属性可以是以下内容之一:

Property属性Value type值类型Description描述
subjectASCII stringSubject name or common name on certificate证书上的使用者名称或通用名称
thumbprinthex stringA sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
The thumbprint is sometimes referred to as a fingerprint.thumbprint有时被称为fingerprint

When using the system SSL certificate store, OCSP (Online Certificate Status Protocol) is used to validate the revocation status of certificates.使用系统SSL证书存储时,OCSP(联机证书状态协议)用于验证证书的吊销状态。

The mongod searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified TLS certificate. mongod在操作系统的安全证书存储中搜索验证指定TLS证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the TLS certificate.特别是,安全证书存储必须包含根CA和构建TLS证书的完整证书链所需的任何中间CA证书。 Do not use net.tls.CAFile or net.tls.clusterFile to specify the root and intermediate CA certificate不要使用net.tls.CAFilenet.tls.clusterFile指定根证书和中间CA证书

For example, if the TLS certificate was signed with a single root CA certificate, the secure certificate store must contain that root CA certificate. 例如,如果TLS证书是用单个根CA证书签名的,则安全证书存储必须包含该根CA证书。If the TLS certificate was signed with an intermediate CA certificate, the secure certificate store must contain the intermedia CA certificate and the root CA certificate.如果TLS证书是用中间CA证书签名的,则安全证书存储必须包含中间CA证书和根CA证书。

Note

You cannot use the rotateCertificates command or the db.rotateCertificates() shell method when using net.tls.certificateSelector or --tlsCertificateSelector set to thumbprint当使用设置为指纹的net.tls.certificateSelector--tlsCertificateSelector时,不能使用rotateCertificates命令或db.rotateCertificates()shell方法

net.tls.clusterCertificateSelector

Type: string

New in version 4.2:4.2版新增:Available on Windows and macOS as an alternative to net.tls.clusterFile.可在Windows和macOS上作为net.tls.clusterFile的替代方案提供。

Specifies a certificate property to select a matching certificate from the operating system's secure certificate store to use for internal x.509 membership authentication.指定一个证书属性,从操作系统的安全证书存储中选择一个匹配的证书,用于内部x.509成员身份验证

net.tls.clusterFile and net.tls.clusterCertificateSelector options are mutually exclusive. You can only specify one.net.tls.clusterFilenet.tls.clusterCertificateSelector选项相互排斥。您只能指定一个。

net.tls.clusterCertificateSelector accepts an argument of the format <property>=<value> where the property can be one of the following:接受格式为<property>=<value>的参数,其中该属性可以是以下内容之一:

Property属性Value type值类型Description描述
subjectASCII stringSubject name or common name on certificate证书上的使用者名称或通用名称
thumbprinthex stringA sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
The thumbprint is sometimes referred to as a fingerprint. thumbprint有时被称为fingerprint

The mongod searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified cluster certificate. mongod在操作系统的安全证书存储中搜索验证指定群集证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the cluster certificate. 特别是,安全证书存储必须包含根CA和构建到群集证书的完整证书链所需的任何中间CA证书。Do not use net.tls.CAFile or net.tls.clusterCAFile to specify the root and intermediate CA certificate.不要使用net.tls.CAFilenet.tls.clusterCAFile来指定根证书和中间CA证书。

For example, if the cluster certificate was signed with a single root CA certificate, the secure certificate store must contain that root CA certificate. 例如,如果群集证书是用单个根CA证书签名的,则安全证书存储必须包含该根CA证书。If the cluster certificate was signed with an intermediate CA certificate, the secure certificate store must contain the intermediate CA certificate and the root CA certificate.如果群集证书是用中间CA证书签名的,则安全证书存储必须包含中间CA证书和根CA证书。

Changed in version 4.4:4.4版更改:mongod / mongos logs a warning on connection if the presented x.509 certificate expires within 30 days of the mongod/mongos host system time. 如果提供的x.509证书在mongod/mongos主机系统时间后30天内过期,则在连接时记录警告。See x.509 Certificates Nearing Expiry Trigger Warnings for more information.有关详细信息,请参阅x.509证书接近到期触发警告

net.tls.clusterFile

Type: string

New in version 4.2:4.2版新增:The .pem file that contains the x.509 certificate-key file for membership authentication for the cluster or replica set..pem文件,包含用于集群或副本集成员身份验证的x.509证书键文件。

Starting with MongoDB 4.0 on macOS or Windows, you can use the net.tls.clusterCertificateSelector option to specify a certificate from the operating system's secure certificate store instead of a PEM key file. 从macOS或Windows上的MongoDB 4.0开始,您可以使用net.tls.clusterCertificateSelector选项从操作系统的安全证书存储中指定证书,而不是PEM键文件。net.tls.clusterFile and net.tls.clusterCertificateSelector options are mutually exclusive.net.tls.clusterFilenet.tls.clusterCertificateSelector选项相互排斥。 You can only specify one.您只能指定一个。

If net.tls.clusterFile does not specify the .pem file for internal cluster authentication or the alternative net.tls.clusterCertificateSelector, the cluster uses the .pem file specified in the certificateKeyFile setting or the certificate returned by the net.tls.certificateSelector.如果net.tls.clusterFile未指定用于内部群集身份验证的.pem文件或替代net.tls.clusterCertificateSelector,则群集将使用certificateKeyFile设置中指定的.pem文件或net.tls.certificateSelector返回的证书。

If using x.509 authentication, --tlsCAFile or tls.CAFile must be specified unless using --tlsCertificateSelector.如果使用x.509身份验证,则必须指定--tlsCAFiletls.CAFile,除非使用--tlsCertificateSelector

Changed in version 4.4:4.4版更改:mongod / mongos logs a warning on connection if the presented x.509 certificate expires within 30 days of the mongod/mongos host system time. 如果提供的x.509证书在mongod/mongos主机系统时间后30天内过期,则在连接时记录警告。See x.509 Certificates Nearing Expiry Trigger Warnings for more information.有关详细信息,请参阅x.509证书接近到期触发警告

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

Important

For Windows only, MongoDB 4.0 and later do not support encrypted PEM files. 仅适用于Windows,MongoDB 4.0及更高版本不支持加密的PEM文件。The mongod fails to start if it encounters an encrypted PEM file. 如果mongod遇到加密的PEM文件,它将无法启动。To securely store and access a certificate for use with membership authentication on Windows, use net.tls.clusterCertificateSelector.要在Windows上安全存储和访问用于成员身份验证的证书,请使用net.tls.clusterCertificateSelector

net.tls.clusterPassword

Type: string

New in version 4.2:4.2版新增:The password to de-crypt the x.509 certificate-key file specified with --sslClusterFile. 对用--sslClusterFile指定的x.509证书键文件进行解密的密码。Use the net.tls.clusterPassword option only if the certificate-key file is encrypted. 仅当证书键文件已加密时,才使用net.tls.clusterPassword选项。In all cases, the mongos or mongod will redact the password from all logging and reporting output.在所有情况下,mongosmongod都会对所有日志记录和报告输出的密码进行编辑。

Starting in MongoDB 4.0:从MongoDB 4.0开始:

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

net.tls.clusterAuthX509

New in version 7.0. 7.0版新增。

net:
tls:
clusterAuthX509:
attributes: <string>
extensionValue: <string>
net.tls.clusterAuthX509.attributes

Type: string

New in version 7.0. 7.0版新增。

Specifies a set of X.509 Distinguished Name (DN) attributes and values that the server expects cluster member nodes to contain in their certificate subject names. 指定一组X.509可分辨名称(DN)属性和值,服务器希望群集成员节点在其证书使用者名称中包含这些属性和值。This lets you use certificates that don't contain DC, O, and OU values to authenticate cluster members.这允许您使用不包含DC、O和OU值的证书来对集群成员进行身份验证。

When attributes is set, MongoDB matches certificates using the DN and ignores extension values.设置attributes后,MongoDB将使用DN匹配证书,并忽略扩展值。

net.tls.clusterAuthX509.extensionValue

Type: string

New in version 7.0. 7.0版新增。

Specifies an extension value that corresponds to the MongoDB cluster membership extension OID, 1.3.6.1.4.1.34601.2.1.2, that the server expects cluster member nodes to contain in their certificates. This allows you to use certificates that don't contain DC, O, and OU values to authenticate cluster members.指定一个扩展值,该值对应于MongoDB集群成员资格扩展OID 1.3.6.1.4.1.3046011.2.1.2,服务器希望集群成员节点在其证书中包含该OID。这允许您使用不包含DC、O和OU值的证书来对集群成员进行身份验证。

When extensionValue is set, MongoDB matches certificates using certificate extension values and ignores the Distinguished Name (DN).当设置extensionValue时,MongoDB使用证书扩展值匹配证书,并忽略可分辨名称(DN)。

net.tls.CAFile

Type: string

New in version 4.2:4.2版新增:The .pem file that contains the root certificate chain from the Certificate Authority. 包含证书颁发机构的根证书链的.pem文件。Specify the file name of the .pem file using relative or absolute paths.使用相对路径或绝对路径指定.pem文件的文件名。

Windows/macOS Only
If using net.tls.certificateSelector and/or net.tls.clusterCertificateSelector, do not use net.tls.CAFile to specify the root and intermediate CA certificates. 如果使用net.tls.certificateSelector和/或net.tls.clusterCertificateSelector,请不要使用net.tls.CAFile指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the net.tls.certificateSelector and/or net.tls.clusterCertificateSelector certificates in the secure certificate store.将验证net.tls.certificateSelector和/或net.tls.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。

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

net.tls.clusterCAFile

Type: string

New in version 4.2:4.2版新增:The .pem file that contains the root certificate chain from the Certificate Authority used to validate the certificate presented by a client establishing a connection. .pem文件,包含证书颁发机构的根证书链,用于验证建立连接的客户端提供的证书。Specify the file name of the .pem file using relative or absolute paths. 使用相对路径或绝对路径指定pem文件的文件名。net.tls.clusterCAFile requires that net.tls.CAFile is set.要求设置net.tls.CAFile

If net.tls.clusterCAFile does not specify the .pem file for validating the certificate from a client establishing a connection, the cluster uses the .pem file specified in the net.tls.CAFile option.如果net.tls.clusterCAFile没有指定.pem文件来验证来自建立连接的客户端的证书,则集群将使用net.tls.CAFile选项中指定的.pem文件。

net.tls.clusterCAFile lets you use separate Certificate Authorities to verify the client to server and server to client portions of the TLS handshake.允许您使用单独的证书颁发机构来验证TLS握手的客户端到服务器和服务器到客户端部分。

Starting in 4.0, on macOS or Windows, you can use a certificate from the operating system's secure store instead of a PEM key file. 从4.0开始,在macOS或Windows上,您可以使用操作系统安全存储中的证书,而不是PEM键文件。See net.tls.clusterCertificateSelector. 请参阅net.tls.clusterCertificateSelectorWhen using the secure store, you do not need to, but can, also specify the net.tls.clusterCAFile.使用安全存储时,您不需要,但也可以指定net.tls.clusterCAFile

Windows/macOS Only
If using net.tls.certificateSelector and/or net.tls.clusterCertificateSelector, do not use net.tls.clusterCAFile to specify the root and intermediate CA certificates. 如果使用net.tls.certificateSelector和/或net.tls.clusterCertificateSelector,请不要使用net.tls.clusterCAFile指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the net.tls.certificateSelector and/or net.tls.clusterCertificateSelector certificates in the secure certificate store.将验证net.tls.certificateSelector和/或net.tls.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。

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

net.tls.CRLFile

Type: string

New in version 4.2:4.2版新增:In MongoDB 4.0 and earlier, see net.ssl.CRLFile.在MongoDB 4.0及更早版本中,请参阅net.ssl.CRLFile

The .pem file that contains the Certificate Revocation List. Specify the file name of the .pem file using relative or absolute paths.包含证书吊销列表的.pem文件。使用相对路径或绝对路径指定.pem文件的文件名。

Note
  • Starting in MongoDB 4.0, you cannot specify net.tls.CRLFile on macOS. 从MongoDB 4.0开始,您不能在macOS上指定net.tls.CRLFileInstead, you can use the system SSL certificate store, which uses OCSP (Online Certificate Status Protocol) to validate the revocation status of certificates. 相反,您可以使用系统SSL证书存储,该存储使用OCSP(在线证书状态协议)来验证证书的吊销状态。See net.ssl.certificateSelector in MongoDB 4.0 and net.tls.certificateSelector in MongoDB 4.2+ to use the system SSL certificate store.请参阅MongoDB 4.0中的net.ssl.certificateSelector和MongoDB 4.2+中的net.tls.certificateSelector以使用系统SSL证书存储。
  • Starting in version 4.4, to check for certificate revocation, MongoDB enables the use of OCSP (Online Certificate Status Protocol) by default as an alternative to specifying a CRL file or using the system SSL certificate store.从版本4.4开始,为了检查证书吊销,MongoDB默认启用OCSP(在线证书状态协议),作为指定CRL文件或使用系统SSL证书存储的替代方案。

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

net.tls.allowConnectionsWithoutCertificates

Type: boolean

New in version 4.2. 4.2版新增。

For clients that don't provide certificates, mongod or mongos encrypts the TLS/SSL connection, assuming the connection is successfully made.对于不提供证书的客户端,假设连接成功,mongodmongos会对TLS/SSL连接进行加密。

For clients that present a certificate, however, mongos or mongod performs certificate validation using the root certificate chain specified by CAFile and reject clients with invalid certificates.然而,对于提供证书的客户端,mongosmongod使用CAFile指定的根证书链执行证书验证,并拒绝具有无效证书的客户端。

Use the net.tls.allowConnectionsWithoutCertificates option if you have a mixed deployment that includes clients that do not or cannot present certificates to the mongos or mongod.如果您的混合部署包括不向mongosmongod提供证书或不能向其提供证书的客户端,请使用net.tls.allowConnectionsWithoutCertificates选项。

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

net.tls.allowInvalidCertificates

Type: boolean

New in version 4.2. 4.2版新增。

Enable or disable the validation checks for TLS certificates on other servers in the cluster and allows the use of invalid certificates to connect.在群集中的其他服务器上启用或禁用TLS证书的验证检查,并允许使用无效证书进行连接。

Note

If you specify --tlsAllowInvalidCertificates or tls.allowInvalidCertificates: true when using x.509 authentication, an invalid certificate is only sufficient to establish a TLS connection but is insufficient for authentication.如果在使用x.509身份验证时指定--tlsAllowInvalidCertificatestls.allowInvalidCertificates: true,则无效证书仅足以建立TLS连接,但不足以进行身份验证。

When using the net.tls.allowInvalidCertificates setting, MongoDB logs a warning regarding the use of the invalid certificate.当使用net.tls.allowInvalidCertificates设置时,MongoDB会记录有关使用无效证书的警告。

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

net.tls.allowInvalidHostnames

Type: boolean

Default: false

When net.tls.allowInvalidHostnames is true, MongoDB disables the validation of the hostnames in TLS certificates, allowing mongod to connect to MongoDB instances if the hostname their certificates do not match the specified hostname.net.tls.allowInvalidHostnamestrue时,MongoDB将禁用TLS证书中主机名的验证,如果主机名及其证书与指定的主机名不匹配,则允许mongod连接到MongoDB实例。

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

net.tls.disabledProtocols

Type: string

Prevents a MongoDB server running with TLS from accepting incoming connections that use a specific protocol or protocols. 阻止使用TLS运行的MongoDB服务器接受使用特定协议的传入连接。To specify multiple protocols, use a comma separated list of protocols, but do not use spaces after the commas. 要指定多个协议,请使用逗号分隔的协议列表,但不要在逗号后使用空格。If you include a space before a protocol name, the server interprets it as an unrecognized protocol and doesn't start.如果在协议名称之前包含空格,则服务器会将其解释为无法识别的协议,并且不会启动。

net.tls.disabledProtocols recognizes the following protocols: TLS1_0, TLS1_1, TLS1_2, and TLS1_3.识别以下协议:TLS1_0TLS1_1TLS1_2TLS1_3

  • On macOS, you cannot disable TLS1_1 and leave both TLS1_0 and TLS1_2 enabled. 在macOS上,不能禁用TLS1_1并同时启用TLS1_0TLS1_2You must disable at least one of the other two, for example, TLS1_0,TLS1_1.必须禁用其他两个中的至少一个,例如TLS1_0,TLS1_1
  • To list multiple protocols, specify as a comma separated list of protocols without spaces after the commas. 要列出多个协议,请指定为逗号分隔的协议列表,逗号后无空格。For example TLS1_0,TLS1_1.例如TLS1_0,TLS1_1
  • Specifying an unrecognized protocol or including a space after a comma prevents the server from starting.指定无法识别的协议或在逗号后包含空格会阻止服务器启动。
  • The specified disabled protocols overrides any default disabled protocols.指定的禁用协议将覆盖任何默认的禁用协议。

MongoDB disables the use of TLS 1.0 if TLS 1.1+ is available on the system. 如果TLS 1.1+在系统上可用,MongoDB将禁用TLS 1.0的使用。To enable TLS 1.0, specify none to net.tls.disabledProtocols. 若要启用TLS 1.0,请将none指定为net.tls.disabledProtocolsSee Disable TLS 1.0.请参阅禁用TLS 1.0

Members of replica sets and sharded clusters must speak at least one protocol in common.副本集和分片集群的成员必须至少使用一个通用协议。

Tip

See also: 另请参阅:

Disallow Protocols禁用协议

net.tls.FIPSMode

Type: boolean

New in version 4.2. 4.2版新增。

Enable or disable the use of the FIPS mode of the TLS library for the mongos or mongod. mongosmongod启用或禁用TLS库的FIPS模式。Your system must have a FIPS compliant library to use the net.tls.FIPSMode option.您的系统必须具有符合FIPS的库才能使用net.tls.FIPSMode选项。

Note

FIPS-compatible TLS/SSL is available only in MongoDB Enterprise. FIPS兼容的TLS/SSL仅在MongoDB企业版中可用。See Configure MongoDB for FIPS for more information.有关更多信息,请参阅配置MongoDB for FIPS

net.tls.logVersions

Type: string

Instructs mongos or mongod to log a message when a client connects using a specified TLS version.指示mongosmongod在客户端使用指定的TLS版本进行连接时记录消息。

Specify either a single TLS version or a comma-separated list of multiple TLS versions.指定单个TLS版本或多个TLS版本的逗号分隔列表。

Example

To instruct mongos or mongod to log a message when a client connects using either TLS 1.2 or TLS 1.3, set net.tls.logVersions to "TLS1_2,TLS1_3".若要指示mongosmongod在客户端使用TLS 1.2或TLS 1.3连接时记录消息,请将net.tls.logVersions设置为"TLS1_2,TLS1_3"

net.ssl Options

Important

All SSL options are deprecated since 4.2. Use the TLS counterparts instead, as they have identical functionality to the SSL options. The SSL protocol is deprecated and MongoDB supports TLS 1.0 and later.自4.2以来,所有SSL选项都已弃用。请改用TLS对应项,因为它们具有与SSL选项相同的功能。SSL协议已被弃用,MongoDB支持TLS 1.0及更高版本。

net:
ssl: # deprecated since 4.2
sslOnNormalPorts: <boolean> # deprecated since 2.6
mode: <string>
PEMKeyFile: <string>
PEMKeyPassword: <string>
certificateSelector: <string>
clusterCertificateSelector: <string>
clusterFile: <string>
clusterPassword: <string>
CAFile: <string>
clusterCAFile: <string>
CRLFile: <string>
allowConnectionsWithoutCertificates: <boolean>
allowInvalidCertificates: <boolean>
allowInvalidHostnames: <boolean>
disabledProtocols: <string>
FIPSMode: <boolean>
net.ssl.sslOnNormalPorts

Type: boolean

Deprecated since version 2.6自2.6版起弃用: Use net.tls.mode: requireTLS instead.:请改用net.tls.mode: requireTLS

Enable or disable TLS/SSL for mongos or mongod.mongosmongod启用或禁用TLS/SSL。

With net.ssl.sslOnNormalPorts, a mongos or mongod requires TLS/SSL encryption for all connections on the default MongoDB port, or the port specified by net.port. 使用net.ssl.sslOnNormalPortsmongosmongod需要对默认MongoDB端口或net.port指定的端口上的所有连接进行TLS/SSL加密。By default, net.ssl.sslOnNormalPorts is disabled.默认情况下,net.ssl.sslOnNormalPorts处于禁用状态。

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

net.ssl.mode

Type: string

Deprecated since version 4.2: Use net.tls.mode instead.:请改用net.tls.mode

Enables TLS/SSL or mixed TLS/SSL used for all network connections. 启用用于所有网络连接的TLS/SSL或混合TLS/SSL。The argument to the net.ssl.mode setting can be one of the following:net.ssl.mode设置的参数可以是以下参数之一:

ValueDescription描述
disabledThe server does not use TLS/SSL.服务器未使用TLS/SSL。
allowSSLConnections between servers do not use TLS/SSL. 服务器之间的连接不使用TLS/SSL。For incoming connections, the server accepts both TLS/SSL and non-TLS/non-SSL.对于传入连接,服务器同时接受TLS/SSL和非TLS/非SSL。
preferSSLConnections between servers use TLS/SSL. 服务器之间的连接使用TLS/SSL。For incoming connections, the server accepts both TLS/SSL and non-TLS/non-SSL.对于传入连接,服务器同时接受TLS/SSL和非TLS/非SSL。
requireSSLThe server uses and accepts only TLS/SSL encrypted connections.服务器仅使用并接受TLS/SSL加密的连接。

If --tlsCAFile/net.tls.CAFile (or their aliases --sslCAFile/net.ssl.CAFile) is not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS/SSL-enabled server.如果未指定--tlsCAFile/net.tls.CAFile(或其别名--sslCAFile/net.ssl.CAFile),并且您未使用x.509身份验证,则在连接到启用TLS/SSL的服务器时将使用系统范围的CA证书存储。

To use x.509 authentication, --tlsCAFile or net.tls.CAFile must be specified unless you are using --tlsCertificateSelector or --net.tls.certificateSelector.若要使用x.509身份验证,必须指定--tlsCAFilenet.tls.CAFile,除非您使用的是--tlsCertificateSelector--net.tls.certificateSelector

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

net.ssl.PEMKeyFile

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.certificateKeyFile instead.:请改用net.tls.certificateKeyFile

The .pem file that contains both the TLS/SSL certificate and key.包含TLS/SSL证书和键的.pem文件。

Starting with MongoDB 4.0 on macOS or Windows, you can use the net.ssl.certificateSelector setting to specify a certificate from the operating system's secure certificate store instead of a PEM key file. 从macOS或Windows上的MongoDB 4.0开始,您可以使用net.ssl.certificateSelector设置从操作系统的安全证书存储中指定证书,而不是PEM键文件。PEMKeyFile and net.ssl.certificateSelector are mutually exclusive. 相互排斥。You can only specify one.您只能指定一个。

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

net.ssl.PEMKeyPassword

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.certificateKeyFilePassword instead.:请改用net.tls.certificateKeyFilePassword

The password to de-crypt the certificate-key file (i.e. PEMKeyFile). 对证书键文件(即PEMKeyFile)进行解密的密码。Use the net.ssl.PEMKeyPassword option only if the certificate-key file is encrypted. 仅当证书键文件已加密时,才使用net.ssl.PEMKeyPassword选项。In all cases, the mongos or mongod will redact the password from all logging and reporting output.在所有情况下,mongosmongod都会对所有日志记录和报告输出的密码进行编辑。

Starting in MongoDB 4.0:从MongoDB 4.0开始:

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

net.ssl.certificateSelector

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.certificateSelector instead.:请改用net.tls.certificateSelector

New in version 4.0:4.0版新增:Available on Windows and macOS as an alternative to net.ssl.PEMKeyFile.可在Windows和macOS上作为net.ssl.PEMKeyFile的替代品提供。

Specifies a certificate property in order to select a matching certificate from the operating system's certificate store to use for TLS/SSL.指定证书属性,以便从操作系统的证书存储中选择用于TLS/SSL的匹配证书。

net.ssl.PEMKeyFile and net.ssl.certificateSelector options are mutually exclusive. You can only specify one.选项是相互排斥的。您只能指定一个。

net.ssl.certificateSelector accepts an argument of the format <property>=<value> where the property can be one of the following:接受格式为<property>=<value>的参数,其中该属性可以是以下内容之一:

Property属性Value type值类型Description描述
subjectASCII stringSubject name or common name on certificate证书上的使用者名称或通用名称
thumbprinthex stringA sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
The thumbprint is sometimes referred to as a fingerprint. thumbprint有时被称为fingerprint

When using the system SSL certificate store, OCSP (Online Certificate Status Protocol) is used to validate the revocation status of certificates.使用系统SSL证书存储时,OCSP(联机证书状态协议)用于验证证书的吊销状态。

The mongod searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified TLS/SSL certificate. mongod在操作系统的安全证书存储中搜索验证指定TLS/SSL证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the TLS/SSL certificate. 特别是,安全证书存储必须包含根CA和构建TLS/SSL证书的完整证书链所需的任何中间CA证书。Do not use net.ssl.CAFile or net.ssl.clusterFile to specify the root and intermediate CA certificate不要使用net.ssl.CAFilenet.ssl.clusterFile指定根证书和中间CA证书

For example, if the TLS/SSL certificate was signed with a single root CA certificate, the secure certificate store must contain that root CA certificate. 例如,如果TLS/SSL证书是用单个根CA证书签名的,则安全证书存储必须包含该根CA证书。If the TLS/SSL certificate was signed with an intermediate CA certificate, the secure certificate store must contain the intermediate CA certificate and the root CA certificate.如果TLS/SSL证书是用中间CA证书签名的,则安全证书存储必须包含中间CA证书和根CA证书。

net.ssl.clusterCertificateSelector

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.clusterCertificateSelector instead.:请改用net.tls.clusterCertificateSelector

New in version 4.0:4.0版新增:Available on Windows and macOS as an alternative to net.ssl.clusterFile.可在Windows和macOS上作为net.ssl.clusterFile的替代品提供。

Specifies a certificate property to select a matching certificate from the operating system's secure certificate store to use for internal x.509 membership authentication.指定一个证书属性,从操作系统的安全证书存储中选择一个匹配的证书,用于内部x.509成员身份验证

net.ssl.clusterFile and net.ssl.clusterCertificateSelector options are mutually exclusive. 选项是相互排斥的。You can only specify one.您只能指定一个。

net.ssl.clusterCertificateSelector accepts an argument of the format <property>=<value> where the property can be one of the following:接受格式为<property>=<value>的参数,其中该属性可以是以下内容之一:

Property属性Value type值类型Description描述
subjectASCII stringSubject name or common name on certificate证书上的使用者名称或通用名称
thumbprinthex stringA sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
The thumbprint is sometimes referred to as a fingerprint.thumbprint有时被称为fingerprint

The mongod searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified cluster certificate. mongod在操作系统的安全证书存储中搜索验证指定群集证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the cluster certificate. 特别是,安全证书存储必须包含根CA和构建到群集证书的完整证书链所需的任何中间CA证书。Do not use net.ssl.CAFile or net.ssl.clusterFile to specify the root and intermediate CA certificate.不要使用net.ssl.CAFilenet.ssl.clusterFile来指定根证书和中间CA证书。

For example, if the cluster certificate was signed with a single root CA certificate, the secure certificate store must contain that root CA certificate. 例如,如果群集证书是用单个根CA证书签名的,则安全证书存储必须包含该根CA证书。If the cluster certificate was signed with an intermediate CA certificate, the secure certificate store must contain the intermediate CA certificate and the root CA certificate.如果群集证书是用中间CA证书签名的,则安全证书存储必须包含中间CA证书和根CA证书。

net.ssl.clusterFile

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.clusterFile instead.:请改用net.tls.clusterFile

The .pem file that contains the x.509 certificate-key file for membership authentication for the cluster or replica set..pem文件,包含用于集群或副本集成员身份验证的x.509证书键文件。

Starting with MongoDB 4.0 on macOS or Windows, you can use the net.ssl.clusterCertificateSelector option to specify a certificate from the operating system's secure certificate store instead of a PEM key file. 从macOS或Windows上的MongoDB 4.0开始,您可以使用net.ssl.clusterCertificateSelector选项从操作系统的安全证书存储中指定证书,而不是PEM键文件。net.ssl.clusterFile and net.ssl.clusterCertificateSelector options are mutually exclusive. 选项是相互排斥的。You can only specify one.您只能指定一个。

If net.ssl.clusterFile does not specify the .pem file for internal cluster authentication or the alternative net.ssl.clusterCertificateSelector, the cluster uses the .pem file specified in the PEMKeyFile setting or the certificate returned by the net.ssl.certificateSelector.如果net.ssl.clusterFile未指定用于内部群集身份验证的 .pem文件或备用net.ssl.clusterCertificateSelector,则群集将使用在PEMKeyFile设置中指定的pem文件或net.ssl.certificateSelector返回的证书。

To use x.509 authentication, --tlsCAFile or net.tls.CAFile must be specified unless you are using --tlsCertificateSelector or --net.tls.certificateSelector.若要使用x.509身份验证,必须指定--tlsCAFilenet.tls.CAFile,除非您使用的是--tlsCertificateSelector--net.tls.certificateSelector

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

Important

For Windows only, MongoDB 4.0 and later do not support encrypted PEM files. 仅适用于Windows,MongoDB 4.0及更高版本不支持加密的PEM文件。The mongod fails to start if it encounters an encrypted PEM file. 如果mongod遇到加密的PEM文件,它将无法启动。To securely store and access a certificate for use with membership authentication on Windows, use net.ssl.clusterCertificateSelector.要在Windows上安全存储和访问用于成员身份验证的证书,请使用net.ssl.clusterCertificateSelector

net.ssl.clusterPassword

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.clusterPassword instead.:请改用net.tls.clusterPassword

The password to de-crypt the x.509 certificate-key file specified with --sslClusterFile. 对用--sslClusterFile指定的x.509证书键文件进行解密的密码。Use the net.ssl.clusterPassword option only if the certificate-key file is encrypted. 仅当证书键文件已加密时,才使用net.ssl.clusterPassword选项。In all cases, the mongos or mongod will redact the password from all logging and reporting output.在所有情况下,mongosmongod都会对所有日志记录和报告输出的密码进行编辑。

Starting in MongoDB 4.0:从MongoDB 4.0开始:

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

net.ssl.CAFile

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.CAFile instead.:请改用net.tls.CAFile

The .pem file that contains the root certificate chain from the Certificate Authority. .pem文件,包含来自证书颁发机构的根证书链。Specify the file name of the .pem file using relative or absolute paths.使用相对路径或绝对路径指定.pem文件的文件名。

Windows/macOS Only
If using net.ssl.certificateSelector and/or net.ssl.clusterCertificateSelector, do not use net.ssl.CAFile to specify the root and intermediate CA certificates. 如果使用net.ssl.certificateSelector和/或net.ssl.clusterCertificateSelector,请不要使用net.ssl.CAFile指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the net.ssl.certificateSelector and/or net.ssl.clusterCertificateSelector certificates in the secure certificate store.将验证net.ssl.certificateSelector和/或net.ssl.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。

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

net.ssl.clusterCAFile

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.clusterCAFile instead.:请改用net.tls.clusterCAFile

The .pem file that contains the root certificate chain from the Certificate Authority used to validate the certificate presented by a client establishing a connection. .pem文件,包含证书颁发机构的根证书链,用于验证建立连接的客户端提供的证书。Specify the file name of the .pem file using relative or absolute paths. 使用相对路径或绝对路径指定.pem文件的文件名。net.ssl.clusterCAFile requires that net.ssl.CAFile is set.

If net.ssl.clusterCAFile does not specify the .pem file for validating the certificate from a client establishing a connection, the cluster uses the .pem file specified in the net.ssl.CAFile option.如果net.ssl.clusterCAFile没有指定用于验证来自建立连接的客户端的证书的.pem文件,则集群将使用net.ssl.CAFile选项中指定的.pem

net.ssl.clusterCAFile lets you use separate Certificate Authorities to verify the client to server and server to client portions of the TLS handshake.允许您使用单独的证书颁发机构来验证TLS握手的客户端到服务器和服务器到客户端部分。

Starting in 4.0, on macOS or Windows, you can use a certificate from the operating system's secure store instead of a PEM key file. 从4.0开始,在macOS或Windows上,您可以使用操作系统安全存储中的证书,而不是PEM键文件。See net.ssl.clusterCertificateSelector. 请参阅net.ssl.clusterCertificateSelectorWhen using the secure store, you do not need to, but can, also specify the net.ssl.clusterCAFile.使用安全存储时,您不需要,但也可以指定net.ssl.clusterCAFile

Windows/macOS Only
If using net.ssl.certificateSelector and/or net.ssl.clusterCertificateSelector, do not use net.ssl.clusterCAFile to specify the root and intermediate CA certificates. 如果使用net.ssl.certificateSelector和/或net.ssl.clusterCertificateSelector,请不要使用net.ssl.clusterCAFile来指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the net.ssl.certificateSelector and/or net.ssl.clusterCertificateSelector certificates in the secure certificate store.将验证net.ssl.certificateSelector和/或net.ssl.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。

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

net.ssl.CRLFile

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.CRLFile instead.:请改用net.tls.CRLFile

The .pem file that contains the Certificate Revocation List. Specify the file name of the .pem file using relative or absolute paths.包含证书吊销列表的.pem文件。使用相对路径或绝对路径指定.pem文件的文件名。

Note
  • Starting in MongoDB 4.0, you cannot specify net.ssl.CRLFile on macOS. 从MongoDB 4.0开始,您不能在macOS上指定net.ssl.CRLFileInstead, you can use the system SSL certificate store, which uses OCSP (Online Certificate Status Protocol) to validate the revocation status of certificates. 相反,您可以使用系统SSL证书存储,该存储使用OCSP(在线证书状态协议)来验证证书的吊销状态。See net.ssl.certificateSelector in MongoDB 4.0 and net.tls.certificateSelector in MongoDB 4.2 to use the system SSL certificate store.请参阅MongoDB 4.0中的net.ssl.certificateSelector和MongoDB 4.2中的net.tls.certificateSelector来使用系统SSL证书存储。
  • Starting in version 4.4, MongoDB enables, by default, the use of OCSP (Online Certificate Status Protocol) to check for certificate revocation as an alternative to specifying a CRL file or using the system SSL certificate store.从版本4.4开始,MongoDB默认情况下允许使用OCSP(在线证书状态协议)检查证书吊销,作为指定CRL文件或使用系统SSL证书存储的替代方案。

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

net.ssl.allowConnectionsWithoutCertificates

Type: boolean

Deprecated since version 4.2自4.2版起弃用: Use net.tls.allowConnectionsWithoutCertificates instead.:请改用net.tls.allowConnectionsWithoutCertificates

For clients that don't provide certificates, mongod or mongos encrypts the TLS/SSL connection, assuming the connection is successfully made.对于不提供证书的客户端,假设连接成功,mongodmongos会对TLS/SSL连接进行加密。

For clients that present a certificate, however, mongos or mongod performs certificate validation using the root certificate chain specified by CAFile and reject clients with invalid certificates.然而,对于提供证书的客户端,mongosmongod使用CAFile指定的根证书链执行证书验证,并拒绝具有无效证书的客户端。

Use the net.ssl.allowConnectionsWithoutCertificates option if you have a mixed deployment that includes clients that do not or cannot present certificates to the mongos or mongod.如果您的混合部署包括不向mongosmongod提供证书或不能向其提供证书的客户端,请使用net.ssl.allowConnectionsWithoutCertificates选项。

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

net.ssl.allowInvalidCertificates

Type: boolean

Deprecated since version 4.2自4.2版起弃用: Use net.tls.allowInvalidCertificates instead.:请改用net.tls.allowInvalidCertificates

Enable or disable the validation checks for TLS/SSL certificates on other servers in the cluster and allows the use of invalid certificates to connect.启用或禁用群集中其他服务器上TLS/SSL证书的验证检查,并允许使用无效证书进行连接。

Note

Starting in MongoDB 4.0, if you specify any of the following x.509 authentication options, an invalid certificate is sufficient only to establish a TLS connection but it is insufficient for authentication:从MongoDB 4.0开始,如果指定以下x.509身份验证选项中的任何一个,则无效证书仅足以建立TLS连接,但不足以进行身份验证:

  • --sslAllowInvalidCertificates or net.ssl.allowInvalidCertificates: true for MongoDB 4.0 and later
  • --tlsAllowInvalidCertificates or net.tls.allowInvalidCertificates: true for MongoDB 4.2 and later

When using the net.ssl.allowInvalidCertificates setting, MongoDB logs a warning regarding the use of the invalid certificate.当使用net.ssl.allowInvalidCertificates设置时,MongoDB会记录有关使用无效证书的警告。

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

net.ssl.allowInvalidHostnames

Type: boolean

Default: false

Deprecated since version 4.2.自4.2版起弃用

Use net.tls.allowInvalidHostnames instead.请改用net.tls.allowInvalidHostnames

When net.ssl.allowInvalidHostnames is true, MongoDB disables the validation of the hostnames in TLS/SSL certificates, allowing mongod to connect to MongoDB instances if the hostname their certificates do not match the specified hostname.net.ssl.allowInvalidHostnamestrue时,MongoDB将禁用TLS/SSL证书中主机名的验证,允许mongod在主机名及其证书与指定主机名不匹配时连接到MongoDB实例。

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

net.ssl.disabledProtocols

Type: string

Deprecated since version 4.2自4.2版起弃用: Use net.tls.disabledProtocols instead.:请改用net.tls.disabledProtocols

Prevents a MongoDB server running with TLS/SSL from accepting incoming connections that use a specific protocol or protocols. To specify multiple protocols, use a comma separated list of protocols.阻止使用TLS/SSL运行的MongoDB服务器接受使用特定协议的传入连接。要指定多个协议,请使用逗号分隔的协议列表。

net.ssl.disabledProtocols recognizes the following protocols: TLS1_0, TLS1_1, TLS1_2, and starting in version 4.0.4 (and 3.6.9), TLS1_3.net.ssl.disabledProtocols可识别以下协议:TLS1_0TLS1_1TLS1_2,以及从版本4.0.4(和3.6.9)开始的TLS1_3

  • On macOS, you cannot disable TLS1_1 and leave both TLS1_0 and TLS1_2 enabled. 在macOS上,不能禁用TLS1_1并同时启用TLS1_0TLS1_2You must disable at least one of the other two, for example, TLS1_0,TLS1_1.必须禁用其他两个中的至少一个,例如TLS1_0,TLS1_1
  • To list multiple protocols, specify as a comma separated list of protocols. For example TLS1_0,TLS1_1.要列出多个协议,请指定为以逗号分隔的协议列表。例如TLS1_0,TLS1_1
  • Specifying an unrecognized protocol will prevent the server from starting.指定无法识别的协议将阻止服务器启动。
  • The specified disabled protocols overrides any default disabled protocols.指定的禁用协议将覆盖任何默认的禁用协议。

Starting in version 4.0, MongoDB disables the use of TLS 1.0 if TLS 1.1+ is available on the system. 从4.0版本开始,如果TLS 1.1+在系统上可用,MongoDB将禁用TLS 1.0的使用。To enable the disabled TLS 1.0, specify none to net.ssl.disabledProtocols. See Disable TLS 1.0.要启用禁用的TLS 1.0,请为net.ssl.disabledProtocols指定none。请参阅禁用TLS 1.0

Members of replica sets and sharded clusters must speak at least one protocol in common.副本集和分片集群的成员必须至少使用一个通用协议。

Tip

See also: 另请参阅:

Disallow Protocols禁用协议

net.ssl.FIPSMode

Type: boolean

Deprecated since version 4.2自4.2版起弃用: Use net.tls.FIPSMode instead.:请改用net.tls.FIPSMode

Enable or disable the use of the FIPS mode of the TLS/SSL library for the mongos or mongod. Your system must have a FIPS compliant library to use the net.ssl.FIPSMode option.mongosmongod启用或禁用TLS/SSL库的FIPS模式。您的系统必须具有符合FIPS的库才能使用net.ssl.FIPSMode选项。

Note

FIPS-compatible TLS/SSL is available only in MongoDB Enterprise. FIPS兼容的TLS/SSL仅在MongoDB企业版中可用。See Configure MongoDB for FIPS for more information.有关更多信息,请参阅配置MongoDB for FIPS

net.compression Option

net:
compression:
compressors: <string>
net.compression.compressors

Default: snappy,zstd,zlib

Specifies the default compressor(s) to use for communication between this mongod or mongos instance and:指定用于此mongodmongos实例与以下对象之间通信的默认压缩器:

  • other members of the deployment if the instance is part of a replica set or a sharded cluster部署的其他成员(如果实例是副本集或分片集群的一部分)
  • mongosh
  • drivers that support the OP_COMPRESSED message format.支持OP_COMPRESSED消息格式的驱动程序。

MongoDB supports the following compressors:MongoDB支持以下压缩器:

  • snappy
  • zlib (Available starting in MongoDB 3.6)(从MongoDB 3.6开始提供)
  • zstd (Available starting in MongoDB 4.2)(从MongoDB 4.2开始提供)

In versions 3.6 and 4.0, mongod and mongos enable network compression by default with snappy as the compressor.在3.6和4.0版本中mongodmongos默认启用网络压缩,并使用snappy作为压缩器。

Starting in version 4.2, mongod and mongos instances default to both snappy,zstd,zlib compressors, in that order.从4.2版本开始mongodmongos实例默认为snappy,zstd,zlib压缩器,按顺序排列。

To disable network compression, set the value to disabled.要禁用网络压缩,请将该值设置为disabled

Important

Messages are compressed when both parties enable network compression. Otherwise, messages between the parties are uncompressed.当双方都启用网络压缩时,消息会被压缩。否则,双方之间的消息将被解压缩。

If you specify multiple compressors, then the order in which you list the compressors matter as well as the communication initiator. 如果指定了多个压缩器,那么列出压缩器的顺序与通信启动器一样重要。For example, if mongosh specifies the following network compressors zlib,snappy and the mongod specifies snappy,zlib, messages between mongosh and mongod uses zlib.例如,如果mongosh指定以下网络压缩器zlib,snappy,而mongod指定snappy,zlib,则mongoshmongod之间的消息使用zlib

If the parties do not share at least one common compressor, messages between the parties are uncompressed. 如果双方不共享至少一个公共压缩器,则双方之间的消息将被解压缩。For example, if mongosh specifies the network compressor zlib and mongod specifies snappy, messages between mongosh and mongod are not compressed.例如,如果mongosh指定网络压缩器zlibmongod指定snappy,则mongoshmongod之间的消息不会被压缩。

security Options

security:
keyFile: <string>
clusterAuthMode: <string>
authorization: <string>
transitionToAuth: <boolean>
javascriptEnabled: <boolean>
redactClientLogData: <boolean>
clusterIpSourceAllowlist:
- <string>
sasl:
hostName: <string>
serviceName: <string>
saslauthdSocketPath: <string>
enableEncryption: <boolean>
encryptionCipherMode: <string>
encryptionKeyFile: <string>
kmip:
keyIdentifier: <string>
rotateMasterKey: <boolean>
serverName: <string>
port: <string>
clientCertificateFile: <string>
clientCertificatePassword: <string>
clientCertificateSelector: <string>
serverCAFile: <string>
connectRetries: <int>
connectTimeoutMS: <int>
ldap:
servers: <string>
bind:
method: <string>
saslMechanisms: <string>
queryUser: <string>
queryPassword: <string | array>
useOSDefaults: <boolean>
transportSecurity: <string>
timeoutMS: <int>
userToDNMapping: <string>
authz:
queryTemplate: <string>
validateLDAPServerConfig: <boolean>
security.keyFile

Type: string

The path to a key file that stores the shared secret that MongoDB instances use to authenticate to each other in a sharded cluster or replica set. 存储共享机密的键文件的路径,MongoDB实例使用该共享机密在分片集群副本集中相互验证。keyFile implies security.authorization. keyFile意味着security.authorizationSee Internal/Membership Authentication for more information.有关详细信息,请参阅内部/成员身份验证

Starting in MongoDB 4.2, keyfiles for internal membership authentication use YAML format to allow for multiple keys in a keyfile. The YAML format accepts either:从MongoDB 4.2开始,用于内部成员身份验证的键文件使用YAML格式,允许在一个键文件中有多个键。YAML格式接受以下任一项:

  • A single key string (same as in earlier versions)单个键字符串(与早期版本相同)
  • A sequence of key strings一串键串

The YAML format is compatible with the existing single-key keyfiles that use the text file format.YAML格式与使用文本文件格式的现有单键键文件兼容。

security.clusterAuthMode

Type: string

Default: keyFile

The authentication mode used for cluster authentication. 用于群集身份验证的身份验证模式。If you use internal x.509 authentication, specify so here. 如果使用内部x.509身份验证,请在此处指定。This option can have one of the following values:此选项可以具有以下值之一:

ValueDescription描述
keyFileUse a keyfile for authentication. Accept only keyfiles.使用键文件进行身份验证。仅接受关键文件。
sendKeyFileFor rolling upgrade purposes. Send a keyfile for authentication but can accept both keyfiles and x.509 certificates.用于滚动升级。发送键文件进行身份验证,但可以接受键文件和x.509证书。
sendX509For rolling upgrade purposes. Send the x.509 certificate for authentication but can accept both keyfiles and x.509 certificates.用于滚动升级。发送x.509证书进行身份验证,但可以同时接受键文件和x.509证书。
x509Recommended. Send the x.509 certificate for authentication and accept only x.509 certificates.推荐。发送x.509证书进行身份验证,只接受x.509证书。

If --tlsCAFile or tls.CAFile is not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS-enabled server.如果未指定--tlsCAFiletls.CAFile,并且您未使用x.509身份验证,则在连接到启用TLS的服务器时将使用系统范围的CA证书存储。

If using x.509 authentication, --tlsCAFile or tls.CAFile must be specified unless using --tlsCertificateSelector.如果使用x.509身份验证,则必须指定--tlsCAFiletls.CAFile,除非使用--tlsCertificateSelector

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

security.authorization

Type: string

Default: disabled

Enable or disable Role-Based Access Control (RBAC) to govern each user's access to database resources and operations.启用或禁用基于角色的访问控制(RBAC)以管理每个用户对数据库资源和操作的访问。

Set this option to one of the following:将此选项设置为以下选项之一:

ValueDescription描述
enabledA user can access only the database resources and actions for which they have been granted privileges.用户只能访问被授予权限的数据库资源和操作。
disabledA user can access any database and perform any action.用户可以访问任何数据库并执行任何操作。

See Role-Based Access Control for more information.有关详细信息,请参阅基于角色的访问控制

The security.authorization setting is available only for mongod.security.authorization设置仅适用于mongod

security.transitionToAuth

Type: boolean

Default: false

Allows the mongod or mongos to accept and create authenticated and non-authenticated connections to and from other mongod and mongos instances in the deployment. 允许mongodmongos接受并创建与部署中其他mongodmongos实例之间的已验证和未验证连接。Used for performing rolling transition of replica sets or sharded clusters from a no-auth configuration to internal authentication. 用于执行副本集或分片集群从无身份验证配置到内部身份验证的滚动转换。Requires specifying a internal authentication mechanism such as security.keyFile.需要指定内部身份验证机制,如security.keyFile

For example, if using keyfiles for internal authentication, the mongod or mongos creates an authenticated connection with any mongod or mongos in the deployment using a matching keyfile. 例如,如果使用keyfiles进行内部身份验证mongodmongos将使用匹配的键文件创建与部署中的任何mongodmongos的已验证连接。If the security mechanisms do not match, the mongod or mongos utilizes a non-authenticated connection instead.如果安全机制不匹配,mongodmongos将使用未经身份验证的连接。

A mongod or mongos running with security.transitionToAuth does not enforce user access controls. 使用security.transitionToAuth运行的mongodmongos不强制执行用户访问控制Users may connect to your deployment without any access control checks and perform read, write, and administrative operations.用户可以在不进行任何访问控制检查的情况下连接到您的部署,并执行读取、写入和管理操作。

Note

A mongod or mongos running with internal authentication and without security.transitionToAuth requires clients to connect using user access controls. 使用内部身份验证而不使用security.transitionToAuth运行的mongodmongos要求客户端使用用户访问控制进行连接。Update clients to connect to the mongod or mongos using the appropriate user prior to restarting mongod or mongos without security.transitionToAuth.在没有security.transitionToAuth的情况下重新启动mongodmongos之前,更新客户端以使用适当的用户连接到mongod或者mongos

security.javascriptEnabled

Type: boolean

Default: true

Enables or disables server-side JavaScript execution. 启用或禁用服务器端JavaScript执行When disabled, you cannot use operations that perform server-side execution of JavaScript code, such as the $where query operator, mapReduce command, $accumulator, and $function.禁用时,不能使用执行JavaScript代码的服务器端执行的操作,例如$where查询运算符、mapReduce命令、$accumulator$function

If you do not use these operations, disable server-side scripting.如果不使用这些操作,请禁用服务器端脚本。

Starting in version 4.4, the security.javascriptEnabled is available for both mongod and mongos. 从版本4.4开始,security.javascriptEnabled可用于mongodmongosIn earlier versions, the setting is only available for mongod.在早期版本中,该设置仅适用于mongod

security.redactClientLogData

Type: boolean

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

A mongod or mongos running with security.redactClientLogData redacts any message accompanying a given log event before logging. 使用security.redactClientLogData运行的mongodmongos会在日志记录之前对给定日志事件附带的任何消息进行编辑。This prevents the mongod or mongos from writing potentially sensitive data stored on the database to the diagnostic log. 这可以防止mongodmongos将存储在数据库中的潜在敏感数据写入诊断日志。Metadata such as error or operation codes, line numbers, and source file names are still visible in the logs.元数据(如错误或操作代码、行号和源文件名)在日志中仍然可见。

Use security.redactClientLogData in conjunction with Encryption at Rest and TLS/SSL (Transport Encryption) to assist compliance with regulatory requirements.security.redactClientLogData静态加密TLS/SSL(传输加密)结合使用,有助于遵守法规要求。

For example, a MongoDB deployment might store Personally Identifiable Information (PII) in one or more collections. 例如,MongoDB部署可能将个人识别信息(PII)存储在一个或多个集合中。The mongod or mongos logs events such as those related to CRUD operations, sharding metadata, etc. mongodmongos记录事件,例如与CRUD操作、分片元数据等相关的事件。It is possible that the mongod or mongos may expose PII as a part of these logging operations. mongodmongos可能会将PII作为这些日志操作的一部分进行公开。A mongod or mongos running with security.redactClientLogData removes any message accompanying these events before being output to the log, effectively removing the PII.使用security.redactClientLogData运行的mongodmongos会在将这些事件输出到日志之前删除伴随这些事件的任何消息,从而有效地删除PII。

Diagnostics on a mongod or mongos running with security.redactClientLogData may be more difficult due to the lack of data related to a log event. 由于缺少与日志事件相关的数据,在使用security.redactClientLogData运行的mongodmongos上进行诊断可能会更加困难。See the process logging manual page for an example of the effect of security.redactClientLogData on log output.有关security.redactClientLogData对日志输出的影响的示例,请参阅进程日志记录手册页面。

On a running mongod or mongos, use setParameter with the redactClientLogData parameter to configure this setting.在运行的mongodmongos上,使用setParameterredactClientLogData参数来配置此设置。

security.clusterIpSourceAllowlist

Type: list

New in version 5.0. 5.0版新增。

A list of IP addresses/CIDR (Classless Inter-Domain Routing) ranges against which the mongod validates authentication requests from other members of the replica set and, if part of a sharded cluster, the mongos instances. IP地址/CIDR(无类别域间路由)范围的列表,mongod根据该列表验证来自副本集其他成员的身份验证请求,如果是分片集群的一部分,则验证mongos实例。The mongod verifies that the originating IP is either explicitly in the list or belongs to a CIDR range in the list. mongod验证始发IP是否明确在列表中,或者是否属于列表中的CIDR范围。If the IP address is not present, the server does not authenticate the mongod or mongos.如果IP地址不存在,则服务器不会对mongodmongos进行身份验证。

security.clusterIpSourceAllowlist has no effect on a mongod started without authentication.security.clusterIpSourceAllowlist对未经身份验证启动的mongod没有影响。

security.clusterIpSourceAllowlist requires specifying each IPv4/6 address or Classless Inter-Domain Routing (CIDR) range as a YAML list:要求将每个IPv4/6地址或无类别域间路由(CIDR)范围指定为YAML列表:

security:
clusterIpSourceAllowlist:
- 192.0.2.0/24
- 127.0.0.1
- ::1
Important

Ensure security.clusterIpSourceAllowlist includes the IP address or CIDR ranges that include the IP address of each replica set member or mongos in the deployment to ensure healthy communication between cluster components.确保security.clusterIpSourceAllowlist包括IP地址或CIDR范围,其中包括部署中每个副本集成员或mongos的IP地址,以确保集群组件之间的通信正常。

security.clusterIpSourceWhitelist

Type: list

Deprecated in version 5.0:在版本5.0中已弃用: Usesecurity.clusterIpSourceAllowlist instead. 请改用security.clusterIpSourceAllowlist

A list of IP addresses/CIDR (Classless Inter-Domain Routing) ranges against which the mongod validates authentication requests from other members of the replica set and, if part of a sharded cluster, the mongos instances. IP地址/CIDR(无类别域间路由)范围的列表,mongod根据该列表验证来自副本集其他成员的身份验证请求,如果是分片集群的一部分,则验证mongos实例。The mongod verifies that the originating IP is either explicitly in the list or belongs to a CIDR range in the list. mongod验证始发IP是否明确在列表中,或者是否属于列表中的CIDR范围。If the IP address is not present, the server does not authenticate the mongod or mongos.如果IP地址不存在,则服务器不会对mongodmongos进行身份验证。

security.clusterIpSourceWhitelist has no effect on a mongod started without authentication.对未经身份验证启动的mongod没有影响。

security.clusterIpSourceWhitelist requires specifying each IPv4/6 address or Classless Inter-Domain Routing (CIDR) range as a YAML list:要求将每个IPv4/6地址或无类别域间路由(CIDR)范围指定为YAML列表:

security:
clusterIpSourceWhitelist:
- 192.0.2.0/24
- 127.0.0.1
- ::1
Important

Ensure security.clusterIpSourceWhitelist includes the IP address or CIDR ranges that include the IP address of each replica set member or mongos in the deployment to ensure healthy communication between cluster components.确保security.clusterIpSourceWhitelist包括IP地址CIDR范围,其中包括部署中每个副本集成员或mongos的IP地址,以确保集群组件之间的通信正常。

Key Management Configuration Options键管理配置选项

security:
enableEncryption: <boolean>
encryptionCipherMode: <string>
encryptionKeyFile: <string>
kmip:
keyIdentifier: <string>
rotateMasterKey: <boolean>
serverName: <string>
port: <string>
clientCertificateFile: <string>
clientCertificatePassword: <string>
clientCertificateSelector: <string>
serverCAFile: <string>
connectRetries: <int>
connectTimeoutMS: <int>
activateKeys: <boolean>
keyStatePollingSeconds: <int>
security.enableEncryption

Type: boolean

Default: false

Enables encryption for the WiredTiger storage engine. 为WiredTiger存储引擎启用加密。You must set to true to pass in encryption keys and configurations.必须设置为true才能传入加密键和配置。

Note

Enterprise Feature企业功能

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

security.encryptionCipherMode

Type: string

Default: AES256-CBC

The cipher mode to use for encryption at rest:用于静态加密的密码模式:

ModeDescription描述
AES256-CBC256-bit Advanced Encryption Standard in Cipher Block Chaining Mode256位高级加密标准在密码块链接模式下的应用
AES256-GCM256-bit Advanced Encryption Standard in Galois/Counter ModeGalois/Counter模式下的256位高级加密标准
Available only on Linux.
Changed in version 4.0:4.0版更改:MongoDB Enterprise on Windows no longer supports AES256-GCM. Windows上的MongoDB Enterprise不再支持AES256-GCMThis cipher is now available only on Linux. 此密码现在仅在Linux上可用。
Note

Enterprise Feature企业功能

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

security.encryptionKeyFile

Type: string

The path to the local keyfile when managing keys via process other than KMIP. 通过KMIP以外的进程管理键时,本地键文件的路径。Only set when managing keys via process other than KMIP. If data is already encrypted using KMIP, MongoDB will throw an error.仅在通过KMIP以外的进程管理键时设置。如果数据已经使用KMIP加密,MongoDB将抛出一个错误。

Requires security.enableEncryption to be true.要求security.enableEncryptiontrue

Note

Enterprise Feature企业功能

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

security.kmip.keyIdentifier

Type: string

Unique KMIP identifier for an existing key within the KMIP server. KMIP服务器中现有键的唯一KMIP标识符。Include to use the key associated with the identifier as the system key. 包含将与标识符关联的键用作系统键。You can only use the setting the first time you enable encryption for the mongod instance. 您只能在第一次为mongod实例启用加密时使用该设置。Requires security.enableEncryption to be true.要求security.enableEncryptiontrue

If unspecified, MongoDB will request that the KMIP server create a new key to utilize as the system key.如果未指定,MongoDB将请求KMIP服务器创建一个新键作为系统键。

If the KMIP server cannot locate a key with the specified identifier or the data is already encrypted with a key, MongoDB will throw an error.如果KMIP服务器找不到具有指定标识符的键,或者数据已经用键加密,MongoDB将抛出错误。

Note

Enterprise Feature企业功能

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

security.kmip.rotateMasterKey

Type: boolean

Default: false

If true, rotate the master key and re-encrypt the internal keystore.如果为true,则旋转主键并重新加密内部键库。

Note

Enterprise Feature企业功能

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

Tip

See also: 另请参阅:

KMIP Master Key RotationKMIP主键旋转

security.kmip.serverName

Type: string

Hostname or IP address of the KMIP server to connect to. Requires security.enableEncryption to be true.要连接到的KMIP服务器的主机名或IP地址。要求security.enableEncryptiontrue

Starting in MongoDB 4.2.1 (and 4.0.14), you can specify multiple KMIP servers as a comma-separated list, e.g. server1.example.com,server2.example.com. 从MongoDB 4.2.1(和4.0.14)开始,您可以将多个KMIP服务器指定为逗号分隔的列表,例如server1.example.com,server2.example.comOn startup, the mongod will attempt to establish a connection to each server in the order listed, and will select the first server to which it can successfully establish a connection. KMIP server selection occurs only at startup.启动时,mongod将尝试按照列出的顺序建立与每个服务器的连接,并选择第一个可以成功建立连接的服务器。KMIP服务器选择仅在启动时发生。

mongod verifies the connection to the KMIP server on startup.在启动时验证与KMIP服务器的连接。

The server name specified in --kmipServerName must match either the Subject Alternative Name SAN or the Common Name CN on the certificate presented by the KMIP server. --kmipServerName中指定的服务器名称必须与KMIP服务器提供的证书上的使用者备用名称SAN或公用名称CN匹配。SAN can be a system name or an IP address.可以是系统名称或IP地址。

If SAN is present, mongod does not try to match against CN.如果存在SANmongod不会尝试与CN进行匹配。

If the hostname or IP address of the KMIP server does does not match either SAN or CN, mongod does not start.如果KMIP服务器的主机名或IP地址与SANCN不匹配,则mongod不会启动。

Starting in MongoDB 4.2, when performing comparison of SAN, MongoDB supports comparison of DNS names or IP addresses. In previous versions, MongoDB only supports comparisons of DNS names.从MongoDB 4.2开始,在进行SAN比较时,MongoDB支持DNS名称或IP地址的比较。在以前的版本中,MongoDB只支持DNS名称的比较。

Note

Enterprise Feature企业功能

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

security.kmip.port

Type: string

Default: 5696

Port number to use to communicate with the KMIP server. 用于与KMIP服务器通信的端口号。Requires security.kmip.serverName. Requires security.enableEncryption to be true.需要security.kmip.serverName。要求security.enableEncryptiontrue

If specifying multiple KMIP servers with security.kmip.serverName, the mongod will use the port specified with security.kmip.port for all provided KMIP servers.如果使用security.kmip.serverName指定多个KMIP服务器,则mongod将为所有提供的KMIP服务器使用使用security.kmip.port指定的端口。

Note

Enterprise Feature企业功能

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

security.kmip.clientCertificateFile

Type: string

Path to the .pem file used to authenticate MongoDB to the KMIP server. 用于向KMIP服务器验证MongoDB的.pem文件的路径。The specified .pem file must contain both the TLS/SSL certificate and key.指定的.pem文件必须同时包含TLS/SSL证书和键。

To use this setting, you must also specify the security.kmip.serverName setting.若要使用此设置,还必须指定security.kmip.serverName设置。

Note

Starting in 4.0, on macOS or Windows, you can use a certificate from the operating system's secure store instead of a PEM key file. 从4.0开始,在macOS或Windows上,您可以使用操作系统安全存储中的证书,而不是PEM键文件。See security.kmip.clientCertificateSelector.请参阅security.kmip.clientCertificateSelector

Note

Enterprise Feature企业功能

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

security.kmip.clientCertificatePassword

Type: string

The password to decrypt the client certificate (i.e. security.kmip.clientCertificateFile), used to authenticate MongoDB to the KMIP server. 解密客户端证书的密码(即security.kmip.clientCertificateFile),用于向KMIP服务器验证MongoDB。Use the option only if the certificate is encrypted.仅当证书已加密时才使用该选项。

Note

Enterprise Feature企业功能

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

security.kmip.clientCertificateSelector

Type: string

New in version 4.0:4.0版新增:(and 4.2.15, 4.4.7, and 5.0)

Available on Windows and macOS as an alternative to security.kmip.clientCertificateFile.在Windows和macOS上可用作security.kmip.clientCertificateFile的替代方案。

security.kmip.clientCertificateFile and security.kmip.clientCertificateSelector options are mutually exclusive. You can only specify one.选项是相互排斥的。您只能指定一个。

Specifies a certificate property in order to select a matching certificate from the operating system's certificate store to authenticate MongoDB to the KMIP server.指定一个证书属性,以便从操作系统的证书存储中选择一个匹配的证书,以向KMIP服务器验证MongoDB。

security.kmip.clientCertificateSelector accepts an argument of the format <property>=<value> where the property can be one of the following:接受格式为<property>=<value>的参数,其中该属性可以是以下内容之一:

Property属性Value type值类型Description描述
subjectASCII stringSubject name or common name on certificate证书上的使用者名称或通用名称
thumbprinthex stringA sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
The thumbprint is sometimes referred to as a fingerprint. thumbprint有时被称为fingerprint
Note

Enterprise Feature企业功能

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

security.kmip.serverCAFile

Type: string

Path to CA File. Used for validating secure client connection to KMIP server.CA文件的路径。用于验证与KMIP服务器的安全客户端连接。

Note

Starting in 4.0, on macOS or Windows, you can use a certificate from the operating system's secure store instead of a PEM key file. 从4.0开始,在macOS或Windows上,您可以使用操作系统安全存储中的证书,而不是PEM键文件。See security.kmip.clientCertificateSelector. 请参阅security.kmip.clientCertificateSelectorWhen using the secure store, you do not need to, but can, also specify the security.kmip.serverCAFile.使用安全存储时,您不需要,但也可以指定security.kmip.serverCAFile

Note

Enterprise Feature企业功能

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

security.kmip.connectRetries

Type: int

Default: 0

New in version 4.4. 4.4版新增。

How many times to retry the initial connection to the KMIP server. 重试与KMIP服务器的初始连接的次数。Use together with connectTimeoutMS to control how long the mongod waits for a response between each retry.connectTimeoutMS一起使用可以控制mongod在每次重试之间等待响应的时间。

Note

Enterprise Feature企业功能

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

security.kmip.connectTimeoutMS

Type: int

Default: 5000

New in version 4.4. 4.4版新增。

Timeout in milliseconds to wait for a response from the KMIP server. 等待KMIP服务器响应的超时(以毫秒为单位)。If the connectRetries setting is specified, the mongod will wait up to the value specified with connectTimeoutMS for each retry.如果指定了connectRetries设置,则mongod将在每次重试时等待connectTimeoutMS指定的值。

Value must be 1000 or greater.值必须大于或等于1000

Note

Enterprise Feature企业功能

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

security.kmip.activateKeys

Type: boolean

Default: true

New in version 5.3. 5.3版新增。

Activates all newly created KMIP keys upon creation and then periodically checks those keys are in an active state.在创建时激活所有新创建的KMIP键,然后定期检查这些键是否处于活动状态。

When security.kmip.activateKeys is true and you have existing keys on a KMIP server, the key must be activated first or the mongod node will fail to start.security.kmip.activateKeystrue并且您在KMIP服务器上有现有键时,必须首先激活该键,否则mongod节点将无法启动。

If the key being used by the mongod transitions into a non-active state, the mongod node will shut down unless kmipActivateKeys is false. 如果mongod使用的键转换为非活动状态,则mongod节点将关闭,除非kmipActivateKeysfalseTo ensure you have an active key, rotate the KMIP master key by using security.kmip.rotateMasterKey.要确保您有一个活动键,请使用security.kmip.rotateMasterKey

security.kmip.keyStatePollingSeconds

Type: int

Default: 900 seconds

New in version 5.3. 5.3版新增。

Frequency in seconds at which mongod polls the KMIP server for active keys.mongod轮询KMIP服务器以获取活动键的频率(以秒为单位)。

To disable disable polling, set the value to -1.要禁用禁用轮询,请将值设置为-1

security.kmip.useLegacyProtocol

Type: boolean

Default: false

New in version 7.0:7.0版新增:(and 6.0.6)

When true, mongod uses KMIP protocol version 1.0 or 1.1 instead of the default version. The default KMIP protocol is version 1.2.如果为truemongod将使用KMIP协议版本1.0或1.1,而不是默认版本。默认的KMIP协议是1.2版本。

To use audit log encryption with KMIP version 1.0 or 1.1, you must specify auditEncryptKeyWithKMIPGet at startup.若要在KMIP版本1.0或1.1中使用审核日志加密,必须在启动时指定auditEncryptKeyWithKMIPGet

To use KMIP protocol version 1.0 or 1.1, substitute your local values and add an entry like this to your mongod configuration file:要使用KMIP协议版本1.0或1.1,请替换您的本地值,并在mongod配置文件中添加这样的条目:

security:
enableEncryption: true
kmip:
serverName: "mdbhost.somecompany.com"
serverCAFile: "security/libs/trusted-ca.pem"
clientCertificateFile: "security/libs/trusted-client.pem"
useLegacyProtocol: true

security.sasl Options

security:
sasl:
hostName: <string>
serviceName: <string>
saslauthdSocketPath: <string>
security.sasl.hostName

Type: string

A fully qualified server domain name for the purpose of configuring SASL and Kerberos authentication. 用于配置SASL和Kerberos身份验证的完全限定服务器域名。The SASL hostname overrides the hostname only for the configuration of SASL and Kerberos.SASL主机名仅为SASL和Kerberos的配置覆盖主机名。

security.sasl.serviceName

Type: string

Registered name of the service using SASL. 使用SASL的服务的注册名称。This option allows you to override the default Kerberos service name component of the Kerberos principal name, on a per-instance basis. 此选项允许您根据每个实例覆盖Kerberos主体名称的默认Kerberos服务名称组件。If unspecified, the default value is mongodb.如果未指定,则默认值为mongodb

MongoDB permits setting this option only at startup. The setParameter can not change this setting.MongoDB只允许在启动时设置此选项。setParameter无法更改此设置。

This option is available only in MongoDB Enterprise.此选项仅在MongoDB Enterprise中可用。

Important

Ensure that your driver supports alternate service names. For mongosh and other MongoDB tools to connect to the new serviceName, see the gssapiServiceName option.确保您的驱动程序支持备用服务名称。要想让mongosh和其他MongoDB工具连接到新的serviceName,请参阅gssapiServiceName选项。

security.sasl.saslauthdSocketPath

Type: string

The path to the UNIX domain socket file for saslauthd.saslauthd的UNIX域套接字文件的路径。

security.ldap Options

security:
ldap:
servers: <string>
bind:
method: <string>
saslMechanisms: <string>
queryUser: <string>
queryPassword: <string | array>
useOSDefaults: <boolean>
transportSecurity: <string>
timeoutMS: <int>
retryCount: <int>
userToDNMapping: <string>
authz:
queryTemplate: <string>
validateLDAPServerConfig: <boolean>
security.ldap.servers

Type: string

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

The LDAP server against which the mongod or mongos authenticates users or determines what actions a user is authorized to perform on a given database. mongodmongos对用户进行身份验证或确定用户有权在给定数据库上执行哪些操作的LDAP服务器。If the LDAP server specified has any replicated instances, you may specify the host and port of each replicated server in a comma-delimited list.如果指定的LDAP服务器具有任何已复制实例,则可以在逗号分隔的列表中指定每个已复一致性务器的主机和端口。

If your LDAP infrastructure partitions the LDAP directory over multiple LDAP servers, specify one LDAP server or any of its replicated instances to security.ldap.servers. 如果LDAP基础结构在多个LDAP服务器上对LDAP目录进行分区,请将一个LDAP服务器或其任何复制实例指定为安全的LDAP服务器。MongoDB supports following LDAP referrals as defined in RFC 4511 4.1.10. MongoDB支持RFC 4511 4.1.10中定义的以下LDAP引用。Do not use security.ldap.servers for listing every LDAP server in your infrastructure.不要使用security.ldap.servers来列出基础结构中的每个LDAP服务器。

This setting can be configured on a running mongod or mongos using setParameter.可以使用setParameter在正在运行的mongodmongos上配置此设置。

If unset, mongod or mongos cannot use LDAP authentication or authorization.如果未设置,mongodmongos将无法使用LDAP身份验证或授权

security.ldap.bind.queryUser

Type: string

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

The identity with which mongod or mongos binds as, when connecting to or performing queries on an LDAP server.当连接到LDAP服务器或在LDAP服务器上执行查询时,mongodmongos绑定为的标识。

Only required if any of the following are true:仅当以下任何一项为真时才需要:

You must use queryUser with queryPassword.必须将queryUserqueryPassword一起使用。

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

This setting can be configured on a running mongod or mongos using setParameter.可以使用setParameter在正在运行的mongodmongos上配置此设置。

Note

Windows MongoDB deployments can use useOSDefaults instead of queryUser and queryPassword. Windows MongoDB部署可以使用useOSDefaults而不是queryUserqueryPasswordYou cannot specify both queryUser and useOSDefaults at the same time.不能同时指定queryUseruseOSDefaults

security.ldap.bind.queryPassword

Type: string or array

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

The password used to bind to an LDAP server when using queryUser. 使用queryUser时用于绑定到LDAP服务器的密码。You must use queryPassword with queryUser.您必须将queryPasswordqueryUser一起使用。

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

You can configure this setting on a running mongod or mongos using setParameter.您可以使用setParameter在正在运行的mongodmongos上配置此设置。

Starting in MongoDB 4.4, the ldapQueryPassword setParameter command accepts either a string or an array of strings. 从MongoDB 4.4开始,ldapQueryPassword setParameter命令接受字符串或字符串数组。If ldapQueryPassword is set to an array, MongoDB tries each password in order until one succeeds. Use a password array to roll over the LDAP account password without downtime.如果ldapQueryPassword设置为数组,MongoDB会按顺序尝试每个密码,直到成功为止。使用密码数组可以在不停机的情况下滚动LDAP帐户密码。

Note

Windows MongoDB deployments can use useOSDefaults instead of queryUser and queryPassword. Windows MongoDB部署可以使用useOSDefaults而不是queryUserqueryPasswordYou cannot specify both queryPassword and useOSDefaults at the same time.不能同时指定queryPassworduseOSDefaults

security.ldap.bind.useOSDefaults

Type: boolean

Default: false

Available in MongoDB Enterprise for the Windows platform only.仅适用于Windows平台的MongoDB Enterprise。

Allows mongod or mongos to authenticate, or bind, using your Windows login credentials when connecting to the LDAP server.允许mongodmongos在连接到LDAP服务器时使用Windows登录凭据进行身份验证或绑定。

Only required if:只有在以下情况下才需要:

Use useOSDefaults to replace queryUser and queryPassword.使用useOSDefaults替换queryUserqueryPassword

security.ldap.bind.method

Type: string

Default: simple

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

The method mongod or mongos uses to authenticate to an LDAP server. mongodmongos用于向LDAP服务器进行身份验证的方法。Use with queryUser and queryPassword to connect to the LDAP server.queryUserqueryPassword一起使用可连接到LDAP服务器。

method supports the following values:支持以下值:

  • simple - mongod or mongos uses simple authentication.mongodmongos使用简单的身份验证。
  • sasl - mongod or mongos uses SASL protocol for authenticationmongodmongos使用SASL协议进行身份验证

If you specify sasl, you can configure the available SASL mechanisms using security.ldap.bind.saslMechanisms. 如果指定sasl,则可以使用security.ldap.bind.saslMechanisms配置可用的sasl机制。mongod or mongos defaults to using DIGEST-MD5 mechanism.mongodmongos默认使用DIGEST-MD5机制。

security.ldap.bind.saslMechanisms

Type: string

Default: DIGEST-MD5

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

A comma-separated list of SASL mechanisms mongod or mongos can use when authenticating to the LDAP server. mongodmongos在向LDAP服务器进行身份验证时可以使用的SASL机制的逗号分隔列表。The mongod or mongos and the LDAP server must agree on at least one mechanism. mongodmongos和LDAP服务器必须至少在一种机制上达成一致。The mongod or mongos dynamically loads any SASL mechanism libraries installed on the host machine at runtime.mongodmongos在运行时动态加载主机上安装的任何SASL机制库。

Install and configure the appropriate libraries for the selected SASL mechanism(s) on both the mongod or mongos host and the remote LDAP server host. mongodmongos主机和远程LDAP服务器主机上为所选SASL机制安装和配置适当的库。Your operating system may include certain SASL libraries by default. Defer to the documentation associated with each SASL mechanism for guidance on installation and configuration.默认情况下,您的操作系统可能包括某些SASL库。有关安装和配置的指导,请参阅与每个SASL机制相关的文档。

If using the GSSAPI SASL mechanism for use with Kerberos Authentication, verify the following for the mongod or mongos host machine:如果使用GSSAPI SASL机制与Kerberos身份验证一起使用,请为mongodmongos主机验证以下内容:

Linux
  • The KRB5_CLIENT_KTNAME environment variable resolves to the name of the client Linux Keytab Files for the host machine. KRB5_CLIENT_KTNAME环境变量解析为主机的客户端Linux Keytab Files的名称。For more on Kerberos environment variables, please defer to the Kerberos documentation.有关Kerberos环境变量的更多信息,请参阅Kerberos文档
  • The client keytab includes a User Principal for the mongod or mongos to use when connecting to the LDAP server and execute LDAP queries.客户端键选项卡包括一个用户主体,供mongodmongos在连接到LDAP服务器并执行LDAP查询时使用。
Windows
If connecting to an Active Directory server, the Windows Kerberos configuration automatically generates a Ticket-Granting-Ticket when the user logs onto the system. 如果连接到活动目录服务器,则当用户登录到系统时,Windows Kerberos配置会自动生成票证授予票证Set useOSDefaults to true to allow mongod or mongos to use the generated credentials when connecting to the Active Directory server and execute queries.useOSDefaults设置为true,以允许mongodmongos在连接到活动目录服务器并执行查询时使用生成的凭据。

Set method to sasl to use this option.method设置为sasl以使用此选项。

Note

For a complete list of SASL mechanisms see the IANA listing. 有关SASL机制的完整列表,请参阅IANA列表Defer to the documentation for your LDAP or Active Directory service for identifying the SASL mechanisms compatible with the service.请参阅LDAP或活动目录服务的文档,以确定与该服务兼容的SASL机制。

MongoDB is not a source of SASL mechanism libraries, nor is the MongoDB documentation a definitive source for installing or configuring any given SASL mechanism. For documentation and support, defer to the SASL mechanism library vendor or owner.MongoDB不是SASL机制库的来源,MongoDB文档也不是安装或配置任何给定SASL机制的最终来源。有关文档和支持,请咨询SASL机制库供应商或所有者。

For more information on SASL, defer to the following resources:有关SASL的更多信息,请参阅以下资源:

security.ldap.transportSecurity

Type: string

Default: tls

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

By default, mongod or mongos creates a TLS/SSL secured connection to the LDAP server.默认情况下,mongodmongos会创建到LDAP服务器的TLS/SSL安全连接。

For Linux deployments, you must configure the appropriate TLS Options in /etc/openldap/ldap.conf file. 对于Linux部署,必须在/etc/openldap/ldap.conf文件中配置适当的TLS选项。Your operating system's package manager creates this file as part of the MongoDB Enterprise installation, via the libldap dependency. 您的操作系统的包管理器通过libldap依赖关系将此文件创建为MongoDB Enterprise安装的一部分。See the documentation for TLS Options in the ldap.conf OpenLDAP documentation for more complete instructions.有关更完整的说明,请参阅ldap.conf OpenLDAP文档中的TLS选项文档。

For Windows deployment, you must add the LDAP server CA certificates to the Windows certificate management tool. 对于Windows部署,必须将LDAP服务器CA证书添加到Windows证书管理工具中。The exact name and functionality of the tool may vary depending on operating system version. 该工具的确切名称和功能可能因操作系统版本而异。Please see the documentation for your version of Windows for more information on certificate management.有关证书管理的详细信息,请参阅Windows版本的文档。

Set transportSecurity to none to disable TLS/SSL between mongod or mongos and the LDAP server.transportSecurity设置为none可禁用mongodmongos与LDAP服务器之间的TLS/SSL。

Warning

Setting transportSecurity to none transmits plaintext information and possibly credentials between mongod or mongos and the LDAP server.transportSecurity设置为none将在mongodmongos与LDAP服务器之间传输明文信息,并可能传输凭据。

security.ldap.timeoutMS

Type: int

Default: 10000

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

The amount of time in milliseconds mongod or mongos should wait for an LDAP server to respond to a request.mongodmongos应等待LDAP服务器响应请求的时间(以毫秒为单位)。

Increasing the value of timeoutMS may prevent connection failure between the MongoDB server and the LDAP server, if the source of the failure is a connection timeout. 如果故障源是连接超时,那么增加timeoutMS的值可以防止MongoDB服务器和LDAP服务器之间的连接故障。Decreasing the value of timeoutMS reduces the time MongoDB waits for a response from the LDAP server.减少timeoutMS的值可以减少MongoDB等待LDAP服务器响应的时间。

This setting can be configured on a running mongod or mongos using setParameter.可以使用setParameter在正在运行的mongodmongos上配置此设置。

security.ldap.retryCount

New in version 6.1. 6.1版新增。

Type: int

Default: 0

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

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

This setting can be configured on a running mongod or mongos using setParameter.可以使用setParameter在正在运行的mongodmongos上配置此设置。

security.ldap.userToDNMapping

Type: string

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

Maps the username provided to mongod or mongos for authentication to a LDAP Distinguished Name (DN). 将提供给mongodmongos进行身份验证的用户名映射到LDAP可分辨名称(DN)。You may need to use userToDNMapping to transform a username into an LDAP DN in the following scenarios:在以下情况下,您可能需要使用userToDNMapping将用户名转换为LDAP DN:

  • Performing LDAP authentication with simple LDAP binding, where users authenticate to MongoDB with usernames that are not full LDAP DNs.使用简单的LDAP绑定执行LDAP身份验证,其中用户使用非完整LDAP DN的用户名向MongoDB进行身份验证。
  • Using an LDAP authorization query template that requires a DN.使用需要DN的LDAP授权查询模板
  • Transforming the usernames of clients authenticating to Mongo DB using different authentication mechanisms (e.g. x.509, kerberos) to a full LDAP DN for authorization.将使用不同身份验证机制(例如x.509、kerberos)向Mongo-DB进行身份验证的客户端的用户名转换为完整的LDAP DN以进行授权。

userToDNMapping expects a quote-enclosed JSON-string representing an ordered array of documents. 需要一个带引号的JSON字符串,该字符串表示文档的有序数组。Each document contains a regular expression match and either a substitution or ldapQuery template used for transforming the incoming username.每个文档都包含一个正则表达式匹配和一个用于转换传入用户名的substitutionldapQuery模板。

Each document in the array has the following form:数组中的每个文档都具有以下形式:

{
match: "<regex>"
substitution: "<LDAP DN>" | ldapQuery: "<LDAP Query>"
}
Field字段Description描述Example示例
matchAn ECMAScript-formatted regular expression (regex) to match against a provided username. ECMAScript格式的正则表达式(regex)与提供的用户名匹配。Each parenthesis-enclosed section represents a regex capture group used by substitution or ldapQuery.每个带括号的部分表示substitutionldapQuery使用的regex捕获组。"(.+)ENGINEERING" "(.+)DBA"
substitutionAn LDAP distinguished name (DN) formatting template that converts the authentication name matched by the match regex into a LDAP DN. LDAP可分辨名称(DN)格式模板,用于将匹配正则表达式匹配的身份验证名称转换为LDAP DN。Each curly bracket-enclosed numeric value is replaced by the corresponding regex capture group extracted from the authentication username via the match regex.每个用大括号括起来的数值都被通过match正则表达式从身份验证用户名中提取的相应正则表达式捕获组所替换。
The result of the substitution must be an RFC4514 escaped string. 替换的结果必须是RFC4514转义字符串。
"cn={0},ou=engineering, dc=example,dc=com"
ldapQueryA LDAP query formatting template that inserts the authentication name matched by the match regex into an LDAP query URI encoded respecting RFC4515 and RFC4516. LDAP查询格式化模板,将match正则表达式匹配的身份验证名称插入到根据RFC4515和RFC4516编码的LDAP查询URI中。Each curly bracket-enclosed numeric value is replaced by the corresponding regex capture group extracted from the authentication username via the match expression. 每个用大括号括起来的数值都被通过匹配表达式从身份验证用户名中提取的相应regex捕获组所替换。mongod or mongos executes the query against the LDAP server to retrieve the LDAP DN for the authenticated user. mongodmongos对LDAP服务器执行查询,以检索经过身份验证的用户的LDAP DN。mongod or mongos requires exactly one returned result for the transformation to be successful, or mongod or mongos skips this transformation.mongodmongos只需要一个返回结果就可以成功转换,或者mongod或者mongos跳过这个转换。"ou=engineering,dc=example, dc=com??one?(user={0})"
Note

An explanation of RFC4514, RFC4515, RFC4516, or LDAP queries is out of scope for the MongoDB Documentation. Please review the RFC directly or use your preferred LDAP resource.RFC4514RFC4515RFC4516或LDAP查询的解释超出了MongoDB文档的范围。请直接查看RFC或使用您首选的LDAP资源。

For each document in the array, you must use either substitution or ldapQuery. You cannot specify both in the same document.对于数组中的每个文档,必须使用substitutionldapQuery。不能在同一文档中同时指定两者。

When performing authentication or authorization, mongod or mongos steps through each document in the array in the given order, checking the authentication username against the match filter. 在执行身份验证或授权时,mongodmongos按给定顺序遍历数组中的每个文档,并根据匹配筛选器检查身份验证用户名。If a match is found, mongod or mongos applies the transformation and uses the output for authenticating the user. 如果找到匹配项,mongodmongos将应用转换并使用输出对用户进行身份验证。mongod or mongos does not check the remaining documents in the array.mongodmongos不检查数组中的其余文档。

If the given document does not match the provided authentication name, mongod or mongos continues through the list of documents to find additional matches. 如果给定的文档与提供的身份验证名称不匹配,mongodmongos会继续查看文档列表以查找其他匹配项。If no matches are found in any document, or the transformation the document describes fails, mongod or mongos returns an error.如果在任何文档中都找不到匹配项,或者文档描述的转换失败,mongodmongos将返回错误。

Starting in MongoDB 4.4, mongod or mongos also returns an error if one of the transformations cannot be evaluated due to networking or authentication failures to the LDAP server. 从MongoDB 4.4开始,如果其中一个转换由于LDAP服务器的网络或身份验证失败而无法评估,mongodmongos也会返回一个错误。mongod or mongos rejects the connection request and does not check the remaining documents in the array.mongodmongos拒绝连接请求,并且不检查数组中的其余文档。

Starting in MongoDB 5.0, userToDNMapping accepts an empty string "" or empty array [ ] in place of a mapping document. 从MongoDB 5.0开始,userToDNMapping接受一个空字符串""或空数组[]来代替映射文档。If providing an empty string or empty array to userToDNMapping, MongoDB will map the authenticated username as the LDAP DN. 如果向userToDNMapping提供空字符串或空数组,MongoDB将把经过身份验证的用户名映射为LDAP DN。Previously, providing an empty mapping document would cause mapping to fail.以前,提供空的映射文档会导致映射失败。

Example

The following shows two transformation documents. 下面显示了两个转换文档。The first document matches against any string ending in @ENGINEERING, placing anything preceding the suffix into a regex capture group. 第一个文档与任何以@ENGINEERING结尾的字符串匹配,将后缀之前的任何内容放入regex捕获组中。The second document matches against any string ending in @DBA, placing anything preceding the suffix into a regex capture group.第二个文档匹配任何以@DBA结尾的字符串,将后缀之前的任何内容放入regex捕获组中。

Important

You must pass the array to userToDNMapping as a string.必须将数组作为字符串传递给userToDNMapping。

"[
{
match: "(.+)@ENGINEERING.EXAMPLE.COM",
substitution: "cn={0},ou=engineering,dc=example,dc=com"
},
{
match: "(.+)@DBA.EXAMPLE.COM",
ldapQuery: "ou=dba,dc=example,dc=com??one?(user={0})"

}

]"

A user with username alice@ENGINEERING.EXAMPLE.COM matches the first document. The regex capture group {0} corresponds to the string alice. The resulting output is the DN "cn=alice,ou=engineering,dc=example,dc=com".

A user with username bob@DBA.EXAMPLE.COM matches the second document. The regex capture group {0} corresponds to the string bob. The resulting output is the LDAP query "ou=dba,dc=example,dc=com??one?(user=bob)". mongod or mongos executes this query against the LDAP server, returning the result "cn=bob,ou=dba,dc=example,dc=com".

If userToDNMapping is unset, mongod or mongos applies no transformations to the username when attempting to authenticate or authorize a user against the LDAP server.

This setting can be configured on a running mongod or mongos using the setParameter database command.

security.ldap.authz.queryTemplate

Type: string

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

A relative LDAP query URL formatted conforming to RFC4515 and RFC4516 that mongod executes to obtain the LDAP groups to which the authenticated user belongs to. The query is relative to the host or hosts specified in security.ldap.servers.

In the URL, you can use the following substitution tokens:在URL中,您可以使用以下替换令牌:

Substitution TokenDescription描述
{USER}Substitutes the authenticated username, or the transformed username if a userToDNMapping is specified.
{PROVIDED_USER}Substitutes the supplied username, i.e. before either authentication or LDAP transformation. 替换提供的用户名,即在身份验证或LDAP转换之前。
New in version 4.2. 4.2版新增。

When constructing the query URL, ensure that the order of LDAP parameters respects RFC4516:构造查询URL时,请确保LDAP参数的顺序符合RFC4516:

[ dn  [ ? [attributes] [ ? [scope] [ ? [filter] [ ? [Extensions] ] ] ] ] ]

If your query includes an attribute, mongod assumes that the query retrieves a list of the DNs which this entity is a member of.如果您的查询包含一个属性,mongod假设该查询检索该实体所属的DN列表。

If your query does not include an attribute, mongod assumes the query retrieves all entities which the user is member of.如果您的查询不包括属性,mongod假设查询检索用户所属的所有实体。

For each LDAP DN returned by the query, mongod assigns the authorized user a corresponding role on the admin database. 对于查询返回的每个LDAP DN,mongodadmin数据库中为授权用户分配相应的角色。If a role on the on the admin database exactly matches the DN, mongod grants the user the roles and privileges assigned to that role. 如果admin数据库上的角色与DN完全匹配,mongod将向用户授予分配给该角色的角色和权限。See the db.createRole() method for more information on creating roles.有关创建角色的更多信息,请参阅db.createRole()方法。

Example

This LDAP query returns any groups listed in the LDAP user object's memberOf attribute.此LDAP查询返回LDAP用户对象的memberOf属性中列出的任何组。

"{USER}?memberOf?base"

Your LDAP configuration may not include the memberOf attribute as part of the user schema, may possess a different attribute for reporting group membership, or may not track group membership through attributes. Configure your query with respect to your own unique LDAP configuration.LDAP配置可能不包括memberOf属性作为用户架构的一部分,可能拥有用于报告组成员身份的不同属性,或者可能不通过属性跟踪组成员身份。根据您自己的唯一LDAP配置配置查询。

If unset, mongod cannot authorize users using LDAP.如果未设置,mongod将无法使用LDAP对用户进行授权。

This setting can be configured on a running mongod using the setParameter database command.可以使用setParameter数据库命令在正在运行的mongod上配置此设置。

Note

An explanation of RFC4515, RFC4516 or LDAP queries is out of scope for the MongoDB Documentation. RFC4515RFC4516或LDAP查询的解释超出了MongoDB文档的范围。Please review the RFC directly or use your preferred LDAP resource.请直接查看RFC或使用您首选的LDAP资源。

security.ldap.validateLDAPServerConfig

Type: boolean

Default: true

Available in MongoDB Enterprise在MongoDB Enterprise中可用

A flag that determines if the mongod or mongos instance checks the availability of the LDAP server(s) as part of its startup:一个标志,用于确定mongodmongos实例是否在启动时检查LDAP服务器的可用性:

  • If true, the mongod or mongos instance performs the availability check and only continues to start up if the LDAP server is available.如果为truemongodmongos实例将执行可用性检查,并且只有在LDAP服务器可用时才会继续启动。
  • If false, the mongod or mongos instance skips the availability check; i.e. the instance starts up even if the LDAP server is unavailable.如果为falsemongodmongos实例将跳过可用性检查;即,即使LDAP服务器不可用,实例也会启动。

setParameter Option

setParameter

Set MongoDB parameter or parameters described in MongoDB Server Parameters设置MongoDB参数或MongoDB Server parameters中描述的参数

To set parameters in the YAML configuration file, use the following format:要在YAML配置文件中设置参数,请使用以下格式:

setParameter:
<parameter1>: <value1>
<parameter2>: <value2>

For example, to specify the enableLocalhostAuthBypass in the configuration file:例如,要在配置文件中指定enableLocalhostAuthBypass

setParameter:
enableLocalhostAuthBypass: false

LDAP ParametersLDAP参数

setParameter.ldapUserCacheInvalidationInterval

Type: int

Default: 30

For use with mongod servers using LDAP Authorization.用于使用LDAP授权mongod服务器。

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

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

setParameter:
ldapUserCacheInvalidationInterval: <int>

storage Options

Changed in version 6.1:6.1版更改:

  • MongoDB always enables journaling. As a result, MongoDB removes the storage.journal.enabled option and the corresponding --journal and --nojournal command-line options.MongoDB始终支持日志记录。因此,MongoDB删除了storage.journal.enabled选项以及相应的--journal--nojournal命令行选项。

Changed in version 4.4:4.4版更改:

  • MongoDB removes the storage.indexBuildRetry option and the corresponding --noIndexBuildRetry command-line option.MongoDB删除了storage.indexBuildRetry选项和相应的--noIndexBuildRetry命令行选项。
  • MongoDB deprecates storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB option. MongoDB弃用storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB选项。The option has no effect starting in MongoDB 4.4.该选项在MongoDB 4.4中启动时没有任何效果。

storage:
dbPath: <string>
journal:
commitIntervalMs: <num>
directoryPerDB: <boolean>
syncPeriodSecs: <int>
engine: <string>
wiredTiger:
engineConfig:
cacheSizeGB: <number>
journalCompressor: <string>
directoryForIndexes: <boolean>
maxCacheOverflowFileSizeGB: <number> // deprecated in MongoDB 4.4
collectionConfig:
blockCompressor: <string>
indexConfig:
prefixCompression: <boolean>
inMemory:
engineConfig:
inMemorySizeGB: <number>
oplogMinRetentionHours: <double>
storage.dbPath

Type: string

Default:

  • /data/db on Linux and macOS
  • \data\db on Windows

The directory where the mongod instance stores its data.mongod实例存储其数据的目录。

The storage.dbPath setting is available only for mongod.storage.dbPath设置仅适用于mongod

Note

Configuration Files配置文件

The default mongod.conf configuration file included with package manager installations uses the following platform-specific default values for storage.dbPath:包管理器安装中包含的默认mongod.conf配置文件使用以下特定于平台的storage.dbPath默认值:

PlatformPackage Manager程序包管理器Default storage.dbPath
RHEL / CentOS and Amazonyum/var/lib/mongo
SUSEzypper/var/lib/mongo
Ubuntu and Debianapt/var/lib/mongodb
macOSbrew/usr/local/var/mongodb

The Linux package init scripts do not expect storage.dbPath to change from the defaults. Linux包init脚本不希望storage.dbPath从默认值更改。If you use the Linux packages and change storage.dbPath, you will have to use your own init scripts and disable the built-in scripts.如果使用Linux软件包并更改storage.dbPath,则必须使用自己的init脚本并禁用内置脚本。

storage.journal.commitIntervalMs

Type: number

Default: 100

The maximum amount of time in milliseconds that the mongod process allows between journal operations. mongod进程在日志操作之间允许的最大时间(以毫秒为单位)。Values can range from 1 to 500 milliseconds. 值的范围可以是1到500毫秒。Lower values increase the durability of the journal, at the expense of disk performance.较低的值会以牺牲磁盘性能为代价,提高日志的持久性。

On WiredTiger, the default journal commit interval is 100 milliseconds. 在WiredTiger上,默认的日志提交间隔为100毫秒。Additionally, a write that includes or implies j:true will cause an immediate sync of the journal. 此外,包含或暗示j:true的写入将导致日志的立即同步。For details or additional conditions that affect the frequency of the sync, see Journaling Process.有关影响同步频率的详细信息或其他条件,请参阅日志处理

The storage.journal.commitIntervalMs setting is available only for mongod.storage.journal.commitIntervalMs设置仅适用于mongod

Not available for mongod instances that use the in-memory storage engine.不适用于使用内存中存储引擎mongod实例。

Note

Known Issue in 4.2.0: The storage.journal.commitIntervalMs is missing in 4.2.0.4.2.0中的已知问题:4.2.0中缺少storage.journal.commitIntervalMs

storage.directoryPerDB

Type: boolean

Default: false

When true, MongoDB uses a separate directory to store data for each database. 当为true时,MongoDB使用一个单独的目录来存储每个数据库的数据。The directories are under the storage.dbPath directory, and each subdirectory name corresponds to the database name.这些目录位于storage.dbPath目录下,每个子目录名称都与数据库名称相对应。

The storage.directoryPerDB setting is available only for mongod.storage.directoryPerDB设置仅适用于mongod

Not available for mongod instances that use the in-memory storage engine.不适用于使用内存中存储引擎mongod实例。

Starting in MongoDB 5.0, dropping the final collection in a database (or dropping the database itself) when storage.directoryPerDB is enabled deletes the newly empty subdirectory for that database.从MongoDB 5.0开始,在启用storage.directoryPerDB时,删除数据库中的最终集合(或删除数据库本身)会删除该数据库的新空子目录。

To change the storage.directoryPerDB option for existing deployments:要更改现有部署的storage.directoryPerDB选项,请执行以下操作:

  • For standalone instances:对于独立实例:

    1. Use mongodump on the existing mongod instance to generate a backup.对现有mongod实例使用mongodump生成备份。
    2. Stop the mongod instance.停止mongod实例。
    3. Add the storage.directoryPerDB value and configure a new data directory添加storage.directoryPerDB值并配置新的数据目录
    4. Restart the mongod instance.重新启动mongod实例。
    5. Use mongorestore to populate the new data directory.使用mongorestore填充新的数据目录。
  • For replica sets:对于复制副本集:

    1. Stop a secondary member.停止辅助成员。
    2. Add the storage.directoryPerDB value and configure a new data directory to that secondary member.添加storage.directoryPerDB值,为该辅助成员配置一个新的数据目录。
    3. Restart that secondary.重新启动辅助设备。
    4. Use initial sync to populate the new data directory.使用初始同步来填充新的数据目录。
    5. Update remaining secondaries in the same fashion.以相同的方式更新其余的辅助设备。
    6. Step down the primary, and update the stepped-down member in the same fashion.逐步减少主成员,并以相同的方式更新逐步减少的成员。
storage.syncPeriodSecs

Type: number

Default: 60

The amount of time that can pass before MongoDB flushes data to the data files via an fsync operation.MongoDB通过fsync操作将数据刷新到数据文件之前可能经过的时间量。

Do not set this value on production systems.不要在生产系统上设置此值。 In almost every situation, you should use the default setting.在几乎所有情况下,都应该使用默认设置。

Warning

If you set storage.syncPeriodSecs to 0, MongoDB will not sync the memory mapped files to disk.如果将storage.syncPeriodSecs设置为0,MongoDB将不会将内存映射文件同步到磁盘。

The mongod process writes data very quickly to the journal and lazily to the data files. mongod进程非常快速地将数据写入日志,并缓慢地写入数据文件。storage.syncPeriodSecs has no effect on Journaling, but if storage.syncPeriodSecs is set to 0 the journal will eventually consume all available disk space.日志记录没有影响,但如果storage.syncPeriodSecs设置为0,则日志记录最终将消耗所有可用磁盘空间。

The storage.syncPeriodSecs setting is available only for mongod.storage.syncPeriodSecs设置仅适用于mongod

Not available for mongod instances that use the in-memory storage engine.不适用于使用内存中存储引擎mongod实例。

storage.engine

Default: wiredTiger

Note

Starting in version 4.2, MongoDB removes the deprecated MMAPv1 storage engine.从4.2版本开始,MongoDB删除了不推荐使用的MMAPv1存储引擎。

The storage engine for the mongod database. Available values include:mongod数据库的存储引擎。可用值包括:

ValueDescription描述
wiredTigerTo specify the WiredTiger Storage Engine.指定WiredTiger存储引擎
inMemoryTo specify the In-Memory Storage Engine.指定内存中存储引擎
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。
If you attempt to start a mongod with a storage.dbPath that contains data files produced by a storage engine other than the one specified by storage.engine, mongod will refuse to start. 如果您尝试使用storage.dbPath启动mongod,该storage.engine包含存储引擎(而不是storage.engine指定的存储引擎)生成的数据文件,mongod将拒绝启动。
storage.oplogMinRetentionHours

Type: double

New in version 4.4:4.4版新增:Specifies the minimum number of hours to preserve an oplog entry, where the decimal values represent the fractions of an hour. 指定保留操作日志项的最小小时数,其中十进制值表示小时的小数。For example, a value of 1.5 represents one hour and thirty minutes.例如,值1.5表示一小时三十分钟。

The value must be greater than or equal to 0. 该值必须大于或等于0A value of 0 indicates that the mongod should truncate the oplog starting with the oldest entries to maintain the configured maximum oplog size.0表示mongod应该从最旧的条目开始截断oplog,以保持配置的最大oplog大小。

Defaults to 0.默认值为0。

A mongod started with oplogMinRetentionHours only removes an oplog entry if:oplogMinRetentionHours开头的mongod仅在以下情况下删除oplog条目:

  • The oplog has reached the maximum configured oplog size andoplog已达到配置的最大oplog大小,并且
  • The oplog entry is older than the configured number of hours based on the host system clock.oplog条目早于基于主机系统时钟配置的小时数。

The mongod has the following behavior when configured with a minimum oplog retention period:当配置了最短oplog保留期时,mongod具有以下行为:

  • The oplog can grow without constraint so as to retain oplog entries for the configured number of hours. oplog可以无限制地增长,以便在配置的小时数内保留oplog条目。This may result in reduction or exhaustion of system disk space due to a combination of high write volume and large retention period.由于高写入量和大保留期的组合,这可能导致系统磁盘空间的减少或耗尽。
  • If the oplog grows beyond its maximum size, the mongod may continue to hold that disk space even if the oplog returns to its maximum size or is configured for a smaller maximum size. 如果oplog增长超过其最大大小,即使oplog恢复到其最大大小或配置为更小的最大大小,mongod也可能继续保留该磁盘空间。See Reducing Oplog Size Does Not Immediately Return Disk Space.请参阅减少操作日志大小不会立即返回磁盘空间
  • The mongod compares the system wall clock to an oplog entries creation wall clock time when enforcing oplog entry retention. Clock drift between cluster components may result in unexpected oplog retention behavior. mongod在强制执行oplog条目保留时,将系统墙时钟与oplog条目创建墙时钟时间进行比较。集群组件之间的时钟漂移可能会导致意外的oplog保留行为。See Clock Synchronization for more information on clock synchronization across cluster members.有关集群成员间时钟同步的详细信息,请参阅时钟同步

To change the minimum oplog retention period after starting the mongod, use replSetResizeOplog. 要在启动mongod后更改oplog的最小保留期,请使用replSetResizeOplogreplSetResizeOplog enables you to resize the oplog dynamically without restarting the mongod process. 使您能够在不重新启动mongod进程的情况下动态调整oplog的大小。To persist the changes made using replSetResizeOplog through a restart, update the value of oplogMinRetentionHours.要在重新启动时保持使用replSetResizeOplog所做的更改,请更新oplogMinRetentionHours的值。

storage.wiredTiger Options

storage:
wiredTiger:
engineConfig:
cacheSizeGB: <number>
journalCompressor: <string>
directoryForIndexes: <boolean>
maxCacheOverflowFileSizeGB: <number> // Deprecated in MongoDB 4.4
collectionConfig:
blockCompressor: <string>
indexConfig:
prefixCompression: <boolean>
storage.wiredTiger.engineConfig.cacheSizeGB

Type: float

Defines the maximum size of the internal cache that WiredTiger will use for all data. 定义WiredTiger将用于所有数据的内部缓存的最大大小。The memory consumed by an index build (see maxIndexBuildMemoryUsageMegabytes) is separate from the WiredTiger cache memory.索引构建所消耗的内存(请参阅maxIndexBuildMemoryUsageMegabytes)与WiredTiger缓存内存是分开的。

Values can range from 0.25 GB to 10000 GB.值的范围从0.25 GB到10000 GB。

Starting in MongoDB 3.4, the default WiredTiger internal cache size is the larger of either:从MongoDB 3.4开始,默认的WiredTiger内部缓存大小是以下两者中较大的一个:

  • 50% of (RAM - 1 GB), or
  • 256 MB.

For example, on a system with a total of 4GB of RAM the WiredTiger cache will use 1.5GB of RAM (0.5 * (4 GB - 1 GB) = 1.5 GB). 例如,在总内存为4GB的系统上,WiredTiger缓存将使用1.5GB的RAM(0.5 * (4 GB - 1 GB) = 1.5 GB)。Conversely, a system with a total of 1.25 GB of RAM will allocate 256 MB to the WiredTiger cache because that is more than half of the total RAM minus one gigabyte (0.5 * (1.25 GB - 1 GB) = 128 MB < 256 MB).相反,总RAM为1.25 GB的系统将为WiredTiger缓存分配256 MB,因为这超过了总RAM的一半减去1 GB(0.5 * (1.25 GB - 1 GB) = 128 MB < 256 MB)。

Note

In some instances, such as when running in a container, the database can have memory constraints that are lower than the total system memory. In such instances, this memory limit, rather than the total system memory, is used as the maximum RAM available.在某些情况下,例如在容器中运行时,数据库的内存约束可能低于系统总内存。在这种情况下,这个内存限制,而不是整个系统内存,被用作可用的最大RAM。

To see the memory limit, see hostInfo.system.memLimitMB.要查看内存限制,请参阅hostInfo.system.memLimitMB

Avoid increasing the WiredTiger internal cache size above its default value.避免将WiredTiger内部缓存大小增加到其默认值以上。

With WiredTiger, MongoDB utilizes both the WiredTiger internal cache and the filesystem cache.有了WiredTiger,MongoDB既利用了WiredTinger内部缓存,也利用了文件系统缓存。

Via the filesystem cache, MongoDB automatically uses all free memory that is not used by the WiredTiger cache or by other processes.通过文件系统缓存,MongoDB自动使用WiredTiger缓存或其他进程未使用的所有可用内存。

Note

The storage.wiredTiger.engineConfig.cacheSizeGB limits the size of the WiredTiger internal cache. storage.wiredTiger.engineConfig.cacheSizeGB限制了WiredTiger内部缓存的大小。The operating system will use the available free memory for filesystem cache, which allows the compressed MongoDB data files to stay in memory. In addition, the operating system will use any free RAM to buffer file system blocks and file system cache.操作系统将使用可用的空闲内存进行文件系统缓存,这允许压缩的MongoDB数据文件留在内存中。此外,操作系统将使用任何空闲的RAM来缓冲文件系统块和文件系统缓存。

To accommodate the additional consumers of RAM, you may have to decrease WiredTiger internal cache size.为了容纳更多的RAM消耗者,您可能需要减小WiredTiger内部缓存的大小。

The default WiredTiger internal cache size value assumes that there is a single mongod instance per machine. 默认的WiredTiger内部缓存大小值假定每台机器有一个mongod实例。If a single machine contains multiple MongoDB instances, then you should decrease the setting to accommodate the other mongod instances.如果一台机器包含多个MongoDB实例,那么应该减少设置以容纳其他mongod实例。

If you run mongod in a container (e.g. lxc, cgroups, Docker, etc.) that does not have access to all of the RAM available in a system, you must set storage.wiredTiger.engineConfig.cacheSizeGB to a value less than the amount of RAM available in the container. 如果在无法访问系统中所有可用RAM的容器(例如lxccgroups、Docker等)中运行mongod,则必须将storage.wiredTiger.engineConfig.cacheSizeGB设置为小于容器中可用RAM量的值。The exact amount depends on the other processes running in the container. 确切的数量取决于容器中运行的其他进程。See memLimitMB.请参阅memLimitMB

storage.wiredTiger.engineConfig.journalCompressor

Default: snappy

Specifies the type of compression to use to compress WiredTiger journal data.指定用于压缩WiredTiger日志数据的压缩类型。

Available compressors are:可用的压缩机有:

  • none
  • snappy
  • zlib
  • zstd (Available starting in MongoDB 4.2)(从MongoDB 4.2开始提供)
storage.wiredTiger.engineConfig.directoryForIndexes

Type: boolean

Default: false

When storage.wiredTiger.engineConfig.directoryForIndexes is true, mongod stores indexes and collections in separate subdirectories under the data (i.e. storage.dbPath) directory. storage.wiredTiger.engineConfig.directoryForIndexestrue时,mongod将索引和集合存储在data(即storage.dbPath)目录下的单独子目录中。Specifically, mongod stores the indexes in a subdirectory named index and the collection data in a subdirectory named collection.具体来说,mongod将索引存储在名为index的子目录中,将集合数据存储在名名为collection的子目录下。

By using a symbolic link, you can specify a different location for the indexes. 通过使用符号链接,可以为索引指定不同的位置。Specifically, when mongod instance is not running, move the index subdirectory to the destination and create a symbolic link named index under the data directory to the new destination.具体地说,当mongod实例没有运行时,将index子目录移动到目标,并在数据目录下创建一个名为index的符号链接到新的目标。

storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB

Type: float

Note

Deprecated in MongoDB 4.4

MongoDB deprecates the storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB option. MongoDB建议弃用storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB选项。The option has no effect starting in MongoDB 4.4.该选项在MongoDB 4.4中启动时没有任何效果。

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

The setting can accept the following values:该设置可以接受以下值:

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

To change the maximum size during runtime, use the wiredTigerMaxCacheOverflowSizeGB parameter.要在运行时更改最大大小,请使用wiredTigerMaxCacheOverflowSizeGB参数。

Available starting in MongoDB 4.2.1 (and 4.0.12)从MongoDB 4.2.1(和4.0.12)开始提供

storage.wiredTiger.engineConfig.zstdCompressionLevel

Type: integer

Default: 6

Specifies the level of compression applied when using the zstd compressor.指定使用zstd压缩器时应用的压缩级别。

Values can range from 1 to 22.值的范围从1到22。

The higher the specified value for zstdCompressionLevel the higher the compression which is applied.zstdCompressionLevel的指定值越高,应用的压缩就越高。

Only applicable when blockCompressor is set to zstd.仅当blockCompressor设置为zstd时适用。

Available starting in MongoDB 5.0可在MongoDB 5.0中启动

storage.wiredTiger.collectionConfig.blockCompressor

Default: snappy

Specifies the default compression for collection data. You can override this on a per-collection basis when creating collections.指定集合数据的默认压缩。在创建集合时,可以按每个集合覆盖此项。

Available compressors are:

storage.wiredTiger.collectionConfig.blockCompressor affects all collections created. 影响所有创建的集合。If you change the value of storage.wiredTiger.collectionConfig.blockCompressor on an existing MongoDB deployment, all new collections will use the specified compressor. Existing collections will continue to use the compressor specified when they were created, or the default compressor at that time.如果更改现有MongoDB部署上storage.wiredTiger.collectionConfig.blockCompressor的值,则所有新集合都将使用指定的压缩器。现有集合将继续使用创建时指定的压缩器,或当时的默认压缩器。

storage.wiredTiger.indexConfig.prefixCompression

Default: true

Enables or disables prefix compression for index data.启用或禁用索引数据的前缀压缩

Specify true for storage.wiredTiger.indexConfig.prefixCompression to enable prefix compression for index data, or false to disable prefix compression for index data.storage.wiredTiger.indexConfig.prefixCompression指定true可启用索引数据的前缀压缩,或为false可禁用索引数据的后缀压缩。

The storage.wiredTiger.indexConfig.prefixCompression setting affects all indexes created. storage.wiredTiger.indexConfig.prefixCompression设置会影响所有创建的索引。If you change the value of storage.wiredTiger.indexConfig.prefixCompression on an existing MongoDB deployment, all new indexes will use prefix compression. 如果在现有MongoDB部署上更改storage.wiredTiger.indexConfig.prefixCompression的值,则所有新索引都将使用前缀压缩。Existing indexes are not affected.现有索引不受影响。

storage.inmemory Options

storage:
inMemory:
engineConfig:
inMemorySizeGB: <number>
storage.inMemory.engineConfig.inMemorySizeGB

Type: float

Default: 50% of physical RAM less 1 GB:50%的物理RAM小于1 GB

Values can range from 256MB to 10TB and can be a float.值的范围从256MB到10TB,并且可以是浮点值。

Maximum amount of memory to allocate for in-memory storage engine data, including indexes, oplog if the mongod is part of replica set, replica set or sharded cluster metadata, etc.内存中存储引擎数据分配的最大内存量,包括索引、oplog(如果mongod是副本集、副本集或分片集群元数据的一部分)等。

By default, the in-memory storage engine uses 50% of physical RAM minus 1 GB.默认情况下,内存中存储引擎使用50%的物理RAM减去1 GB。

Note

Enterprise Feature企业功能

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

operationProfiling Options

operationProfiling:
mode: <string>
slowOpThresholdMs: <int>
slowOpSampleRate: <double>
filter: <string>
operationProfiling.mode

Type: string

Default: off

Specifies which operations should be profiled. The following profiler levels are available:指定应探查哪些操作。以下探查器级别可用:

LevelDescription描述
offThe profiler is off and does not collect any data. This is the default profiler level.探查器已关闭,不集合任何数据。这是默认的探查器级别。
slowOpThe profiler collects data for operations that take longer than the value of slowms.探查器为耗时超过slowms值的操作集合数据。
allThe profiler collects data for all operations.探查器集合所有操作的数据。
Warning

Profiling can degrade performance and expose unencrypted query data in the system log. 分析可能会降低性能,并在系统日志中公开未加密的查询数据。Carefully consider any performance and security implications before configuring and enabling the profiler on a production deployment.在生产部署上配置和启用探查器之前,请仔细考虑任何性能和安全影响。

See Profiler Overhead for more information on potential performance degradation.有关潜在性能下降的更多信息,请参阅探查器开销

operationProfiling.slowOpThresholdMs

Type: integer

Default: 100

The slow operation time threshold, in milliseconds. 慢速操作时间阈值,以毫秒为单位。Operations that run for longer than this threshold are considered slow.运行时间超过此阈值的操作被认为是慢速的。

When logLevel is set to 0, MongoDB records slow operations to the diagnostic log at a rate determined by slowOpSampleRate.logLevel设置为0时,MongoDB会以slowOpSampleRate确定的速率将慢速操作记录到诊断日志中。

At higher logLevel settings, all operations appear in the diagnostic log regardless of their latency with the following exception: the logging of slow oplog entry messages by the secondaries. 在更高的logLevel设置下,所有操作都会显示在诊断日志中,无论其延迟如何,但以下情况除外:由secondary记录慢速操作日志条目消息The secondaries log only the slow oplog entries; increasing the logLevel does not log all oplog entries.辅助设备只记录慢速操作日志条目;增加logLevel不会记录所有oplog条目。

This setting is available for mongod and mongos.此设置可用于mongodmongos

  • For mongod instances, the setting affects both the diagnostic log and, if enabled, the profiler.对于mongod实例,该设置会影响诊断日志,如果启用,还会影响探查器。
  • For mongos instances, the setting affects the diagnostic log only and not the profiler, since profiling is not available on mongos.对于mongos实例,该设置仅影响诊断日志,而不影响探查器,因为在mongos上无法进行探查。
operationProfiling.slowOpSampleRate

Type: double

Default: 1.0

The fraction of slow operations that should be profiled or logged. 应该对慢速操作进行分析或记录的部分。operationProfiling.slowOpSampleRate accepts values between 0 and 1, inclusive.接受0和1之间的值(包括0和1)。

Changed in version 4.0:4.0版更改:The slowOpSampleRate setting is available for mongod and mongos. slowOpSampleRate设置可用于mongodmongosIn earlier versions, slowOpSampleRate is available for mongod only.在早期版本中,slowOpSampleRate仅适用于mongod

  • For mongod instances, the setting affects both the diagnostic log and, if enabled, the profiler.对于mongod实例,该设置会影响诊断日志,如果启用,还会影响探查器。
  • For mongos instances, the setting affects the diagnostic log only and not the profiler since profiling is not available on mongos.对于mongos实例,该设置仅影响诊断日志,而不影响探查器,因为在mongos上无法进行探查。
operationProfiling.filter

Type: string representation of a query document:查询文档的字符串表示

A filter expression that controls which operations are profiled and logged.一个筛选器表达式,用于控制对哪些操作进行分析和记录。

When filter is set, slowOpThresholdMs and slowOpSampleRate are not used for profiling and slow-query log lines.设置filter后,slowOpThresholdMsslowOpSampleRate不会用于分析和慢速查询日志行。

When you set a profile filter in the configuration file, the filter applies to all databases in the deployment. 在配置文件中设置配置文件筛选器时,该筛选器将应用于部署中的所有数据库。To set a profile filter for a specific database, use the db.setProfilingLevel() method.要为特定数据库设置配置文件筛选器,请使用db.setProfilingLevel()方法。

The option takes a string representation of a query document of the form:该选项采用以下形式的查询文档的字符串表示形式:

{ <field1>: <expression1>, ... }

The <field> can be any field in the profiler output. The <expression> is a query condition expression.<field>可以是探查器输出中的任何字段<expression>是一个查询条件表达式

To specify a profiling filter in a configuration file, you must:要在配置文件中指定分析筛选器,您必须:

  • Enclose the filter document in single quotes to pass the document as a string.将筛选文档用单引号括起来,以字符串形式传递文档。
  • Use the YAML format of the configuration file.使用配置文件的YAML格式。

For example, the following filter configures the profiler to log query operations that take longer than 2 seconds:例如,以下filter将探查器配置为记录耗时超过2秒的查询操作:

operationProfiling:
mode: all
filter: '{ op: "query", millis: { $gt: 2000 } }'

New in version 4.4.2. 4.4.2版新增。

replication Options

replication:
oplogSizeMB: <int>
replSetName: <string>
enableMajorityReadConcern: <boolean>
replication.oplogSizeMB

Type: integer

The maximum size in megabytes for the replication operation log (i.e., the oplog).复制操作日志(即oplog)的最大大小(MB)。

Note

The oplog can grow past its configured size limit to avoid deleting the majority commit point.oplog可以超过其配置的大小限制,以避免删除majority commit point多数提交点

By default, the mongod process creates an oplog based on the maximum amount of space available. 默认情况下,mongod进程会根据可用的最大空间量创建一个oplogFor 64-bit systems, the oplog is typically 5% of available disk space.对于64位系统,操作日志通常是可用磁盘空间的5%。

Once the mongod has created the oplog for the first time, changing the replication.oplogSizeMB option will not affect the size of the oplog. 一旦mongod第一次创建了oplog,更改replication.oplogSizeMB选项将不会影响oplog的大小。To change the maximum oplog size after starting the mongod, use replSetResizeOplog. 要在启动mongod后更改最大操作日志大小,请使用replSetResizeOplogreplSetResizeOplog enables you to resize the oplog dynamically without restarting the mongod process. 使您能够在不重新启动mongod进程的情况下动态调整oplog的大小。To persist the changes made using replSetResizeOplog through a restart, update the value of oplogSizeMB.要在重新启动时保持使用replSetResizeOplog所做的更改,请更新oplogSizeMB的值。

See Oplog Size for more information.有关详细信息,请参阅操作日志大小

The replication.oplogSizeMB setting is available only for mongod.replication.oplogSizeMB设置仅适用于mongod

replication.replSetName

Type: string

The name of the replica set that the mongod is part of. mongod所属的复制集的名称。All hosts in the replica set must have the same set name.复制副本集中的所有主机都必须具有相同的集名称。

If your application connects to more than one replica set, each set must have a distinct name. Some drivers group replica set connections by replica set name.如果应用程序连接到多个复制副本集,则每个复制副本集都必须具有不同的名称。某些驱动程序按副本集名称对副本集连接进行分组。

The replication.replSetName setting is available only for mongod.replication.replSetName设置仅可用于mongod

Starting in MongoDB 4.0:从MongoDB 4.0开始:

replication.enableMajorityReadConcern

Default: true

Configures support for "majority" read concern.

Starting in MongoDB 5.0, enableMajorityReadConcern cannot be changed and is always set to true. Attempting to start a storage engine that does not support majority read concern with the --enableMajorityReadConcern option will fail and return an error message.从MongoDB 5.0开始,enableMajorityReadConcern不能更改,并且始终设置为true。尝试使用--enableMajorityReadConcern选项启动不支持多数读取关注的存储引擎将失败,并返回错误消息。

In earlier versions of MongoDB, enableMajorityReadConcern was configurable.在MongoDB的早期版本中,enableMajorityReadConcern是可配置的。

Warning

If you are using a three-member primary-secondary-arbiter (PSA) architecture, consider the following:如果您使用的是由三个成员组成的主辅仲裁器(PSA)架构,请考虑以下事项:

  • The write concern "majority" can cause performance issues if a secondary is unavailable or lagging. 如果辅助设备不可用或滞后,写入关注"majority"可能会导致性能问题。For advice on how to mitigate these issues, see Mitigate Performance Issues with PSA Replica Set.有关如何缓解这些问题的建议,请参阅使用PSA副本集缓解性能问题
  • If you are using a global default "majority" and the write concern is less than the size of the majority, your queries may return stale (not fully replicated) data.如果使用全局默认的"majority",并且写入关注小于多数的大小,则查询可能会返回过时(未完全复制)的数据。

sharding Options

sharding:
clusterRole: <string>
archiveMovedChunks: <boolean>
sharding.clusterRole

Type: string

The role that the mongod instance has in the sharded cluster. Set this setting to one of the following:mongod实例在分片集群中的角色。将此设置设置为以下其中一项:

ValueDescription描述
configsvrStart this instance as a config server. 将此实例作为配置服务器启动。The instance starts on port 27019 by default.默认情况下,实例在端口27019上启动。
When you configure a MongoDB instance as clusterRole configsvr you must also specify a replSetName. 当您将MongoDB实例配置为clusterRole configsvr时,还必须指定replSetName
shardsvrStart this instance as a shard. 将此实例作为分片启动。The instance starts on port 27018 by default.默认情况下,实例在端口27018上启动。
When you configure a MongoDB instance as a a clusterRole shardsvr you must also specify a replSetName. 当您将MongoDB实例配置为clusterRole shardsvr时,还必须指定replSetName
Note

Setting sharding.clusterRole requires the mongod instance to be running with replication. 设置sharding.clusterRole需要mongod实例与复制一起运行。To deploy the instance as a replica set member, use the replSetName setting and specify the name of the replica set.要将实例部署为副本集成员,请使用replSetName设置并指定副本集的名称。

The sharding.clusterRole setting is available only for mongod.sharding.clusterRole设置仅适用于mongod

sharding.archiveMovedChunks

Type: boolean

Default: false.

During chunk migration, a shard does not save documents migrated from the shard.在chunk迁移过程中,分片不会保存从分片迁移的文档。

auditLog Options

Note

Available only in MongoDB Enterprise and MongoDB Atlas.仅在MongoDB EnterpriseMongoDB Atlas中提供。

auditLog:
destination: <string>
format: <string>
path: <string>
filter: <string>
auditLog.auditEncryptionKeyIdentifier

Type: string

New in version 6.0. 6.0版新增。

Specifies the unique identifier of the Key Management Interoperability Protocol (KMIP) key for audit log encryption.指定用于审核日志加密的键管理互操作性协议(KMIP)键的唯一标识符。

You cannot use auditLog.auditEncryptionKeyIdentifier and auditLog.localAuditKeyFile together.

Note

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

auditLog.compressionMode

Type: string

New in version 5.3. 5.3版新增。

Specifies the compression mode for audit log encryption. 指定审核日志加密的压缩模式。You must also enable audit log encryption using either auditLog.auditEncryptionKeyIdentifier or auditLog.localAuditKeyFile.您还必须使用auditLog.auditEncryptionKeyIdentifierauditLog.localAuditKeyFile启用审核日志加密。

auditLog.compressionMode can be set to one of these values:可以设置为以下值之一:

ValueDescription描述
zstdUse the zstd algorithm to compress the audit log.使用zstd算法压缩审核日志。
none (default)Do not compress the audit log.不要压缩审核日志。
Note

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

auditLog.destination

Type: string

When set, auditLog.destination enables auditing and specifies where mongos or mongod sends all audit events.设置后,auditLog.destination将启用审核,并指定mongosmongod发送所有审核事件的位置。

auditLog.destination can have one of the following values:可以具有以下值之一:

ValueDescription描述
syslogOutput the audit events to syslog in JSON format. Not available on Windows. 以JSON格式将审核事件输出到syslog。在Windows上不可用。Audit messages have a syslog severity level of info and a facility level of user.审核消息的系统日志严重性级别为info,设施级别为user
The syslog message limit can result in the truncation of audit messages. 系统日志消息限制可能导致截断审核消息。The auditing system will neither detect the truncation nor error upon its occurrence. 审计系统既不会检测到截断,也不会在出现错误时检测到。
consoleOutput the audit events to stdout in JSON format.以JSON格式将审核事件输出到stdout
fileOutput the audit events to the file specified in auditLog.path in the format specified in auditLog.format.将审核事件以auditLog.format中指定的格式输出到auditLog.path中指定的文件。
Note

Available only in MongoDB Enterprise and MongoDB Atlas.仅在MongoDB EnterpriseMongoDB Atlas中提供。

auditLog.filter

Type: string representation of a document

The filter to limit the types of operations the audit system records. The option takes a string representation of a query document of the form:用于限制审核系统记录的操作类型的筛选器。该选项采用以下形式的查询文档的字符串表示形式:

{ <field1>: <expression1>, ... }

The <field> can be any field in the audit message, including fields returned in the param document. The <expression> is a query condition expression.<field>可以是审核消息中的任何字段,包括param文档中返回的字段。<expression>是一个查询条件表达式。

To specify an audit filter, enclose the filter document in single quotes to pass the document as a string.若要指定审核筛选器,请将筛选器文档用单引号括起来,以字符串形式传递该文档。

To specify the audit filter in a configuration file, you must use the YAML format of the configuration file.要在配置文件中指定审核筛选器,必须使用配置文件的YAML格式。

Note

Available only in MongoDB Enterprise and MongoDB Atlas.仅在MongoDB EnterpriseMongoDB Atlas中提供。

auditLog.format

Type: string

The format of the output file for auditing if destination is file. 如果目标file,则用于审核的输出文件的格式。The auditLog.format option can have one of the following values:auditLog.format选项可以具有以下值之一:

ValueDescription描述
JSONOutput the audit events in JSON format to the file specified in auditLog.path.将审核事件以JSON格式输出到auditLog.path中指定的文件。
BSONOutput the audit events in BSON binary format to the file specified in auditLog.path.以BSON二进制格式将审核事件输出到auditLog.path中指定的文件。

Printing audit events to a file in JSON format degrades server performance more than printing to a file in BSON format.将审核事件打印到JSON格式的文件比打印到BSON格式的文件更能降低服务器性能。

Note

Available only in MongoDB Enterprise and MongoDB Atlas.仅在MongoDB EnterpriseMongoDB Atlas中提供。

auditLog.localAuditKeyFile

Type: string

New in version 5.3. 5.3版新增。

Specifies the path and file name for a local audit key file for audit log encryption.指定用于审核日志加密的本地审核键文件的路径和文件名。

Note

Only use auditLog.localAuditKeyFile for testing because the key is not secured. 由于键不安全,只能使用auditLog.localAuditKeyFile进行测试。To secure the key, use auditLog.auditEncryptionKeyIdentifier and an external Key Management Interoperability Protocol (KMIP) server.要保护键,请使用auditLog.auditEncryptionKeyIdentifier和外部键管理互操作性协议(KMIP)服务器。

You cannot use auditLog.localAuditKeyFile and auditLog.auditEncryptionKeyIdentifier together.不能同时使用auditLog.localAuditKeyFileauditLog.auditEncryptionKeyIdentifier

Note

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

auditLog.path

Type: string

The output file for auditing if destination has value of file. 如果destination的值为file,则用于审核的输出文件。The auditLog.path option can take either a full path name or a relative path name.auditLog.path选项可以采用完整路径名,也可以采用相对路径名。

auditLog.runtimeConfiguration

Type: boolean

Specifies if a node allows runtime configuration of audit filters and the auditAuthorizationSuccess variable. 指定节点是否允许运行时配置审核筛选器和auditAuthenticationSuccess变量。If true the node can take part in Online Audit Filter Management.如果为true,则节点可以参与联机审核筛选器管理。

Note

Available only in MongoDB Enterprise and MongoDB Atlas.仅在MongoDB EnterpriseMongoDB Atlas中提供。

mongos -only Options

replication:
localPingThresholdMs: <int>

sharding:
configDB: <string>
replication.localPingThresholdMs

Type: integer

Default: 15

The ping time, in milliseconds, that mongos uses to determine which secondary replica set members to pass read operations from clients. mongos用于确定从客户端传递读取操作的辅助副本集成员的ping时间(以毫秒为单位)。The default value of 15 corresponds to the default value in all of the client drivers.默认值15对应于所有客户端驱动程序中的默认值。

When mongos receives a request that permits reads to secondary members, the mongos will:mongos收到允许secondary成员读取的请求时,mongos将:

  • Find the member of the set with the lowest ping time.查找ping时间最低的集合中的成员。
  • Construct a list of replica set members that is within a ping time of 15 milliseconds of the nearest suitable member of the set.构造副本集成员的列表,该列表位于该集最近的合适成员的ping时间(15毫秒)内。

    If you specify a value for the replication.localPingThresholdMs option, mongos will construct the list of replica members that are within the latency allowed by this value.如果为replication.localPingThresholdMs选项指定一个值,mongos将构造在该值允许的延迟内的副本成员的列表。

  • Select a member to read from at random from this list.从该列表中随机选择一个成员进行阅读。

The ping time used for a member compared by the replication.localPingThresholdMs setting is a moving average of recent ping times, calculated at most every 10 seconds. replication.localPingThresholdMs设置比较的成员使用的ping时间是最近ping时间的移动平均值,最多每10秒计算一次。As a result, some queries may reach members above the threshold until the mongos recalculates the average因此,一些查询可能会到达阈值以上的成员,直到mongos重新计算平均值.

See the Read Preference for Replica Sets section of the read preference documentation for more information.有关详细信息,请参阅读取首选项文档的副本集读取首选项部分。

sharding.configDB

Type: string

The configuration servers for the sharded cluster.分片集群配置服务器

Config servers for sharded clusters are deployed as a replica set. The replica set config servers must run the WiredTiger storage engine.分片集群的配置服务器被部署为一个副本集。复制副本集配置服务器必须运行WiredTiger存储引擎

Specify the config server replica set name and the hostname and port of at least one of the members of the config server replica set.指定配置服务器副本集名称以及配置服务器副本集中至少一个成员的主机名和端口。

sharding:
configDB: <configReplSetName>/cfg1.example.net:27019, cfg2.example.net:27019,...

The mongos instances for the sharded cluster must specify the same config server replica set name but can specify hostname and port of different members of the replica set.分片集群的mongos实例必须指定相同的配置服务器副本集名称,但可以指定副本集不同成员的主机名和端口。

Windows Service Options

processManagement:
windowsService:
serviceName: <string>
displayName: <string>
description: <string>
serviceUser: <string>
servicePassword: <string>
processManagement.windowsService.serviceName

Type: string

Default: MongoDB

The service name of mongos or mongod when running as a Windows Service. Use this name with the net start <name> and net stop <name> operations.作为Windows服务运行时mongosmongod的服务名称。将此名称用于net start <name>net stop <name>操作。

You must use processManagement.windowsService.serviceName in conjunction with either the --install or --remove option.必须将processManagement.windowsService.serviceName--install--remove选项结合使用。

processManagement.windowsService.displayName

Type: string

Default: MongoDB

The name listed for MongoDB on the Services administrative application.服务管理应用程序上为MongoDB列出的名称。

processManagement.windowsService.description

Type: string

Default: MongoDB Server

Run mongos or mongod service description.运行mongosmongod服务描述。

You must use processManagement.windowsService.description in conjunction with the --install option.必须将processManagement.windowsService.description--install选项结合使用。

For descriptions that contain spaces, you must enclose the description in quotes.对于包含空格的说明,必须将说明用引号括起来。

processManagement.windowsService.serviceUser

Type: string

The mongos or mongod service in the context of a certain user. This user must have "Log on as a service" privileges.某个用户上下文中的mongosmongod服务。此用户必须具有“作为服务登录”权限。

You must use processManagement.windowsService.serviceUser in conjunction with the --install option.必须将processManagement.windowsService.serviceUser--install选项结合使用。

processManagement.windowsService.servicePassword

Type: string

The password for <user> for mongos or mongod when running with the processManagement.windowsService.serviceUser option.当使用processManagement.windowsService.serviceUser选项运行时,mongosmongod<user>的密码。

You must use processManagement.windowsService.servicePassword in conjunction with the --install option.必须将processManagement.windowsService.servicePassword--install选项结合使用。

Removed MMAPv1 Options

Starting in version 4.2, MongoDB removes the deprecated MMAPv1 storage engine and the MMAPv1-specific configuration options:从4.2版本开始,MongoDB删除了不推荐使用的MMAPv1存储引擎和MMAPv1特定的配置选项:

Removed Configuration File Setting已删除配置文件设置Removed Command-line Option删除了命令行选项
storage.mmapv1.journal.commitIntervalMs
storage.mmapv1.journal.debugFlagsmongod --journalOptions
storage.mmapv1.nsSizemongod --nssize
storage.mmapv1.preallocDataFilesmongod --noprealloc
storage.mmapv1.quota.enforcedmongod --quota
storage.mmapv1.quota.maxFilesPerDBmongod --quotaFiles
storage.mmapv1.smallFilesmongod --smallfiles
storage.repairPathmongod --repairpath
replication.secondaryIndexPrefetchmongod --replIndexPrefetch

For earlier versions of MongoDB, refer to the corresponding version of the manual. 有关MongoDB的早期版本,请参阅相应版本的手册。For example:例如: