Configuration File Options配置文件选项
On this page本页内容
Configuration File配置文件File Format文件格式Use the Configuration File使用配置文件Core Options核心选项systemLogOptions选项processManagementOptions选项cloudOptions选项netOptions选项securityOptions选项setParameterOption选项storageOptions选项operationProfilingOptions选项replicationOptions选项shardingOptions选项auditLogOptions选项仅用于mongos-only Optionsmongos的选项Windows Service OptionsWindows服务选项Removed MMAPv1 Options删除了MMAPv1选项
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. mongod和mongos实例。The configuration file contains settings that are equivalent to the 配置文件包含与mongod and mongos command-line options. mongod和mongos命令行选项等效的设置。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. mongod和mongos选项,尤其是对于大规模部署。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如果您在Linux上使用诸如yumorapton Linux orbrewon macOS, or with the MSI installer on Windows, a default configuration file has been provided as part of your installation:yum或apt之类的软件包管理器安装MongoDB,或在macOS上使用brew,或在Windows上使用MSI安装程序安装,则会在安装过程中提供默认配置文件:Platform Method方法Configuration File配置文件Linux apt,yum, orzypperPackage Managerapt、yum或zypper软件包管理器/etc/mongod.confmacOS brewPackage Manager/usr/local/etc/mongod.conf(on Intel processors), or(在英特尔处理器上),或
/opt/homebrew/etc/mongod.conf(on Apple M1 processors)(在Apple M1处理器上)
Windows MSI Installer <install directory>\bin\mongod.cfgIf you installed MongoDB via a downloaded如果您通过下载的TGZorZIPfile, you will need to create your own configuration file.TGZ或ZIP文件安装MongoDB,则需要创建自己的配置文件。The basic example configuration is a good place to start.基本示例配置是一个很好的起点。
File Format文件格式
MongoDB configuration files use the YAMLMongoDB配置文件使用YAML format
格式[1].
The following sample configuration file contains several 以下示例配置文件包含几个mongod settings that you may adapt to your local configuration:mongod设置,您可以根据本地配置进行调整:
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 官方MongoDB包中包含的Linux包init脚本取决于systemLog.path, storage.dbPath, and processManagement.fork. If you modify these settings in the default configuration file, mongod may not start.systemLog.path、storage.dbPath和processManagement.fork的特定值。如果在默认配置文件中修改这些设置,mongod可能不会启动。
| [1] | |
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:以下扩展指令可用:
__rest | REST endpoint as the external source for configuration file options or the full configuration file.REST端点指定为配置文件选项或完整配置文件的外部源。__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进程的用户。 |
__exec | __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:mongod或mongos,请使用--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. mongod或mongos时必须包含--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详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.是MongoDB的默认日志详细级别,以包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
To use a different verbosity level for a named component, use the component's verbosity setting.若要对命名组件使用不同的详细级别,请使用该组件的详细级别设置。For example, use the例如,使用systemLog.component.accessControl.verbosityto set the verbosity level specifically forACCESScomponents.systemLog.component.accessControl.verbosity专门为ACCESS组件设置详细级别。See the请参阅systemLog.component.<name>.verbositysettings 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例如,如果详细级别为2,MongoDB将记录D2.D2。In previous versions, MongoDB log messages only specified在以前的版本中,MongoDB日志消息只为调试级别指定了Dfor Debug level.D。
systemLog.quiet-
Type: boolean
Default: false
Run在安静模式下运行mongosormongodin a quiet mode that attempts to limit the amount of output.mongos或mongod,尝试限制输出量。systemLog.quietis 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.destinationtosyslog.systemLog.destination设置为syslog。
systemLog.path-
Type: string
The path of the log file to whichmongodormongosshould send all diagnostic logging information, rather than the standard output or the host's syslog. MongoDB creates the log file at the specified path.mongod或mongos应向其发送所有诊断日志信息的日志文件的路径,而不是标准输出或主机的syslog。MongoDB在指定的路径创建日志文件。The Linux package init scripts do not expectLinux包init脚本不希望systemLog.pathto change from the defaults.systemLog.path从默认值更改。If you use the Linux packages and change如果您使用Linux软件包并更改systemLog.path, you will have to use your own init scripts and disable the built-in scripts.systemLog.path,则必须使用自己的init脚本并禁用内置脚本。
systemLog.logAppend-
Type: boolean
Default: false
When当为true,mongosormongodappends new entries to the end of the existing log file when themongosormongodinstance restarts.true时,mongos或mongod实例重新启动时,会在现有日志文件的末尾添加新条目。Without this option,如果没有此选项,mongodwill back up the existing log and create a new file.mongod将备份现有日志并创建一个新文件。
systemLog.logRotate-
Type: string
Default: rename
Determines the behavior for the确定在旋转服务器日志和/或审核日志时logRotatecommand when rotating the server log and/or the audit log.logRotate命令的行为。Specify either指定renameorreopen:rename或reopen:renamerenames the log file.重命名日志文件。reopencloses and reopens the log file following the typical Linux/Unix log rotate behavior.按照典型的Linux/Unix日志旋转行为关闭并重新打开日志文件。Use使用Linux/Unix logrotate实用程序时请使用reopenwhen using the Linux/Unix logrotate utility to avoid log loss.reopen以避免日志丢失。If you specify如果指定reopen, you must also setsystemLog.logAppendtotrue.reopen,还必须将systemLog.logAppend设置为true。
systemLog.destination-
Type: string
The destination to which MongoDB sends all log output.MongoDB将所有日志输出发送到的目的地。Specify either指定fileorsyslog.file或syslog。If you specify如果指定file, you must also specifysystemLog.path.file,则还必须指定systemLog.path。If you do not specify如果没有指定systemLog.destination, MongoDB sends all log output to standard output.systemLog.destination,MongoDB会将所有日志输出发送到标准输出。WarningThesyslogdaemon 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我们建议生产系统使用fileoption 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:日志消息中时间戳的时间格式。指定以下值之一:Value值Description描述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.000Ziso8601-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:00NoteStarting in MongoDB 4.4,从MongoDB 4.4开始,systemLog.timeStampFormatno longer supportsctime. An example ofctimeformatted date is:Wed Dec 31 18:17:54.811.systemLog.timeStampFormat不再支持ctime。ctime格式日期的示例是: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>
Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. 从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs 例如,如果详细级别为2,MongoDB将记录D2. In previous versions, MongoDB log messages only specified D for Debug level.D2。在以前的版本中,MongoDB日志消息只为调试级别指定了D。
systemLog.component.accessControl.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to access control.与访问控制相关的组件的日志消息详细级别。See请参阅ACCESScomponents.ACCESS组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.command.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to commands.与命令相关的组件的日志消息详细级别。See请参见COMMANDcomponents.COMMAND组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.control.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to control operations.与控制操作相关的组件的日志消息详细级别。See请参阅CONTROLcomponents.CONTROL组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.ftdc.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to diagnostic data collection operations. See与诊断数据集合操作相关的组件的日志消息详细级别。请参阅FTDCcomponents.FTDC组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.geo.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to geospatial parsing operations.与地理空间分析操作相关的组件的日志消息详细级别。See请参见GEOcomponents.GEO组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.index.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to indexing operations.与索引操作相关的组件的日志消息详细级别。See请参见INDEXcomponents.INDEX组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.network.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to networking operations.与网络操作相关的组件的日志消息详细级别。See请参阅NETWORKcomponents.NETWORK组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.query.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to query operations.与查询操作相关的组件的日志消息详细级别。See请参阅QUERYcomponents.QUERY组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.replication.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to replication.与复制相关的组件的日志消息详细级别。See请参见REPLcomponents.REPL组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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与选举相关的组件的日志消息详细级别。请参见ELECTIONcomponents.ELECTION组件。If如果未设置systemLog.component.replication.election.verbosityis unset,systemLog.component.replication.verbositylevel also applies to election components.systemLog.component.replication.election.verbosity,则systemLog.component.replication.verbosity级别也适用于选举组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.replication.heartbeats.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to heartbeats.与检测信号相关的组件的日志消息详细级别。See请参见REPL_HBcomponents.REPL_HB组件。If如果未设置systemLog.component.replication.heartbeats.verbosityis unset,systemLog.component.replication.verbositylevel also applies to heartbeats components.systemLog.component.replication.heartbeats.verbosity,则systemLog.component.replication.verbosity级别也适用于检测信号组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅INITSYNCcomponents.INITSYNC组件。If如果未设置systemLog.component.replication.initialSync.verbosityis unset,systemLog.component.replication.verbositylevel also applies to initialSync components.systemLog.component.replication.initialSync.verbosity,则systemLog.component.replication.verbosity级别也适用于initialSync组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.replication.rollback.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to rollback.与回滚相关的组件的日志消息详细级别。See请参见ROLLBACKcomponents.ROLLBACK组件。If如果未设置systemLog.component.replication.rollback.verbosityis unset,systemLog.component.replication.verbositylevel also applies to rollback components.systemLog.component.replication.rollback.verbosity,则systemLog.component.replication.verbosity级别也适用于回滚组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.sharding.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to sharding.与分片相关的组件的日志消息详细级别。See请参阅SHARDINGcomponents.SHARDING组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.storage.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to storage.与存储相关的组件的日志消息详细级别。See请参阅STORAGEcomponents.STORAGE组件。If如果未设置systemLog.component.storage.journal.verbosityis unset,systemLog.component.storage.verbositylevel also applies to journaling components.systemLog.component.storage.journal.verbosity,则systemLog.component.storage.verbosity级别也适用于日志组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.storage.journal.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to journaling.与日志记录相关的组件的日志消息详细级别。See请参阅JOURNALcomponents.JOURNAL组件。If如果未设置systemLog.component.storage.journal.verbosityis unset, the journaling components have the same verbosity level as the parent storage components: i.e. either thesystemLog.component.storage.verbositylevel if set or the default verbosity level.systemLog.component.storage.journal.verbosity,则日志记录组件与父存储组件具有相同的详细级别:即,如果设置了systemLog.component.storage.verbosity级别,则为默认详细级别。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅RECOVERYcomponents.RECOVERY组件。If如果未设置systemLog.component.storage.recovery.verbosityis unset,systemLog.component.storage.verbositylevel also applies to recovery components.systemLog.component.storage.recovery.verbosity,则systemLog.component.storage.verbosity级别也适用于恢复组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参见WTcomponents.WT组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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与WiredTiger存储引擎执行的备份操作相关的组件的日志消息详细级别。请参阅WTBACKUPcomponents.WTBACKUP组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参见WTCHKPTcomponents.WTCHKPT组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTCMPCTcomponents.WTCMPCT组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTEVICTcomponents.WTEVICT组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTHScomponents.WTHS组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTRECOVcomponents.WTRECOV组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTRTScomponents.WTRTS组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTSLVGcomponents.WTSLVG组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTTIERcomponents.WTTIER组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTTScomponents.WTTS组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTTXNcomponents.WTTXN组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTVRFYcomponents.WTVRFY组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅WTWRTLOGcomponents.WTWRTLOG组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
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请参阅TXNcomponents.TXN组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
systemLog.component.write.verbosity-
Type: integer
Default: 0
The log message verbosity level for components related to write operations.与写入操作相关的组件的日志消息详细级别。See请参阅WRITEcomponents.WRITE组件。The verbosity level can range from详细程度级别可以在0to5:0到5之间:0is the MongoDB's default log verbosity level, to include Informational messages.0是MongoDB的默认日志详细级别,包括信息消息。1to5increases the verbosity level to include Debug messages.1到5增加了详细级别以包括调试消息。
processManagement Options
processManagement:
fork: <boolean>
pidFilePath: <string>
timeZoneInfo: <string>
processManagement.fork-
Type: boolean
Default: false
Enable a daemon mode that runs the启用后台运行mongosormongodprocess in the background.mongos或mongod进程的守护程序模式。By default默认情况下,mongosormongoddoes not run as a daemon: typically you will runmongosormongodas a daemon, either by usingprocessManagement.forkor by using a controlling process that handles the daemonization process (e.g. as withupstartandsystemd).mongos或mongod不作为守护进程运行:通常,您将通过使用processManagement.fork或通过使用处理守护进程的控制进程(例如,与upstart和systemd一样)将mongos和mongod作为守护进程来运行。TheWindows不支持processManagement.forkoption is not supported on Windows.processManagement.fork选项。The Linux package init scripts do not expectLinux包init脚本不希望processManagement.forkto change from the defaults.processManagement.fork从默认值更改。If you use the Linux packages and change如果使用Linux软件包并更改processManagement.fork, you will have to use your own init scripts and disable the built-in scripts.processManagement.fork,则必须使用自己的init脚本并禁用内置脚本。
processManagement.pidFilePath-
Type: string
Specifies a file location to store the process ID (PID) of the指定用于存储mongosormongodprocess.mongos或mongod进程的进程ID(PID)的文件位置。The user running the运行mongodormongosprocess must be able to write to this path.mongod或mongos进程的用户必须能够写入此路径。If the如果未指定processManagement.pidFilePathoption 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.forksetting.processManagement.fork设置结合使用时有用。NoteLinux
On Linux, PID file management is generally the responsibility of your distro's init system: usually a service file in the在Linux上,PID文件管理通常由发行版的init系统负责:通常是/etc/init.ddirectory, or a systemd unit file registered withsystemctl./etc/init.d目录中的服务文件,或者是在systemctl中注册的systemd单元文件。Only use the只有当您没有使用这些init系统时,才使用processManagement.pidFilePathoption if you are not using one of these init systems.processManagement.pidFilePath选项。For more information, please see the respective Installation Guide for your operating system.有关详细信息,请参阅相应操作系统的安装指南。NotemacOS
On macOS, PID file management is generally handled by在macOS上,PID文件管理通常由brew.brew处理。Only use the如果您的macOS系统上没有使用brew,请仅使用processManagement.pidFilePathoption if you are not usingbrewon your macOS system.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 toLinux和macOS软件包附带的配置文件默认情况下会将时区数据库路径设置为/usr/share/zoneinfoby default./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下载网站.
上提供了时区数据库的最新版本。
WarningMongoDB uses the third party timelibMongoDB使用第三方timeliblibrary to provide accurate conversions between timezones. Due to a recent update,
timelibcould create inaccurate time zone conversions in older versions of MongoDB.库来提供时区之间的准确转换。由于最近的更新,
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并使用timeZoneInfoparameter.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.stateaccepts the following values:接受以下值:runtimeDefault.违约You can enable or disable free monitoring during runtime.您可以在运行时启用或禁用免费监控。
To enable or disable free monitoring during runtime, see要在运行时启用或禁用自由监视,请参阅db.enableFreeMonitoring()anddb.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()anddb.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 MongoDB 4.2摒弃ssl options in favor of tls options with identical functionality.ssl选项,转而支持具有相同功能的tls选项。
Changed in version 5.0:5.0版更改:MongoDB removes the MongoDB删除了net.serviceExecutor configuration option and the corresponding --serviceExecutor command-line option.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:
27017 formongod(if not a shard member or a config server member) ormongosinstancemongod(如果不是分片成员或配置服务器成员)或mongos实例为2701727018 if如果mongodis ashard membermongod是分片成员则为2701827019 if如果mongodis aconfig server membermongod是配置服务器成员则为27019
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 whichmongosormongodshould listen for client connections.mongos或mongod应在其上侦听客户端连接的主机名和/或IP地址和/或完整Unix域套接字路径。You may attach您可以将mongosormongodto any interface.mongos或mongod附加到任何接口。To bind to multiple addresses, enter a list of comma-separated values.要绑定到多个地址,请输入逗号分隔的值列表。Examplelocalhost,/tmp/mongod.sockYou can specify both IPv4 and IPv6 addresses, or hostnames that resolve to an IPv4 or IPv6 address.可以指定IPv4和IPv6地址,也可以指定解析为IPv4或IPv6地址的主机名。Examplelocalhost, 2001:0DB8:e132:ba26:0d5c:2774:e7f9:d513NoteIf specifying an IPv6 address or a hostname that resolves to an IPv6 address to如果指定IPv6地址或解析为net.bindIp, you must startmongosormongodwithnet.ipv6 : trueto enable IPv6 support.net.bindIp的IPv6地址的主机名,则必须使用net.ipv6 : true启动mongos或mongod才能启用IPv6支持。Specifying an IPv6 address to为net.bindIpdoes not enable IPv6 support.net.bindIp指定IPv6地址不会启用IPv6支持。If specifying a link-local IPv6 address如果指定链接本地IPv6地址(
fe80::/10), you must append the zone indexto that address (i.e.
fe80::<address>%<adapter-name>).(
fe80::/10),则必须将区域索引附加到该地址(即
fe80::<address>%<adapter-name>)。Examplelocalhost,fe80::a00:27ff:fee0:1fcf%enp0s3ImportantTo 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地址的节点将无法通过启动验证,也不会启动。WarningBefore 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要绑定到所有IPv4地址,请输入0.0.0.0.0.0.0.0。To bind to all IPv4 and IPv6 addresses, enter要绑定到所有IPv4和IPv6地址,请输入::,0.0.0.0or starting in MongoDB 4.2, an asterisk"*"(enclose the asterisk in quotes to distinguish from YAML alias nodes).
::,0.0.0.0,或者从MongoDB 4.2开始,输入星号"*"(用引号括起星号以区别于YAML别名节点)。
Alternatively, use the或者,使用net.bindIpAllsetting.net.bindIpAll设置。Notenet.bindIpandnet.bindIpAllare mutually exclusive. That is, you can specify one or the other, but not both.net.bindIp和net.bindIpAll是互斥的。也就是说,您可以指定一个或另一个,但不能同时指定两者。The command-line option命令行选项--bind_ipoverrides the configuration file settingnet.bindIp.--bind_ip覆盖配置文件设置net.bindIp。
To configure cluster nodes for split horizon DNS要为拆分范围DNS, use host names instead of IP addresses.
配置群集节点,请使用主机名而不是IP地址。
Starting in MongoDB v5.0,从MongoDB v5.0开始,replSetInitiateandreplSetReconfigreject configurations that use IP addresses instead of hostnames.replSetInitiate和replSetReconfig拒绝使用IP地址而不是主机名的配置。Use使用disableSplitHorizonIPCheckto modify nodes that cannot be updated to use host names.disableSplitHorizonIPCheck可以修改无法更新为使用主机名的节点。The parameter only applies to the configuration commands.该参数仅适用于配置命令。mongodandmongosdo not rely ondisableSplitHorizonIPCheckfor validation at startup. Legacymongodandmongosinstances that use IP addresses instead of host names will start after an upgrade.mongod和mongos在启动时不依赖disableSplitHorizonIPCheck进行验证。使用IP地址而不是主机名的旧mongod和mongos实例将在升级后启动。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如果为mongosormongodinstance binds to all IPv4 addresses (i.e.0.0.0.0).true,mongos或mongod实例将绑定到所有IPv4地址(即0.0.0.0)。If如果mongosormongodstarts withnet.ipv6 : true,net.bindIpAllalso binds to all IPv6 addresses (i.e.::).mongos或mongod以net.ipv6 : true开头,那么net.bindIpAll也会绑定到所有IPv6地址(即::)。mongosormongodonly supports IPv6 if started withnet.ipv6 : true.mongos或mongod仅支持以net.ipv6 : true启动的IPv6。Specifying单独指定net.bindIpAllalone does not enable IPv6 support.net.bindIpAll并不能启用IPv6支持。WarningBefore 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或者,从MongoDB 4.2开始,将net.bindIpto::,0.0.0.0or, 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.
net.bindIp设置为::,0.0.0.0,或者设置为星号"*"(用引号括起星号以区别于YAML别名节点),以绑定到所有IP地址。
Notenet.bindIpandnet.bindIpAllare mutually exclusive. Specifying both options causesmongosormongodto throw an error and terminate.net.bindIp和net.bindIpAll是互斥的。指定这两个选项会导致mongos或mongod抛出错误并终止。
net.maxIncomingConnections-
Type: integer
Default: 65536
The maximum number of simultaneous connections thatmongosormongodwill accept.mongos或mongod将接受的最大同时连接数。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如果您有一个创建多个连接并允许它们超时而不是关闭的客户端,那么这对mongosif you have a client that creates multiple connections and allows them to timeout rather than closing them.mongos来说尤其有用。In this case, set在这种情况下,请将maxIncomingConnectionsto 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此设置可防止mongosfrom 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, themongodormongosinstance validates all requests from clients upon receipt to prevent clients from inserting malformed or invalid BSON into a MongoDB database.true时,mongod或mongos实例在收到来自客户端的所有请求时进行验证,以防止客户端将格式错误或无效的BSON插入MongoDB数据库。For objects with a high degree of sub-document nesting,对于具有高度子文档嵌套的对象,net.wireObjectCheckcan have a small impact on performance.net.wireObjectCheck可能会对性能产生较小影响。
net.ipv6-
Type: boolean
Default: false
Set将net.ipv6totrueto enable IPv6 support.mongos/mongoddisables IPv6 support by default.net.ipv6设置为true以启用IPv6支持。mongos/mongod默认禁用IPv6支持。Setting设置net.ipv6does not direct themongos/mongodto listen on any local IPv6 addresses or interfaces.net.ipv6不会指示mongos/mongod侦听任何本地IPv6地址或接口。To configure the要将mongos/mongodto listen on an IPv6 interface, you must either:mongos/mongod配置为在IPv6接口上侦听,您必须:Configure使用一个或多个IPv6地址或解析为IPv6地址的主机名配置net.bindIpwith one or more IPv6 addresses or hostnames that resolve to IPv6 addresses, ornet.bindIp,或者Set将net.bindIpAlltotrue.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.enabledapplies only to Unix-based systems.仅适用于基于Unix的系统。When当net.unixDomainSocket.enabledistrue,mongosormongodlistens on the UNIX socket.net.unixDomainSocket.enabled为true时,mongos或mongod侦听UNIX套接字。Themongosormongodprocess always listens on the UNIX socket unless one of the following is true:mongos或mongod进程始终侦听UNIX套接字,除非以下情况之一为真:net.unixDomainSocket.enabledis为false--nounixsocketis set.已设置。The command line option takes precedence over the configuration file setting.命令行选项优先于配置文件设置。net.bindIpis not set未设置net.bindIpdoes not specify未指定localhostor its associated IP addresslocalhost或其关联的IP地址
默认情况下,从官方.deb和.rpm包安装的mongosormongodinstalled from official .deb and .rpm packages have thebind_ipconfiguration set to127.0.0.1by default.mongos或mongod的bind_ip配置设置为127.0.0.1。
net.unixDomainSocket.pathPrefix-
Type: string
Default: /tmp
The path for the UNIX socket.UNIX套接字的路径。net.unixDomainSocket.pathPrefixapplies only to Unix-based systems.仅适用于基于Unix的系统。If this option has no value, the如果该选项没有值,mongosormongodprocess creates a socket with/tmpas a prefix.mongos或mongod进程将创建一个以/tmp为前缀的套接字。MongoDB creates and listens on a UNIX socket unless one of the following is true:MongoDB在UNIX套接字上创建和侦听,除非以下情况之一为真:net.unixDomainSocket.enabledis为false--nounixsocketis set已设置net.bindIpis not set未设置net.bindIpdoes not specify未指定localhostor its associated IP addresslocalhost或其关联的IP地址
net.unixDomainSocket.filePermissions-
Type: int
Default:
0700Sets the permission for the UNIX domain socket file.设置UNIX域套接字文件的权限。net.unixDomainSocket.filePermissionsapplies only to Unix-based systems.仅适用于基于Unix的系统。
net.http Options
Changed in version 3.6:3.6版更改:MongoDB 3.6 removes the deprecated MongoDB 3.6删除了不推荐使用的net.http options. 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 thenet.tls.modesetting can be one of the following:net.tls.mode设置的参数可以是以下参数之一:Value值Description描述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如果未指定--tlsCAFileortls.CAFileis 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.--tlsCAFile或tls.CAFile,并且您未使用x.509身份验证,则在连接到启用TLS的服务器时将使用系统范围的CA证书存储。If using x.509 authentication,如果使用x.509身份验证,则必须指定--tlsCAFileortls.CAFilemust be specified unless using--tlsCertificateSelector.--tlsCAFile或tls.CAFile,除非使用--tlsCertificateSelector。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.certificateKeyFile-
Type: string
New in version 4.2:4.2版新增:The同时包含TLS证书和键的.pemfile that contains both the TLS certificate and key..pem文件。Starting with MongoDB 4.0 on macOS or Windows, you can use the从macOS或Windows上的MongoDB 4.0开始,您可以使用net.tls.certificateSelectorsetting to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.tls.certificateSelector设置从操作系统的安全证书存储中指定证书,而不是PEM键文件。certificateKeyFileand和net.tls.certificateSelectorare mutually exclusive.相互排斥。You can only specify one.您只能指定一个。On Linux/BSD, you must specify在Linux/BSD上,启用TLS时,必须指定net.tls.certificateKeyFilewhen TLS is enabled.net.tls.certificateKeyFile。On Windows or macOS, you must specify either在Windows或macOS上,启用TLS时,必须指定net.tls.certificateKeyFileornet.tls.certificateSelectorwhen TLS is enabled.net.tls.certificateKeyFile或net.tls.certificateSelector。ImportantFor Windows only, MongoDB 4.0 and later do not support encrypted PEM files. The仅适用于Windows,MongoDB 4.0及更高版本不支持加密的PEM文件。如果mongodfails to start if it encounters an encrypted PEM file.mongod遇到加密的PEM文件,它将无法启动。To securely store and access a certificate for use with TLS on Windows, use若要在Windows上安全地存储和访问用于TLS的证书,请使用net.tls.certificateSelector.net.tls.certificateSelector。
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的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.certificateKeyFilePasswordoption only if the certificate-key file is encrypted.net.tls.certificateKeyFilePassword选项。In all cases, the在所有情况下,mongosormongodwill redact the password from all logging and reporting output.mongos或mongod都会对所有日志记录和报告输出的密码进行编辑。Starting in MongoDB 4.0:从MongoDB 4.0开始:On Linux/BSD, if the private key in the PEM file is encrypted and you do not specify the在Linux/BSD上,如果PEM文件中的私钥是加密的,并且您没有指定net.tls.certificateKeyFilePasswordoption, MongoDB will prompt for a passphrase.net.tls.certificateKeyFilePassword选项,MongoDB将提示输入密码短语。See TLS/SSL Certificate Passphrase.请参阅TLS/SSL证书密码。On macOS, if the private key in the PEM file is encrypted, you must explicitly specify the在macOS上,如果PEM文件中的私钥已加密,则必须显式指定net.tls.certificateKeyFilePasswordoption.net.tls.certificateKeyFilePassword选项。Alternatively, you can use a certificate from the secure system store (see或者,您可以使用安全系统存储中的证书(请参阅net.tls.certificateSelector) instead of a PEM key file or use an unencrypted PEM file.net.tls.certificateSelector)而不是PEM键文件,或者使用未加密的PEM文件。On Windows, MongoDB does not support encrypted certificates.在Windows上,MongoDB不支持加密证书。The如果mongodfails if it encounters an encrypted PEM file.mongod遇到加密的PEM文件,它就会失败。Use:请改用net.tls.certificateSelectorinstead.net.tls.certificateSelector。
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.certificateSelector-
Type: string
New in version 4.2:4.2版新增:Available on Windows and macOS as an alternative to可在Windows和macOS上作为net.tls.certificateKeyFile.net.tls.certificateKeyFile的替代方案使用。In MongoDB 4.0, see在MongoDB 4.0中,请参阅net.ssl.certificateSelector.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.certificateKeyFileandnet.tls.certificateSelectoroptions are mutually exclusive. You can only specify one.net.tls.certificateKeyFile和net.tls.certificateSelector选项是互斥的。您只能指定一个。net.tls.certificateSelectoraccepts an argument of the format接受格式为<property>=<value>where the property can be one of the following:<property>=<value>的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subjectASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprinthex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprintis sometimes referred to as afingerprint.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(联机证书状态协议)用于验证证书的吊销状态。Themongodsearches 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.CAFileornet.tls.clusterFileto specify the root and intermediate CA certificatenet.tls.CAFile或net.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证书。NoteYou cannot use the当使用设置为指纹的rotateCertificatescommand or thedb.rotateCertificates()shell method when usingnet.tls.certificateSelectoror--tlsCertificateSelectorset tothumbprintnet.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可在Windows和macOS上作为net.tls.clusterFile.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.clusterFileandnet.tls.clusterCertificateSelectoroptions are mutually exclusive. You can only specify one.net.tls.clusterFile和net.tls.clusterCertificateSelector选项相互排斥。您只能指定一个。net.tls.clusterCertificateSelectoraccepts an argument of the format接受格式为<property>=<value>where the property can be one of the following:<property>=<value>的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subjectASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprinthex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprintis sometimes referred to as afingerprint.thumbprint有时被称为fingerprint。Themongodsearches 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.CAFileornet.tls.clusterCAFileto specify the root and intermediate CA certificate.net.tls.CAFile或net.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/mongoslogs a warning on connection if the presented x.509 certificate expires within如果提供的x.509证书在30days of themongod/mongoshost system time.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.pemfile 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从macOS或Windows上的MongoDB 4.0开始,您可以使用net.tls.clusterCertificateSelectoroption to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.tls.clusterCertificateSelector选项从操作系统的安全证书存储中指定证书,而不是PEM键文件。net.tls.clusterFileandnet.tls.clusterCertificateSelectoroptions are mutually exclusive.net.tls.clusterFile和net.tls.clusterCertificateSelector选项相互排斥。You can only specify one.您只能指定一个。If如果net.tls.clusterFiledoes not specify the.pemfile for internal cluster authentication or the alternativenet.tls.clusterCertificateSelector, the cluster uses the.pemfile specified in thecertificateKeyFilesetting or the certificate returned by thenet.tls.certificateSelector.net.tls.clusterFile未指定用于内部群集身份验证的.pem文件或替代net.tls.clusterCertificateSelector,则群集将使用certificateKeyFile设置中指定的.pem文件或net.tls.certificateSelector返回的证书。If using x.509 authentication,如果使用x.509身份验证,则必须指定--tlsCAFileortls.CAFilemust be specified unless using--tlsCertificateSelector.--tlsCAFile或tls.CAFile,除非使用--tlsCertificateSelector。Changed in version 4.4:4.4版更改:mongod/mongoslogs a warning on connection if the presented x.509 certificate expires within如果提供的x.509证书在30days of themongod/mongoshost system time.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有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。ImportantFor Windows only, MongoDB 4.0 and later do not support encrypted PEM files.仅适用于Windows,MongoDB 4.0及更高版本不支持加密的PEM文件。The如果mongodfails 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要在Windows上安全存储和访问用于成员身份验证的证书,请使用net.tls.clusterCertificateSelector.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.clusterPasswordoption only if the certificate-key file is encrypted.net.tls.clusterPassword选项。In all cases, the在所有情况下,mongosormongodwill redact the password from all logging and reporting output.mongos或mongod都会对所有日志记录和报告输出的密码进行编辑。Starting in MongoDB 4.0:从MongoDB 4.0开始:On Linux/BSD, if the private key in the x.509 file is encrypted and you do not specify the在Linux/BSD上,如果x.509文件中的私钥是加密的,并且您没有指定net.tls.clusterPasswordoption, MongoDB will prompt for a passphrase.net.tls.clusterPassword选项,MongoDB将提示输入密码短语。See TLS/SSL Certificate Passphrase.请参阅TLS/SSL证书密码短语。On macOS, if the private key in the x.509 file is encrypted, you must explicitly specify the在macOS上,如果x.509文件中的私钥已加密,则必须显式指定net.tls.clusterPasswordoption.net.tls.clusterPassword选项。Alternatively, you can either use a certificate from the secure system store (see或者,您可以使用安全系统存储中的证书(请参阅net.tls.clusterCertificateSelector) instead of a cluster PEM file or use an unencrypted PEM file.net.tls.clusterCertificateSelector)代替集群PEM文件,也可以使用未加密的PEM文件。On Windows, MongoDB does not support encrypted certificates.在Windows上,MongoDB不支持加密证书。The如果mongodfails if it encounters an encrypted PEM file.mongod遇到加密的PEM文件,它就会失败。Use请使用net.tls.clusterCertificateSelector.net.tls.clusterCertificateSelector。
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.clusterAuthX509New 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设置attributesis 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当设置extensionValueis 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包含证书颁发机构的根证书链的.pemfile that contains the root certificate chain from the Certificate Authority..pem文件。Specify the file name of the使用相对路径或绝对路径指定.pemfile using relative or absolute paths..pem文件的文件名。- Windows/macOS Only
If using如果使用net.tls.certificateSelectorand/ornet.tls.clusterCertificateSelector, do not usenet.tls.CAFileto 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.certificateSelectorand/ornet.tls.clusterCertificateSelectorcertificates in the secure certificate store.net.tls.certificateSelector和/或net.tls.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.clusterCAFile-
Type: string
New in version 4.2:4.2版新增:The.pemfile 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文件的文件名。.pemfile using relative or absolute paths.net.tls.clusterCAFilerequires that要求设置net.tls.CAFileis set.net.tls.CAFile。If如果net.tls.clusterCAFiledoes not specify the.pemfile for validating the certificate from a client establishing a connection, the cluster uses the.pemfile specified in thenet.tls.CAFileoption.net.tls.clusterCAFile没有指定.pem文件来验证来自建立连接的客户端的证书,则集群将使用net.tls.CAFile选项中指定的.pem文件。net.tls.clusterCAFilelets 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.clusterCertificateSelector。When 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.certificateSelectorand/ornet.tls.clusterCertificateSelector, do not usenet.tls.clusterCAFileto 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.certificateSelectorand/ornet.tls.clusterCertificateSelectorcertificates in the secure certificate store.net.tls.certificateSelector和/或net.tls.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.CRLFile-
Type: string
New in version 4.2:4.2版新增:In MongoDB 4.0 and earlier, see在MongoDB 4.0及更早版本中,请参阅net.ssl.CRLFile.net.ssl.CRLFile。The包含证书吊销列表的.pemfile that contains the Certificate Revocation List. Specify the file name of the.pemfile using relative or absolute paths..pem文件。使用相对路径或绝对路径指定.pem文件的文件名。NoteStarting in MongoDB 4.0, you cannot specify从MongoDB 4.0开始,您不能在macOS上指定net.tls.CRLFileon macOS.net.tls.CRLFile。Instead, 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请参阅MongoDB 4.0中的net.ssl.certificateSelectorin MongoDB 4.0 andnet.tls.certificateSelectorin MongoDB 4.2+ to use the system SSL certificate store.net.ssl.certificateSelector和MongoDB 4.2+中的net.tls.certificateSelector以使用系统SSL证书存储。Starting in version 4.4, to check for certificate revocation, MongoDB从版本4.4开始,为了检查证书吊销,MongoDB默认启用OCSP(在线证书状态协议),作为指定CRL文件或使用系统SSL证书存储的替代方案。enablesthe use of OCSP (Online Certificate Status Protocol) by default as an alternative to specifying a CRL file or using the system SSL certificate store.
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.allowConnectionsWithoutCertificates-
Type: boolean
New in version 4.2.4.2版新增。For clients that don't provide certificates,对于不提供证书的客户端,假设连接成功,mongodormongosencrypts the TLS/SSL connection, assuming the connection is successfully made.mongod或mongos会对TLS/SSL连接进行加密。For clients that present a certificate, however,然而,对于提供证书的客户端,mongosormongodperforms certificate validation using the root certificate chain specified byCAFileand reject clients with invalid certificates.mongos或mongod使用CAFile指定的根证书链执行证书验证,并拒绝具有无效证书的客户端。Use the如果您的混合部署包括不向net.tls.allowConnectionsWithoutCertificatesoption if you have a mixed deployment that includes clients that do not or cannot present certificates to themongosormongod.mongos或mongod提供证书或不能向其提供证书的客户端,请使用net.tls.allowConnectionsWithoutCertificates选项。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的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证书的验证检查,并允许使用无效证书进行连接。NoteIf you specify如果在使用x.509身份验证时指定--tlsAllowInvalidCertificatesortls.allowInvalidCertificates: truewhen using x.509 authentication, an invalid certificate is only sufficient to establish a TLS connection but is insufficient for authentication.--tlsAllowInvalidCertificates或tls.allowInvalidCertificates: true,则无效证书仅足以建立TLS连接,但不足以进行身份验证。When using the当使用net.tls.allowInvalidCertificatessetting, MongoDB logs a warning regarding the use of the invalid certificate.net.tls.allowInvalidCertificates设置时,MongoDB会记录有关使用无效证书的警告。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的TLS/SSL配置。
net.tls.allowInvalidHostnames-
Type: boolean
Default: false
When当net.tls.allowInvalidHostnamesistrue, MongoDB disables the validation of the hostnames in TLS certificates, allowingmongodto connect to MongoDB instances if the hostname their certificates do not match the specified hostname.net.tls.allowInvalidHostnames为true时,MongoDB将禁用TLS证书中主机名的验证,如果主机名及其证书与指定的主机名不匹配,则允许mongod连接到MongoDB实例。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的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.disabledProtocolsrecognizes the following protocols:识别以下协议:TLS1_0,TLS1_1,TLS1_2, andTLS1_3.TLS1_0、TLS1_1、TLS1_2和TLS1_3。On macOS, you cannot disable在macOS上,不能禁用TLS1_1and leave bothTLS1_0andTLS1_2enabled.TLS1_1并同时启用TLS1_0和TLS1_2。You 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若要启用TLS 1.0,请将nonetonet.tls.disabledProtocols.none指定为net.tls.disabledProtocols。See Disable TLS 1.0.请参阅禁用TLS 1.0。Members of replica sets and sharded clusters must speak at least one protocol in common.副本集和分片集群的成员必须至少使用一个通用协议。TipSee also:另请参阅:
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为mongosormongod.mongos或mongod启用或禁用TLS库的FIPS模式。Your system must have a FIPS compliant library to use the您的系统必须具有符合FIPS的库才能使用net.tls.FIPSModeoption.net.tls.FIPSMode选项。NoteFIPS-compatible TLS/SSL is available only in MongoDB EnterpriseFIPS兼容的TLS/SSL仅在MongoDB企业版.
中可用。
See Configure MongoDB for FIPS for more information.有关更多信息,请参阅配置MongoDB for FIPS。
net.tls.logVersions-
Type: string
Instructs指示mongosormongodto log a message when a client connects using a specified TLS version.mongos或mongod在客户端使用指定的TLS版本进行连接时记录消息。Specify either a single TLS version or a comma-separated list of multiple TLS versions.指定单个TLS版本或多个TLS版本的逗号分隔列表。ExampleTo instruct若要指示mongosormongodto log a message when a client connects using either TLS 1.2 or TLS 1.3, setnet.tls.logVersionsto"TLS1_2,TLS1_3".mongos或mongod在客户端使用TLS 1.2或TLS 1.3连接时记录消息,请将net.tls.logVersions设置为"TLS1_2,TLS1_3"。
net.ssl Options
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: requireTLSinstead.net.tls.mode: requireTLS。Enable or disable TLS/SSL for为mongosormongod.mongos或mongod启用或禁用TLS/SSL。With使用net.ssl.sslOnNormalPorts, amongosormongodrequires TLS/SSL encryption for all connections on the default MongoDB port, or the port specified bynet.port.net.ssl.sslOnNormalPorts,mongos或mongod需要对默认MongoDB端口或net.port指定的端口上的所有连接进行TLS/SSL加密。By default,默认情况下,net.ssl.sslOnNormalPortsis disabled.net.ssl.sslOnNormalPorts处于禁用状态。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.mode-
Type: string
Deprecated since version 4.2
: Use:请改用net.tls.modeinstead.net.tls.mode。Enables TLS/SSL or mixed TLS/SSL used for all network connections.启用用于所有网络连接的TLS/SSL或混合TLS/SSL。The argument to thenet.ssl.modesetting can be one of the following:net.ssl.mode设置的参数可以是以下参数之一:Value值Description描述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,若要使用x.509身份验证,必须指定--tlsCAFileornet.tls.CAFilemust be specified unless you are using--tlsCertificateSelectoror--net.tls.certificateSelector.--tlsCAFile或net.tls.CAFile,除非您使用的是--tlsCertificateSelector或--net.tls.certificateSelector。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.PEMKeyFile-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.certificateKeyFileinstead.net.tls.certificateKeyFile。The包含TLS/SSL证书和键的.pemfile that contains both the TLS/SSL certificate and key..pem文件。Starting with MongoDB 4.0 on macOS or Windows, you can use the从macOS或Windows上的MongoDB 4.0开始,您可以使用net.ssl.certificateSelectorsetting to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.ssl.certificateSelector设置从操作系统的安全证书存储中指定证书,而不是PEM键文件。PEMKeyFileand和net.ssl.certificateSelectorare mutually exclusive.相互排斥。You can only specify one.您只能指定一个。On Linux/BSD, you must specify在Linux/BSD上,启用TLS/SSL时,必须指定net.ssl.PEMKeyFilewhen TLS/SSL is enabled.net.ssl.PEMKeyFile。On Windows or macOS, you must specify either在Windows或macOS上,启用TLS/SSL时,必须指定net.ssl.PEMKeyFileornet.ssl.certificateSelectorwhen TLS/SSL is enabled.net.ssl.PEMKeyFile或net.ssl.certificateSelector。ImportantFor Windows only, MongoDB 4.0 and later do not support encrypted PEM files. The仅适用于Windows,MongoDB 4.0及更高版本不支持加密的PEM文件。如果mongodfails to start if it encounters an encrypted PEM file.mongod遇到加密的PEM文件,它将无法启动。To securely store and access a certificate for use with TLS/SSL on Windows, use要在Windows上安全地存储和访问与TLS/SSL一起使用的证书,请使用net.ssl.certificateSelector.net.ssl.certificateSelector。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.PEMKeyPassword-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.certificateKeyFilePasswordinstead.net.tls.certificateKeyFilePassword。The password to de-crypt the certificate-key file (i.e.对证书键文件(即PEMKeyFile).PEMKeyFile)进行解密的密码。Use the仅当证书键文件已加密时,才使用net.ssl.PEMKeyPasswordoption only if the certificate-key file is encrypted.net.ssl.PEMKeyPassword选项。In all cases, the在所有情况下,mongosormongodwill redact the password from all logging and reporting output.mongos或mongod都会对所有日志记录和报告输出的密码进行编辑。Starting in MongoDB 4.0:从MongoDB 4.0开始:On Linux/BSD, if the private key in the PEM file is encrypted and you do not specify the在Linux/BSD上,如果PEM文件中的私钥是加密的,并且您没有指定net.ssl.PEMKeyPasswordoption, MongoDB will prompt for a passphrase.net.ssl.PEMKeyPassword选项,MongoDB将提示输入密码短语。See TLS/SSL Certificate Passphrase.请参阅TLS/SSL证书密码短语。On macOS, if the private key in the PEM file is encrypted, you must explicitly specify the在macOS上,如果PEM文件中的私钥已加密,则必须显式指定net.ssl.PEMKeyPasswordoption.net.ssl.PEMKeyPassword选项。Alternatively, you can use a certificate from the secure system store (see或者,您可以使用安全系统存储中的证书(请参阅net.ssl.certificateSelector) instead of a PEM key file or use an unencrypted PEM file.net.ssl.certificateSelector)而不是PEM键文件,或者使用未加密的PEM文件。On Windows, MongoDB does not support encrypted certificates.在Windows上,MongoDB不支持加密证书。The如果mongodfails if it encounters an encrypted PEM file. Usenet.ssl.certificateSelectorinstead.mongod遇到加密的PEM文件,它就会失败。请改用net.ssl.certificateSelector。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.certificateSelector-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.certificateSelectorinstead.net.tls.certificateSelector。New in version 4.0:4.0版新增:Available on Windows and macOS as an alternative to可在Windows和macOS上作为net.ssl.PEMKeyFile.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.PEMKeyFileand和net.ssl.certificateSelectoroptions are mutually exclusive. You can only specify one.选项是相互排斥的。您只能指定一个。net.ssl.certificateSelectoraccepts an argument of the format接受格式为<property>=<value>where the property can be one of the following:<property>=<value>的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subjectASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprinthex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprintis sometimes referred to as afingerprint.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(联机证书状态协议)用于验证证书的吊销状态。Themongodsearches 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.CAFileornet.ssl.clusterFileto specify the root and intermediate CA certificatenet.ssl.CAFile或net.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.clusterCertificateSelectorinstead.net.tls.clusterCertificateSelector。New in version 4.0:4.0版新增:Available on Windows and macOS as an alternative to可在Windows和macOS上作为net.ssl.clusterFile.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.clusterFileand和net.ssl.clusterCertificateSelectoroptions are mutually exclusive.选项是相互排斥的。You can only specify one.您只能指定一个。net.ssl.clusterCertificateSelectoraccepts an argument of the format接受格式为<property>=<value>where the property can be one of the following:<property>=<value>的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subjectASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprinthex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprintis sometimes referred to as afingerprint.thumbprint有时被称为fingerprint。Themongodsearches 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.CAFileornet.ssl.clusterFileto specify the root and intermediate CA certificate.net.ssl.CAFile或net.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.clusterFileinstead.net.tls.clusterFile。The.pemfile 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从macOS或Windows上的MongoDB 4.0开始,您可以使用net.ssl.clusterCertificateSelectoroption to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.ssl.clusterCertificateSelector选项从操作系统的安全证书存储中指定证书,而不是PEM键文件。net.ssl.clusterFileand和net.ssl.clusterCertificateSelectoroptions are mutually exclusive.选项是相互排斥的。You can only specify one.您只能指定一个。If如果net.ssl.clusterFiledoes not specify the.pemfile for internal cluster authentication or the alternativenet.ssl.clusterCertificateSelector, the cluster uses the.pemfile specified in thePEMKeyFilesetting or the certificate returned by thenet.ssl.certificateSelector.net.ssl.clusterFile未指定用于内部群集身份验证的.pem文件或备用net.ssl.clusterCertificateSelector,则群集将使用在PEMKeyFile设置中指定的pem文件或net.ssl.certificateSelector返回的证书。To use x.509 authentication,若要使用x.509身份验证,必须指定--tlsCAFileornet.tls.CAFilemust be specified unless you are using--tlsCertificateSelectoror--net.tls.certificateSelector.--tlsCAFile或net.tls.CAFile,除非您使用的是--tlsCertificateSelector或--net.tls.certificateSelector。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。ImportantFor Windows only, MongoDB 4.0 and later do not support encrypted PEM files.仅适用于Windows,MongoDB 4.0及更高版本不支持加密的PEM文件。The如果mongodfails 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要在Windows上安全存储和访问用于成员身份验证的证书,请使用net.ssl.clusterCertificateSelector.net.ssl.clusterCertificateSelector。
net.ssl.clusterPassword-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.clusterPasswordinstead.net.tls.clusterPassword。The password to de-crypt the x.509 certificate-key file specified with对用--sslClusterFile.--sslClusterFile指定的x.509证书键文件进行解密的密码。Use the仅当证书键文件已加密时,才使用net.ssl.clusterPasswordoption only if the certificate-key file is encrypted.net.ssl.clusterPassword选项。In all cases, the在所有情况下,mongosormongodwill redact the password from all logging and reporting output.mongos或mongod都会对所有日志记录和报告输出的密码进行编辑。Starting in MongoDB 4.0:从MongoDB 4.0开始:On Linux/BSD, if the private key in the x.509 file is encrypted and you do not specify the在Linux/BSD上,如果x.509文件中的私钥是加密的,并且您没有指定net.ssl.clusterPasswordoption, MongoDB will prompt for a passphrase.net.ssl.clusterPassword选项,MongoDB将提示输入密码短语。See TLS/SSL Certificate Passphrase.请参阅TLS/SSL证书密码短语。On macOS, if the private key in the x.509 file is encrypted, you must explicitly specify the在macOS上,如果x.509文件中的私钥已加密,则必须明确指定net.ssl.clusterPasswordoption.net.ssl.clusterPassword选项。Alternatively, you can either use a certificate from the secure system store (see或者,您可以使用安全系统存储中的证书(请参阅net.ssl.clusterCertificateSelector) instead of a cluster PEM file or use an unencrypted PEM file.net.ssl.clusterCertificateSelector)而不是集群PEM文件,也可以使用未加密的PEM文件。On Windows, MongoDB does not support encrypted certificates.在Windows上,MongoDB不支持加密证书。The如果mongodfails if it encounters an encrypted PEM file.mongod遇到加密的PEM文件,它就会失败。Use请使用net.ssl.clusterCertificateSelector.net.ssl.clusterCertificateSelector。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.CAFile-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.CAFileinstead.net.tls.CAFile。The.pemfile that contains the root certificate chain from the Certificate Authority..pem文件,包含来自证书颁发机构的根证书链。Specify the file name of the使用相对路径或绝对路径指定.pemfile using relative or absolute paths..pem文件的文件名。- Windows/macOS Only
If using如果使用net.ssl.certificateSelectorand/ornet.ssl.clusterCertificateSelector, do not usenet.ssl.CAFileto 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.certificateSelectorand/ornet.ssl.clusterCertificateSelectorcertificates in the secure certificate store.net.ssl.certificateSelector和/或net.ssl.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.clusterCAFile-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.clusterCAFileinstead.net.tls.clusterCAFile。The.pemfile 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使用相对路径或绝对路径指定.pemfile using relative or absolute paths..pem文件的文件名。net.ssl.clusterCAFilerequires thatnet.ssl.CAFileis set.If如果net.ssl.clusterCAFiledoes not specify the.pemfile for validating the certificate from a client establishing a connection, the cluster uses the.pemfile specified in thenet.ssl.CAFileoption.net.ssl.clusterCAFile没有指定用于验证来自建立连接的客户端的证书的.pem文件,则集群将使用net.ssl.CAFile选项中指定的.pem。net.ssl.clusterCAFilelets 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.clusterCertificateSelector。When 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.certificateSelectorand/ornet.ssl.clusterCertificateSelector, do not usenet.ssl.clusterCAFileto 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.certificateSelectorand/ornet.ssl.clusterCertificateSelectorcertificates in the secure certificate store.net.ssl.certificateSelector和/或net.ssl.clusterCertificateSelector证书的完整信任链所需的所有CA证书存储在安全证书存储中。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.CRLFile-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.CRLFileinstead.net.tls.CRLFile。The包含证书吊销列表的.pemfile that contains the Certificate Revocation List. Specify the file name of the.pemfile using relative or absolute paths..pem文件。使用相对路径或绝对路径指定.pem文件的文件名。NoteStarting in MongoDB 4.0, you cannot specify从MongoDB 4.0开始,您不能在macOS上指定net.ssl.CRLFileon macOS.net.ssl.CRLFile。Instead, 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请参阅MongoDB 4.0中的net.ssl.certificateSelectorin MongoDB 4.0 andnet.tls.certificateSelectorin MongoDB 4.2 to use the system SSL certificate store.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有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.allowConnectionsWithoutCertificates-
Type: boolean
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.allowConnectionsWithoutCertificatesinstead.net.tls.allowConnectionsWithoutCertificates。For clients that don't provide certificates,对于不提供证书的客户端,假设连接成功,mongodormongosencrypts the TLS/SSL connection, assuming the connection is successfully made.mongod或mongos会对TLS/SSL连接进行加密。For clients that present a certificate, however,然而,对于提供证书的客户端,mongosormongodperforms certificate validation using the root certificate chain specified byCAFileand reject clients with invalid certificates.mongos或mongod使用CAFile指定的根证书链执行证书验证,并拒绝具有无效证书的客户端。Use the如果您的混合部署包括不向net.ssl.allowConnectionsWithoutCertificatesoption if you have a mixed deployment that includes clients that do not or cannot present certificates to themongosormongod.mongos或mongod提供证书或不能向其提供证书的客户端,请使用net.ssl.allowConnectionsWithoutCertificates选项。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.allowInvalidCertificates-
Type: boolean
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.allowInvalidCertificatesinstead.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证书的验证检查,并允许使用无效证书进行连接。NoteStarting 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连接,但不足以进行身份验证:--sslAllowInvalidCertificatesornet.ssl.allowInvalidCertificates: truefor MongoDB 4.0 and later--tlsAllowInvalidCertificatesornet.tls.allowInvalidCertificates: truefor MongoDB 4.2 and later
When using the当使用net.ssl.allowInvalidCertificatessetting, 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有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.allowInvalidHostnames-
Type: boolean
Default: false
Deprecated since version 4.2.自4.2版起弃用。Use请改用net.tls.allowInvalidHostnamesinstead.net.tls.allowInvalidHostnames。When当net.ssl.allowInvalidHostnamesistrue, MongoDB disables the validation of the hostnames in TLS/SSL certificates, allowingmongodto connect to MongoDB instances if the hostname their certificates do not match the specified hostname.net.ssl.allowInvalidHostnames为true时,MongoDB将禁用TLS/SSL证书中主机名的验证,允许mongod在主机名及其证书与指定主机名不匹配时连接到MongoDB实例。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos以及针对客户端的TLS/SSL配置。
net.ssl.disabledProtocols-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.disabledProtocolsinstead.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.disabledProtocolsrecognizes 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_0、TLS1_1、TLS1_2,以及从版本4.0.4(和3.6.9)开始的TLS1_3。On macOS, you cannot disable在macOS上,不能禁用TLS1_1and leave bothTLS1_0andTLS1_2enabled.TLS1_1并同时启用TLS1_0和TLS1_2。You 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要启用禁用的TLS 1.0,请为nonetonet.ssl.disabledProtocols. See Disable 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.副本集和分片集群的成员必须至少使用一个通用协议。TipSee also:另请参阅:
net.ssl.FIPSMode-
Type: boolean
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.FIPSModeinstead.net.tls.FIPSMode。Enable or disable the use of the FIPS mode of the TLS/SSL library for the为mongosormongod. Your system must have a FIPS compliant library to use thenet.ssl.FIPSModeoption.mongos或mongod启用或禁用TLS/SSL库的FIPS模式。您的系统必须具有符合FIPS的库才能使用net.ssl.FIPSMode选项。NoteFIPS-compatible TLS/SSL is available only in MongoDB EnterpriseFIPS兼容的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指定用于此mongodormongosinstance and:mongod或mongos实例与以下对象之间通信的默认压缩器:other members of the deployment if the instance is part of a replica set or a sharded cluster部署的其他成员(如果实例是副本集或分片集群的一部分)mongoshdrivers that support the支持OP_COMPRESSEDmessage 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,在3.6和4.0版本中,mongodandmongosenable network compression by default withsnappyas the compressor.mongod和mongos默认启用网络压缩,并使用snappy作为压缩器。Starting in version 4.2,从4.2版本开始,mongodandmongosinstances default to bothsnappy,zstd,zlibcompressors, in that order.mongod和mongos实例默认为snappy,zstd,zlib压缩器,按顺序排列。To disable network compression, set the value to要禁用网络压缩,请将该值设置为disabled.disabled。ImportantMessages 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例如,如果mongoshspecifies the following network compressorszlib,snappyand themongodspecifiessnappy,zlib, messages betweenmongoshandmongoduseszlib.mongosh指定以下网络压缩器zlib,snappy,而mongod指定snappy,zlib,则mongosh和mongod之间的消息使用zlib。If the parties do not share at least one common compressor, messages between the parties are uncompressed.如果双方不共享至少一个公共压缩器,则双方之间的消息将被解压缩。For example, if例如,如果mongoshspecifies the network compressorzlibandmongodspecifiessnappy, messages betweenmongoshandmongodare not compressed.mongosh指定网络压缩器zlib,mongod指定snappy,则mongosh和mongod之间的消息不会被压缩。
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实例使用该共享机密在分片集群或副本集中相互验证。keyFileimpliessecurity.authorization.keyFile意味着security.authorization。See 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:此选项可以具有以下值之一:Value值Description描述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如果未指定--tlsCAFileortls.CAFileis 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.--tlsCAFile或tls.CAFile,并且您未使用x.509身份验证,则在连接到启用TLS的服务器时将使用系统范围的CA证书存储。If using x.509 authentication,如果使用x.509身份验证,则必须指定--tlsCAFileortls.CAFilemust be specified unless using--tlsCertificateSelector.--tlsCAFile或tls.CAFile,除非使用--tlsCertificateSelector。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongodandmongosfor TLS/SSL and TLS/SSL Configuration for Clients .mongod和mongos和针对客户端的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:将此选项设置为以下选项之一:Value值Description描述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.有关详细信息,请参阅基于角色的访问控制。Thesecurity.authorizationsetting is available only formongod.security.authorization设置仅适用于mongod。
security.transitionToAuth-
Type: boolean
Default: false
Allows the允许mongodormongosto accept and create authenticated and non-authenticated connections to and from othermongodandmongosinstances in the deployment.mongod或mongos接受并创建与部署中其他mongod和mongos实例之间的已验证和未验证连接。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例如,如果使用keyfiles进行内部身份验证,mongodormongoscreates an authenticated connection with anymongodormongosin the deployment using a matching keyfile.mongod或mongos将使用匹配的键文件创建与部署中的任何mongod和mongos的已验证连接。If the security mechanisms do not match, the如果安全机制不匹配,mongodormongosutilizes a non-authenticated connection instead.mongod或mongos将使用未经身份验证的连接。A使用mongodormongosrunning withsecurity.transitionToAuthdoes not enforce user access controls.security.transitionToAuth运行的mongod或mongos不强制执行用户访问控制。Users may connect to your deployment without any access control checks and perform read, write, and administrative operations.用户可以在不进行任何访问控制检查的情况下连接到您的部署,并执行读取、写入和管理操作。NoteA使用内部身份验证而不使用mongodormongosrunning with internal authentication and withoutsecurity.transitionToAuthrequires clients to connect using user access controls.security.transitionToAuth运行的mongod或mongos要求客户端使用用户访问控制进行连接。Update clients to connect to the在没有mongodormongosusing the appropriate user prior to restartingmongodormongoswithoutsecurity.transitionToAuth.security.transitionToAuth的情况下重新启动mongod或mongos之前,更新客户端以使用适当的用户连接到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禁用时,不能使用执行JavaScript代码的服务器端执行的操作,例如$wherequery operator,mapReducecommand,$accumulator, and$function.$where查询运算符、mapReduce命令、$accumulator和$function。If you do not use these operations, disable server-side scripting.如果不使用这些操作,请禁用服务器端脚本。Starting in version 4.4, the从版本4.4开始,security.javascriptEnabledis available for bothmongodandmongos.security.javascriptEnabled可用于mongod和mongos。In earlier versions, the setting is only available for在早期版本中,该设置仅适用于mongod.mongod。
security.redactClientLogData-
Type: boolean
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。A使用mongodormongosrunning withsecurity.redactClientLogDataredacts any message accompanying a given log event before logging.security.redactClientLogData运行的mongod或mongos会在日志记录之前对给定日志事件附带的任何消息进行编辑。This prevents the这可以防止mongodormongosfrom writing potentially sensitive data stored on the database to the diagnostic log.mongod或mongos将存储在数据库中的潜在敏感数据写入诊断日志。Metadata such as error or operation codes, line numbers, and source file names are still visible in the logs.元数据(如错误或操作代码、行号和源文件名)在日志中仍然可见。Use将security.redactClientLogDatain 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)存储在一个或多个集合中。Themongodormongoslogs events such as those related to CRUD operations, sharding metadata, etc.mongod或mongos记录事件,例如与CRUD操作、分片元数据等相关的事件。It is possible that themongodormongosmay expose PII as a part of these logging operations.mongod或mongos可能会将PII作为这些日志操作的一部分进行公开。A使用mongodormongosrunning withsecurity.redactClientLogDataremoves any message accompanying these events before being output to the log, effectively removing the PII.security.redactClientLogData运行的mongod或mongos会在将这些事件输出到日志之前删除伴随这些事件的任何消息,从而有效地删除PII。Diagnostics on a由于缺少与日志事件相关的数据,在使用mongodormongosrunning withsecurity.redactClientLogDatamay be more difficult due to the lack of data related to a log event.security.redactClientLogData运行的mongod或mongos上进行诊断可能会更加困难。See the process logging manual page for an example of the effect of有关security.redactClientLogDataon log output.security.redactClientLogData对日志输出的影响的示例,请参阅进程日志记录手册页面。On a running在运行的mongodormongos, usesetParameterwith theredactClientLogDataparameter to configure this setting.mongod或mongos上,使用setParameter和redactClientLogData参数来配置此设置。
security.clusterIpSourceAllowlist-
Type: list
New in version 5.0.5.0版新增。A list of IP addresses/CIDR (Classless Inter-Domain RoutingIP地址/CIDR(无类别域间路由) ranges against which the
mongodvalidates authentication requests from other members of the replica set and, if part of a sharded cluster, themongosinstances.)范围的列表,
mongod根据该列表验证来自副本集其他成员的身份验证请求,如果是分片集群的一部分,则验证mongos实例。Themongodverifies 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如果IP地址不存在,则服务器不会对mongodormongos.mongod或mongos进行身份验证。security.clusterIpSourceAllowlisthas no effect on amongodstarted without authentication.security.clusterIpSourceAllowlist对未经身份验证启动的mongod没有影响。security.clusterIpSourceAllowlistrequires specifying each IPv4/6 address or Classless Inter-Domain Routing (CIDR要求将每个IPv4/6地址或无类别域间路由(CIDR) range as a YAML list:
)范围指定为YAML列表:
security:
clusterIpSourceAllowlist:
- 192.0.2.0/24
- 127.0.0.1
- ::1ImportantEnsure确保security.clusterIpSourceAllowlistincludes the IP address or CIDR ranges that include the IP address of each replica set member ormongosin 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中已弃用:Use请改用security.clusterIpSourceAllowlistinstead.security.clusterIpSourceAllowlist。A list of IP addresses/CIDR (Classless Inter-Domain RoutingIP地址/CIDR(无类别域间路由) ranges against which the
mongodvalidates authentication requests from other members of the replica set and, if part of a sharded cluster, themongosinstances.)范围的列表,
mongod根据该列表验证来自副本集其他成员的身份验证请求,如果是分片集群的一部分,则验证mongos实例。Themongodverifies 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如果IP地址不存在,则服务器不会对mongodormongos.mongod或mongos进行身份验证。security.clusterIpSourceWhitelisthas no effect on a对未经身份验证启动的mongodstarted without authentication.mongod没有影响。security.clusterIpSourceWhitelistrequires specifying each IPv4/6 address or Classless Inter-Domain Routing (CIDR要求将每个IPv4/6地址或无类别域间路由(CIDR) range as a YAML list:
)范围指定为YAML列表:
security:
clusterIpSourceWhitelist:
- 192.0.2.0/24
- 127.0.0.1
- ::1ImportantEnsure确保security.clusterIpSourceWhitelistincludes the IP address or CIDR ranges that include the IP address of each replica set member ormongosin 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必须设置为trueto pass in encryption keys and configurations.true才能传入加密键和配置。NoteEnterprise Feature企业功能Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。
security.encryptionCipherMode-
Type: string
Default:
AES256-CBCThe cipher mode to use for encryption at rest:用于静态加密的密码模式:Mode Description描述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 supportsWindows上的MongoDB Enterprise不再支持AES256-GCM.AES256-GCM。This cipher is now available only on Linux.此密码现在仅在Linux上可用。NoteEnterprise 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.enableEncryptionto betrue.security.enableEncryption为true。NoteEnterprise 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您只能在第一次为mongodinstance.mongod实例启用加密时使用该设置。Requires要求security.enableEncryptionto be true.security.enableEncryption为true。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将抛出错误。NoteEnterprise 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,则旋转主键并重新加密内部键库。NoteEnterprise Feature企业功能Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。TipSee also:另请参阅:
security.kmip.serverName-
Type: string
Hostname or IP address of the KMIP server to connect to. Requires要连接到的KMIP服务器的主机名或IP地址。要求security.enableEncryptionto be true.security.enableEncryption为true。Starting in MongoDB 4.2.1 (and 4.0.14), you can specify multiple KMIP servers as a comma-separated list, e.g.从MongoDB 4.2.1(和4.0.14)开始,您可以将多个KMIP服务器指定为逗号分隔的列表,例如server1.example.com,server2.example.com.server1.example.com,server2.example.com。On startup, the启动时,mongodwill 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服务器选择仅在启动时发生。mongodverifies the connection to the KMIP server on startup.在启动时验证与KMIP服务器的连接。The server name specified in在--kmipServerNamemust match either the Subject Alternative NameSANor the Common NameCNon the certificate presented by the KMIP server.--kmipServerName中指定的服务器名称必须与KMIP服务器提供的证书上的使用者备用名称SAN或公用名称CN匹配。SANcan be a system name or an IP address.可以是系统名称或IP地址。If如果存在SANis present,mongoddoes not try to match againstCN.SAN,mongod不会尝试与CN进行匹配。If the hostname or IP address of the KMIP server does does not match either如果KMIP服务器的主机名或IP地址与SANorCN,mongoddoes not start.SAN或CN不匹配,则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名称的比较。NoteEnterprise 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. Requiressecurity.enableEncryptionto be true.security.kmip.serverName。要求security.enableEncryption为true。If specifying multiple KMIP servers with如果使用security.kmip.serverName, themongodwill use the port specified withsecurity.kmip.portfor all provided KMIP servers.security.kmip.serverName指定多个KMIP服务器,则mongod将为所有提供的KMIP服务器使用使用security.kmip.port指定的端口。NoteEnterprise Feature企业功能Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。
security.kmip.clientCertificateFile-
Type: string
Path to the用于向KMIP服务器验证MongoDB的.pemfile used to authenticate MongoDB to the KMIP server..pem文件的路径。The specified指定的.pemfile must contain both the TLS/SSL certificate and key..pem文件必须同时包含TLS/SSL证书和键。To use this setting, you must also specify the若要使用此设置,还必须指定security.kmip.serverNamesetting.security.kmip.serverName设置。NoteStarting 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。NoteEnterprise 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.仅当证书已加密时才使用该选项。NoteEnterprise 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在Windows和macOS上可用作security.kmip.clientCertificateFile.security.kmip.clientCertificateFile的替代方案。security.kmip.clientCertificateFileand和security.kmip.clientCertificateSelectoroptions 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.clientCertificateSelectoraccepts an argument of the format接受格式为<property>=<value>where the property can be one of the following:<property>=<value>的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subjectASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprinthex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprintis sometimes referred to as afingerprint.thumbprint有时被称为fingerprint。NoteEnterprise 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服务器的安全客户端连接。NoteStarting 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。When using the secure store, you do not need to, but can, also specify the使用安全存储时,您不需要,但也可以指定security.kmip.serverCAFile.security.kmip.serverCAFile。NoteEnterprise 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与connectTimeoutMSto control how long themongodwaits for a response between each retry.connectTimeoutMS一起使用可以控制mongod在每次重试之间等待响应的时间。NoteEnterprise 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如果指定了connectRetriessetting is specified, themongodwill wait up to the value specified withconnectTimeoutMSfor each retry.connectRetries设置,则mongod将在每次重试时等待connectTimeoutMS指定的值。Value must be值必须大于或等于1000or greater.1000。NoteEnterprise 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.activateKeysistrueand you have existing keys on a KMIP server, the key must be activated first or themongodnode will fail to start.security.kmip.activateKeys为true并且您在KMIP服务器上有现有键时,必须首先激活该键,否则mongod节点将无法启动。If the key being used by the mongod transitions into a non-active state, the如果mongodnode will shut down unlesskmipActivateKeysis false.mongod使用的键转换为非活动状态,则mongod节点将关闭,除非kmipActivateKeys为false。To 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,mongoduses KMIP protocol version 1.0 or 1.1 instead of the default version. The default KMIP protocol is version 1.2.true,mongod将使用KMIP协议版本1.0或1.1,而不是默认版本。默认的KMIP协议是1.2版本。To use audit log encryption with KMIP version 1.0 or 1.1, you must specify若要在KMIP版本1.0或1.1中使用审核日志加密,必须在启动时指定auditEncryptKeyWithKMIPGetat startup.auditEncryptKeyWithKMIPGet。To use KMIP protocol version 1.0 or 1.1, substitute your local values and add an entry like this to your要使用KMIP协议版本1.0或1.1,请替换您的本地值,并在mongodconfiguration file: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. TheMongoDB只允许在启动时设置此选项。setParametercan not change this setting.setParameter无法更改此设置。This option is available only in MongoDB Enterprise.此选项仅在MongoDB Enterprise中可用。ImportantEnsure that your driver supports alternate service names. For确保您的驱动程序支持备用服务名称。要想让mongoshand other MongoDB tools to connect to the newserviceName, see thegssapiServiceNameoption.mongosh和其他MongoDB工具连接到新的serviceName,请参阅gssapiServiceName选项。
security.sasl.saslauthdSocketPath-
Type: string
The path to the UNIX domain socket file forsaslauthd.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 themongodormongosauthenticates users or determines what actions a user is authorized to perform on a given database.mongod或mongos对用户进行身份验证或确定用户有权在给定数据库上执行哪些操作的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如果LDAP基础结构在多个LDAP服务器上对LDAP目录进行分区,请将一个LDAP服务器或其任何复制实例指定为安全的LDAP服务器。security.ldap.servers.MongoDB supports following LDAP referrals as defined in RFC 4511 4.1.10MongoDB支持RFC 4511 4.1.10.
中定义的以下LDAP引用。
Do not use不要使用security.ldap.serversfor listing every LDAP server in your infrastructure.security.ldap.servers来列出基础结构中的每个LDAP服务器。This setting can be configured on a running可以使用mongodormongosusingsetParameter.setParameter在正在运行的mongod或mongos上配置此设置。If unset,如果未设置,mongodormongoscannot use LDAP authentication or authorization.mongod或mongos将无法使用LDAP身份验证或授权。
security.ldap.bind.queryUser-
Type: string
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。The identity with which当连接到LDAP服务器或在LDAP服务器上执行查询时,mongodormongosbinds as, when connecting to or performing queries on an LDAP server.mongod或mongos绑定为的标识。Only required if any of the following are true:仅当以下任何一项为真时才需要:Using LDAP authorization.使用LDAP授权。Using an LDAP query for使用LDAP查询进行security.ldap.userToDNMapping.security.ldap.userToDNMapping。The LDAP server disallows anonymous bindsLDAP服务器不允许匿名绑定
You must use必须将queryUserwithqueryPassword.queryUser与queryPassword一起使用。If unset,如果未设置,mongodormongoswill not attempt to bind to the LDAP server.mongod或mongos将不会尝试绑定到LDAP服务器。This setting can be configured on a running可以使用mongodormongosusingsetParameter.setParameter在正在运行的mongod或mongos上配置此设置。NoteWindows MongoDB deployments can useWindows MongoDB部署可以使用useOSDefaultsinstead ofqueryUserandqueryPassword.useOSDefaults而不是queryUser和queryPassword。You cannot specify both不能同时指定queryUseranduseOSDefaultsat the same time.queryUser和useOSDefaults。
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您必须将queryPasswordwithqueryUser.queryPassword与queryUser一起使用。If not set,如果未设置,mongodormongosdoes not attempt to bind to the LDAP server.mongod或mongos不会尝试绑定到LDAP服务器。You can configure this setting on a running您可以使用mongodormongosusingsetParameter.setParameter在正在运行的mongod或mongos上配置此设置。Starting in MongoDB 4.4, the从MongoDB 4.4开始,ldapQueryPasswordsetParametercommand accepts either a string or an array of strings.ldapQueryPasswordsetParameter命令接受字符串或字符串数组。If如果ldapQueryPasswordis 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帐户密码。NoteWindows MongoDB deployments can useWindows MongoDB部署可以使用useOSDefaultsinstead ofqueryUserandqueryPassword.useOSDefaults而不是queryUser和queryPassword。You cannot specify both不能同时指定queryPasswordanduseOSDefaultsat the same time.queryPassword和useOSDefaults。
security.ldap.bind.useOSDefaults-
Type: boolean
Default: false
Available in MongoDB Enterprise for the Windows platform only.仅适用于Windows平台的MongoDB Enterprise。Allows允许mongodormongosto authenticate, or bind, using your Windows login credentials when connecting to the LDAP server.mongod或mongos在连接到LDAP服务器时使用Windows登录凭据进行身份验证或绑定。Only required if:只有在以下情况下才需要:Using LDAP authorization.使用LDAP授权。Using an LDAP query for使用LDAP查询进行用户名转换。username transformation.The LDAP server disallows anonymous bindsLDAP服务器不允许匿名绑定
Use使用useOSDefaultsto replacequeryUserandqueryPassword.useOSDefaults替换queryUser和queryPassword。
security.ldap.bind.method-
Type: string
Default: simple
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。The methodmongodormongosuses to authenticate to an LDAP server.mongod或mongos用于向LDAP服务器进行身份验证的方法。Use with与queryUserandqueryPasswordto connect to the LDAP server.queryUser和queryPassword一起使用可连接到LDAP服务器。methodsupports the following values:支持以下值:simple-mongodormongosuses simple authentication.mongod或mongos使用简单的身份验证。sasl-mongodormongosuses SASL protocol for authenticationmongod或mongos使用SASL协议进行身份验证
If you specify如果指定sasl,则可以使用sasl, you can configure the available SASL mechanisms usingsecurity.ldap.bind.saslMechanisms.security.ldap.bind.saslMechanisms配置可用的sasl机制。mongodormongosdefaults to usingDIGEST-MD5mechanism.mongod或mongos默认使用DIGEST-MD5机制。
security.ldap.bind.saslMechanisms-
Type: string
Default: DIGEST-MD5
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。A comma-separated list of SASL mechanismsmongodormongoscan use when authenticating to the LDAP server.mongod或mongos在向LDAP服务器进行身份验证时可以使用的SASL机制的逗号分隔列表。Themongodormongosand the LDAP server must agree on at least one mechanism.mongod或mongos和LDAP服务器必须至少在一种机制上达成一致。Themongodormongosdynamically loads any SASL mechanism libraries installed on the host machine at runtime.mongod或mongos在运行时动态加载主机上安装的任何SASL机制库。Install and configure the appropriate libraries for the selected SASL mechanism(s) on both the在mongodormongoshost and the remote LDAP server host.mongod或mongos主机和远程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机制与Kerberos身份验证一起使用,请为GSSAPISASL mechanism for use with Kerberos Authentication, verify the following for themongodormongoshost machine:mongod或mongos主机验证以下内容:Linux-
TheKRB5_CLIENT_KTNAMEenvironment 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客户端键选项卡包括一个用户主体,供mongodormongosto use when connecting to the LDAP server and execute LDAP queries.mongod或mongos在连接到LDAP服务器并执行LDAP查询时使用。
WindowsIf connecting to an Active Directory server, the Windows Kerberos configuration automatically generates a Ticket-Granting-Ticket如果连接到活动目录服务器,则当用户登录到系统时,Windows Kerberos配置会自动生成票证授予票证when the user logs onto the system.
。
Set将useOSDefaultstotrueto allowmongodormongosto use the generated credentials when connecting to the Active Directory server and execute queries.useOSDefaults设置为true,以允许mongod或mongos在连接到活动目录服务器并执行查询时使用生成的凭据。
Set将methodtosaslto use this option.method设置为sasl以使用此选项。NoteFor 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的更多信息,请参阅以下资源:For Linux, please see the Cyrus SASL documentation.对于Linux,请参阅Cyrus SASL文档。
For Windows, please see the Windows SASL documentation.对于Windows,请参阅Windows SASL文档。
security.ldap.transportSecurity-
Type: string
Default: tls
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。By default,默认情况下,mongodormongoscreates a TLS/SSL secured connection to the LDAP server.mongod或mongos会创建到LDAP服务器的TLS/SSL安全连接。For Linux deployments, you must configure the appropriate TLS Options in对于Linux部署,必须在/etc/openldap/ldap.conffile./etc/openldap/ldap.conf文件中配置适当的TLS选项。Your operating system's package manager creates this file as part of the MongoDB Enterprise installation, via the您的操作系统的包管理器通过libldapdependency.libldap依赖关系将此文件创建为MongoDB Enterprise安装的一部分。See the documentation for有关更完整的说明,请参阅TLS Optionsin the ldap.conf OpenLDAP documentationfor more complete instructions.
ldap.confOpenLDAP文档中的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将transportSecuritytononeto disable TLS/SSL betweenmongodormongosand the LDAP server.transportSecurity设置为none可禁用mongod或mongos与LDAP服务器之间的TLS/SSL。WarningSetting将transportSecuritytononetransmits plaintext information and possibly credentials betweenmongodormongosand the LDAP server.transportSecurity设置为none将在mongod或mongos与LDAP服务器之间传输明文信息,并可能传输凭据。
security.ldap.timeoutMS-
Type: int
Default: 10000
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。The amount of time in millisecondsmongodormongosshould wait for an LDAP server to respond to a request.mongod或mongos应等待LDAP服务器响应请求的时间(以毫秒为单位)。Increasing the value of如果故障源是连接超时,那么增加timeoutMSmay 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减少timeoutMSreduces the time MongoDB waits for a response from the LDAP server.timeoutMS的值可以减少MongoDB等待LDAP服务器响应的时间。This setting can be configured on a running可以使用mongodormongosusingsetParameter.setParameter在正在运行的mongod或mongos上配置此设置。
security.ldap.retryCountNew 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可以使用mongodormongosusingsetParameter.setParameter在正在运行的mongod或mongos上配置此设置。
security.ldap.userToDNMapping-
Type: string
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。Maps the username provided to将提供给mongodormongosfor authentication to a LDAP Distinguished Name (DN).mongod或mongos进行身份验证的用户名映射到LDAP可分辨名称(DN)。You may need to use在以下情况下,您可能需要使用userToDNMappingto 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使用需要DN的LDAP授权查询模板。LDAP authorization query templatethat requires a DN.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以进行授权。
userToDNMappingexpects a quote-enclosed JSON-string representing an ordered array of documents.需要一个带引号的JSON字符串,该字符串表示文档的有序数组。Each document contains a regular expression每个文档都包含一个正则表达式匹配和一个用于转换传入用户名的matchand either asubstitutionorldapQuerytemplate used for transforming the incoming username.substitution或ldapQuery模板。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每个带括号的部分表示substitutionorldapQuery.substitution或ldapQuery使用的regex捕获组。"(.+)ENGINEERING""(.+)DBA"substitutionAn LDAP distinguished name (DN) formatting template that converts the authentication name matched by theLDAP可分辨名称(DN)格式模板,用于将匹配正则表达式匹配的身份验证名称转换为LDAP DN。matchregex into a LDAP DN.Each curly bracket-enclosed numeric value is replaced by the corresponding regex capture group每个用大括号括起来的数值都被通过extracted from the authentication username via the
matchregex.match正则表达式从身份验证用户名中提取的相应正则表达式捕获组所替换。
The result of the substitution must be an RFC4514替换的结果必须是RFC4514escaped string.
转义字符串。
"cn={0},ou=engineering, dc=example,dc=com"ldapQueryA LDAP query formatting template that inserts the authentication name matched by theLDAP查询格式化模板,将matchregex into an LDAP query URI encoded respecting RFC4515 and RFC4516.match正则表达式匹配的身份验证名称插入到根据RFC4515和RFC4516编码的LDAP查询URI中。Each curly bracket-enclosed numeric value is replaced by the corresponding regex capture group每个用大括号括起来的数值都被通过匹配表达式从身份验证用户名中提取的相应regex捕获组extracted from the authentication username via the
matchexpression.所替换。
mongodormongosexecutes the query against the LDAP server to retrieve the LDAP DN for the authenticated user.mongod或mongos对LDAP服务器执行查询,以检索经过身份验证的用户的LDAP DN。mongodormongosrequires exactly one returned result for the transformation to be successful, ormongodormongosskips this transformation.mongod或mongos只需要一个返回结果就可以成功转换,或者mongod或者mongos跳过这个转换。"ou=engineering,dc=example, dc=com??one?(user={0})"NoteFor each document in the array, you must use either对于数组中的每个文档,必须使用substitutionorldapQuery. You cannot specify both in the same document.substitution或ldapQuery。不能在同一文档中同时指定两者。When performing authentication or authorization,在执行身份验证或授权时,mongodormongossteps through each document in the array in the given order, checking the authentication username against thematchfilter.mongod或mongos按给定顺序遍历数组中的每个文档,并根据匹配筛选器检查身份验证用户名。If a match is found,如果找到匹配项,mongodormongosapplies the transformation and uses the output for authenticating the user.mongod或mongos将应用转换并使用输出对用户进行身份验证。mongodormongosdoes not check the remaining documents in the array.mongod或mongos不检查数组中的其余文档。If the given document does not match the provided authentication name,如果给定的文档与提供的身份验证名称不匹配,mongodormongoscontinues through the list of documents to find additional matches.mongod或mongos会继续查看文档列表以查找其他匹配项。If no matches are found in any document, or the transformation the document describes fails,如果在任何文档中都找不到匹配项,或者文档描述的转换失败,mongodormongosreturns an error.mongod或mongos将返回错误。Starting in MongoDB 4.4,从MongoDB 4.4开始,如果其中一个转换由于LDAP服务器的网络或身份验证失败而无法评估,mongodormongosalso returns an error if one of the transformations cannot be evaluated due to networking or authentication failures to the LDAP server.mongod或mongos也会返回一个错误。mongodormongosrejects the connection request and does not check the remaining documents in the array.mongod或mongos拒绝连接请求,并且不检查数组中的其余文档。Starting in MongoDB 5.0,从MongoDB 5.0开始,userToDNMappingaccepts an empty string""or empty array[ ]in place of a mapping document.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.以前,提供空的映射文档会导致映射失败。ExampleThe 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捕获组中。ImportantYou 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.COMmatches the first document. The regex capture group{0}corresponds to the stringalice. The resulting output is the DN"cn=alice,ou=engineering,dc=example,dc=com".A user with username
bob@DBA.EXAMPLE.COMmatches the second document. The regex capture group{0}corresponds to the stringbob. The resulting output is the LDAP query"ou=dba,dc=example,dc=com??one?(user=bob)".mongodormongosexecutes this query against the LDAP server, returning the result"cn=bob,ou=dba,dc=example,dc=com".If
userToDNMappingis unset,mongodormongosapplies 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
mongodormongosusing thesetParameterdatabase 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
mongodexecutes to obtain the LDAP groups to which the authenticated user belongs to. The query is relative to the host or hosts specified insecurity.ldap.servers.In the URL, you can use the following substitution tokens:在URL中,您可以使用以下替换令牌:Substitution Token Description描述{USER}Substitutes the authenticated username, or the transformedusername if auserToDNMappingis specified.{PROVIDED_USER}Substitutes the supplied username, i.e. before either authentication or替换提供的用户名,即在身份验证或LDAP转换之前。LDAP transformation.
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,如果您的查询包含一个属性,mongodassumes 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,如果您的查询不包括属性,mongodassumes the query retrieves all entities which the user is member of.mongod假设查询检索用户所属的所有实体。For each LDAP DN returned by the query,对于查询返回的每个LDAP DN,mongodassigns the authorized user a corresponding role on theadmindatabase.mongod在admin数据库中为授权用户分配相应的角色。If a role on the on the如果admindatabase exactly matches the DN,mongodgrants 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()方法。ExampleThis LDAP query returns any groups listed in the LDAP user object's此LDAP查询返回LDAP用户对象的memberOfattribute.memberOf属性中列出的任何组。"{USER}?memberOf?base"Your LDAP configuration may not include theLDAP配置可能不包括memberOfattribute 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.memberOf属性作为用户架构的一部分,可能拥有用于报告组成员身份的不同属性,或者可能不通过属性跟踪组成员身份。根据您自己的唯一LDAP配置配置查询。If unset,如果未设置,mongodcannot authorize users using LDAP.mongod将无法使用LDAP对用户进行授权。This setting can be configured on a running可以使用mongodusing thesetParameterdatabase command.setParameter数据库命令在正在运行的mongod上配置此设置。
security.ldap.validateLDAPServerConfig-
Type: boolean
Default: true
Available in MongoDB Enterprise在MongoDB Enterprise中可用A flag that determines if the一个标志,用于确定mongodormongosinstance checks the availability of theLDAP server(s)as part of its startup:mongod或mongos实例是否在启动时检查LDAP服务器的可用性:If如果为true, themongodormongosinstance performs the availability check and only continues to start up if the LDAP server is available.true,mongod或mongos实例将执行可用性检查,并且只有在LDAP服务器可用时才会继续启动。If如果为false, themongodormongosinstance skips the availability check; i.e. the instance starts up even if the LDAP server is unavailable.false,mongod或mongos实例将跳过可用性检查;即,即使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例如,要在配置文件中指定enableLocalhostAuthBypassin the configuration file:enableLocalhostAuthBypass:setParameter:
enableLocalhostAuthBypass: false
LDAP ParametersLDAP参数
setParameter.ldapUserCacheInvalidationInterval-
Type: int
Default: 30
For use with用于使用LDAP授权的mongodservers using LDAP Authorization.mongod服务器。The interval (in seconds)外部用户缓存刷新之间的间隔时间(以秒为单位)。mongodwaits between external user cache flushes.Aftermongodflushes 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增加指定的值会增加mongodand 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相反,减少指定的值会减少时间间隔,并且LDAP服务器可能不同步,同时增加LDAP服务器上的负载。mongodand the LDAP server can be out of sync while increasing the load on the LDAP server.
setParameter:
ldapUserCacheInvalidationInterval: <int>
storage Options
Changed in version 6.1:6.1版更改:
MongoDB always enables journaling. As a result, MongoDB removes theMongoDB始终支持日志记录。因此,MongoDB删除了storage.journal.enabledoption and the corresponding--journaland--nojournalcommand-line options.storage.journal.enabled选项以及相应的--journal和--nojournal命令行选项。
Changed in version 4.4:4.4版更改:
MongoDB removes theMongoDB删除了storage.indexBuildRetryoption and the corresponding--noIndexBuildRetrycommand-line option.storage.indexBuildRetry选项和相应的--noIndexBuildRetry命令行选项。MongoDB deprecatesMongoDB弃用storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGBoption.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/dbon Linux and macOS\data\dbon Windows
The directory where themongodinstance stores its data.mongod实例存储其数据的目录。Thestorage.dbPathsetting is available only formongod.storage.dbPath设置仅适用于mongod。NoteConfiguration Files配置文件The default包管理器安装中包含的默认mongod.confconfiguration file included with package manager installations uses the following platform-specific default values forstorage.dbPath:mongod.conf配置文件使用以下特定于平台的storage.dbPath默认值:Platform Package Manager程序包管理器Default storage.dbPathRHEL / CentOS and Amazon yum/var/lib/mongoSUSE zypper/var/lib/mongoUbuntu and Debian apt/var/lib/mongodbmacOS brew/usr/local/var/mongodbThe Linux package init scripts do not expectLinux包init脚本不希望storage.dbPathto change from the defaults.storage.dbPath从默认值更改。If you use the Linux packages and change如果使用Linux软件包并更改storage.dbPath, you will have to use your own init scripts and disable the built-in scripts.storage.dbPath,则必须使用自己的init脚本并禁用内置脚本。
storage.journal.commitIntervalMs-
Type: number
Default: 100
The maximum amount of time in milliseconds that themongodprocess 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:truewill cause an immediate sync of the journal.j:true的写入将导致日志的立即同步。For details or additional conditions that affect the frequency of the sync, see Journaling Process.有关影响同步频率的详细信息或其他条件,请参阅日志处理。Thestorage.journal.commitIntervalMssetting is available only formongod.storage.journal.commitIntervalMs设置仅适用于mongod。Not available for不适用于使用内存中存储引擎的mongodinstances that use the in-memory storage engine.mongod实例。NoteKnown Issue in 4.2.0: The4.2.0中的已知问题:4.2.0中缺少storage.journal.commitIntervalMsis missing in 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.dbPathdirectory, and each subdirectory name corresponds to the database name.storage.dbPath目录下,每个子目录名称都与数据库名称相对应。Thestorage.directoryPerDBsetting is available only formongod.storage.directoryPerDB设置仅适用于mongod。Not available for不适用于使用内存中存储引擎的mongodinstances 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从MongoDB 5.0开始,在启用storage.directoryPerDBis enabled deletes the newly empty subdirectory for that database.storage.directoryPerDB时,删除数据库中的最终集合(或删除数据库本身)会删除该数据库的新空子目录。To change the要更改现有部署的storage.directoryPerDBoption for existing deployments:storage.directoryPerDB选项,请执行以下操作:For standalone instances:对于独立实例:Use对现有mongodumpon the existingmongodinstance to generate a backup.mongod实例使用mongodump生成备份。Stop the停止mongodinstance.mongod实例。Add the添加storage.directoryPerDBvalue and configure a new data directorystorage.directoryPerDB值并配置新的数据目录Restart the重新启动mongodinstance.mongod实例。Use使用mongorestoreto populate the new data directory.mongorestore填充新的数据目录。
For replica sets:对于复制副本集:Stop a secondary member.停止辅助成员。Add the添加storage.directoryPerDBvalue and configure a new data directory to that secondary member.storage.directoryPerDB值,并为该辅助成员配置一个新的数据目录。Restart that secondary.重新启动辅助设备。Use initial sync to populate the new data directory.使用初始同步来填充新的数据目录。Update remaining secondaries in the same fashion.以相同的方式更新其余的辅助设备。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.在几乎所有情况下,都应该使用默认设置。WarningIf you set如果将storage.syncPeriodSecsto0, MongoDB will not sync the memory mapped files to disk.storage.syncPeriodSecs设置为0,MongoDB将不会将内存映射文件同步到磁盘。Themongodprocess writes data very quickly to the journal and lazily to the data files.mongod进程非常快速地将数据写入日志,并缓慢地写入数据文件。storage.syncPeriodSecshas no effect on Journaling, but if对日志记录没有影响,但如果storage.syncPeriodSecsis set to0the journal will eventually consume all available disk space.storage.syncPeriodSecs设置为0,则日志记录最终将消耗所有可用磁盘空间。Thestorage.syncPeriodSecssetting is available only formongod.storage.syncPeriodSecs设置仅适用于mongod。Not available for不适用于使用内存中存储引擎的mongodinstances that use the in-memory storage engine.mongod实例。
storage.engine-
Default:
wiredTigerNoteStarting in version 4.2, MongoDB removes the deprecated MMAPv1 storage engine.从4.2版本开始,MongoDB删除了不推荐使用的MMAPv1存储引擎。The storage engine for themongoddatabase. Available values include:mongod数据库的存储引擎。可用值包括:Value值Description描述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如果您尝试使用mongodwith astorage.dbPaththat contains data files produced by a storage engine other than the one specified bystorage.engine,mongodwill 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.5represents one hour and thirty minutes.1.5表示一小时三十分钟。The value must be greater than or equal to该值必须大于或等于0.0。A value of值0indicates that themongodshould truncate the oplog starting with the oldest entries to maintain the configured maximum oplog size.0表示mongod应该从最旧的条目开始截断oplog,以保持配置的最大oplog大小。Defaults to默认值为0。0.A以mongodstarted withoplogMinRetentionHoursonly 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当配置了最短oplog保留期时,mongodhas the following behavior when configured with a minimum oplog retention period: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如果oplog增长超过其最大大小,即使oplog恢复到其最大大小或配置为更小的最大大小,mongodmay continue to hold that disk space even if the oplog returns to its maximum size or is configured for a smaller maximum size.mongod也可能继续保留该磁盘空间。See Reducing Oplog Size Does Not Immediately Return Disk Space.请参阅减少操作日志大小不会立即返回磁盘空间。Themongodcompares 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, usereplSetResizeOplog.mongod后更改oplog的最小保留期,请使用replSetResizeOplog。replSetResizeOplogenables you to resize the oplog dynamically without restarting the使您能够在不重新启动mongodprocess.mongod进程的情况下动态调整oplog的大小。To persist the changes made using要在重新启动时保持使用replSetResizeOplogthrough a restart, update the value ofoplogMinRetentionHours.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到10000 GB。0.25GB to10000GB.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 (例如,在总内存为4GB的系统上,WiredTiger缓存将使用1.5GB的RAM(0.5 * (4 GB - 1 GB) = 1.5 GB).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 (相反,总RAM为1.25 GB的系统将为WiredTiger缓存分配256 MB,因为这超过了总RAM的一半减去1 GB(0.5 * (1.25 GB - 1 GB) = 128 MB < 256 MB).0.5 * (1.25 GB - 1 GB) = 128 MB < 256 MB)。NoteIn 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缓存或其他进程未使用的所有可用内存。NoteThestorage.wiredTiger.engineConfig.cacheSizeGBlimits 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默认的WiredTiger内部缓存大小值假定每台机器有一个mongodinstance per machine.mongod实例。If a single machine contains multiple MongoDB instances, then you should decrease the setting to accommodate the other如果一台机器包含多个MongoDB实例,那么应该减少设置以容纳其他mongodinstances.mongod实例。If you run如果在无法访问系统中所有可用RAM的容器(例如mongodin a container (e.g.lxc,cgroups, Docker, etc.) that does not have access to all of the RAM available in a system, you must setstorage.wiredTiger.engineConfig.cacheSizeGBto a value less than the amount of RAM available in the container.lxc、cgroups、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:可用的压缩机有:
storage.wiredTiger.engineConfig.directoryForIndexes-
Type: boolean
Default: false
When当storage.wiredTiger.engineConfig.directoryForIndexesistrue,mongodstores indexes and collections in separate subdirectories under the data (i.e.storage.dbPath) directory.storage.wiredTiger.engineConfig.directoryForIndexes为true时,mongod将索引和集合存储在data(即storage.dbPath)目录下的单独子目录中。Specifically,具体来说,mongodstores the indexes in a subdirectory namedindexand the collection data in a subdirectory namedcollection.mongod将索引存储在名为index的子目录中,将集合数据存储在名名为collection的子目录下。By using a symbolic link, you can specify a different location for the indexes.通过使用符号链接,可以为索引指定不同的位置。Specifically, when具体地说,当mongodinstance is not running, move theindexsubdirectory to the destination and create a symbolic link namedindexunder the data directory to the new destination.mongod实例没有运行时,将index子目录移动到目标,并在数据目录下创建一个名为index的符号链接到新的目标。
storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB-
Type: float
NoteDeprecated in MongoDB 4.4
MongoDB deprecates theMongoDB建议弃用storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGBoption.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指定MongoDB 4.2.1-4.2x和4.0.12-4.0x的“lookaside(或缓存溢出)表”文件WiredTigerLAS.wtfor MongoDB 4.2.1-4.2.x and 4.0.12-4.0.x. The file no longer exists starting in version 4.4.WiredTigerLAS.wt的最大大小(以GB为单位)。该文件从4.4版开始不再存在。The setting can accept the following values:该设置可以接受以下值:Value值Description描述0The default value.默认值。If set to如果设置为0, the file size is unbounded.0,则文件大小是无限制的。number >= 0.1 The maximum size (in GB).最大大小(以GB为单位)。If the如果WiredTigerLAS.wtfile exceeds this size,mongodexits with a fatal assertion.WiredTigerLAS.wt文件超过此大小,mongod将退出并发出致命断言。You can clear the您可以清除WiredTigerLAS.wtfile and restartmongod.WiredTigerLAS.wt文件并重新启动mongod。To change the maximum size during runtime, use the要在运行时更改最大大小,请使用wiredTigerMaxCacheOverflowSizeGBparameter.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 forzstdCompressionLevelthe higher the compression which is applied.zstdCompressionLevel的指定值越高,应用的压缩就越高。Only applicable when仅当blockCompressoris set tozstd.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.blockCompressoraffects all collections created.影响所有创建的集合。If you change the value of如果更改现有MongoDB部署上storage.wiredTiger.collectionConfig.blockCompressoron 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.storage.wiredTiger.collectionConfig.blockCompressor的值,则所有新集合都将使用指定的压缩器。现有集合将继续使用创建时指定的压缩器,或当时的默认压缩器。
storage.wiredTiger.indexConfig.prefixCompression-
Default: true
Enables or disables prefix compression for index data.启用或禁用索引数据的前缀压缩。Specify为trueforstorage.wiredTiger.indexConfig.prefixCompressionto enable prefix compression for index data, orfalseto disable prefix compression for index data.storage.wiredTiger.indexConfig.prefixCompression指定true可启用索引数据的前缀压缩,或为false可禁用索引数据的后缀压缩。Thestorage.wiredTiger.indexConfig.prefixCompressionsetting affects all indexes created.storage.wiredTiger.indexConfig.prefixCompression设置会影响所有创建的索引。If you change the value of如果在现有MongoDB部署上更改storage.wiredTiger.indexConfig.prefixCompressionon an existing MongoDB deployment, all new indexes will use prefix compression.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 GBValues 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为内存中存储引擎数据分配的最大内存量,包括索引、oplog(如果mongodis part of replica set, replica set or sharded cluster metadata, etc.mongod是副本集、副本集或分片集群元数据的一部分)等。By default, the in-memory storage engine uses 50% of physical RAM minus 1 GB.默认情况下,内存中存储引擎使用50%的物理RAM减去1 GB。NoteEnterprise Feature企业功能Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。
operationProfiling Options
operationProfiling:
mode: <string>
slowOpThresholdMs: <int>
slowOpSampleRate: <double>
filter: <string>
operationProfiling.mode-
Type: string
Default:
offSpecifies which operations should be profiled. The following profiler levels are available:指定应探查哪些操作。以下探查器级别可用:Level Description描述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.探查器集合所有操作的数据。WarningProfiling 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当logLevelis set to0, MongoDB records slow operations to the diagnostic log at a rate determined byslowOpSampleRate.logLevel设置为0时,MongoDB会以slowOpSampleRate确定的速率将慢速操作记录到诊断日志中。At higher在更高的logLevelsettings, 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辅助设备只记录慢速操作日志条目;增加logLeveldoes not log all oplog entries.logLevel不会记录所有oplog条目。This setting is available for此设置可用于mongodandmongos.mongod和mongos。For对于mongodinstances, the setting affects both the diagnostic log and, if enabled, the profiler.mongod实例,该设置会影响诊断日志,如果启用,还会影响探查器。For对于mongosinstances, the setting affects the diagnostic log only and not the profiler, since profiling is not available onmongos.mongos实例,该设置仅影响诊断日志,而不影响探查器,因为在mongos上无法进行探查。
operationProfiling.slowOpSampleRate-
Type: double
Default: 1.0
The fraction of slow operations that should be profiled or logged.应该对慢速操作进行分析或记录的部分。operationProfiling.slowOpSampleRateaccepts values between 0 and 1, inclusive.接受0和1之间的值(包括0和1)。Changed in version 4.0:4.0版更改:TheslowOpSampleRatesetting is available formongodandmongos.slowOpSampleRate设置可用于mongod和mongos。In earlier versions,在早期版本中,slowOpSampleRateis available formongodonly.slowOpSampleRate仅适用于mongod。For对于mongodinstances, the setting affects both the diagnostic log and, if enabled, the profiler.mongod实例,该设置会影响诊断日志,如果启用,还会影响探查器。For对于mongosinstances, the setting affects the diagnostic log only and not the profiler since profiling is not available onmongos.mongos实例,该设置仅影响诊断日志,而不影响探查器,因为在mongos上无法进行探查。
operationProfiling.filter-
Type
: string representation of a query document:查询文档的字符串表示A filter expression that controls which operations are profiled and logged.一个筛选器表达式,用于控制对哪些操作进行分析和记录。When设置filteris set,slowOpThresholdMsandslowOpSampleRateare not used for profiling and slow-query log lines.filter后,slowOpThresholdMs和slowOpSampleRate不会用于分析和慢速查询日志行。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例如,以下filterconfigures the profiler to logqueryoperations 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)。NoteThe oplog can grow past its configured size limit to avoid deleting theoplog可以超过其配置的大小限制,以避免删除majority commit point.majority commit point多数提交点。By default, the默认情况下,mongodprocess creates an oplog based on the maximum amount of space available.mongod进程会根据可用的最大空间量创建一个oplog。For 64-bit systems, the oplog is typically 5% of available disk space.对于64位系统,操作日志通常是可用磁盘空间的5%。Once the一旦mongodhas created the oplog for the first time, changing thereplication.oplogSizeMBoption will not affect the size of the oplog.mongod第一次创建了oplog,更改replication.oplogSizeMB选项将不会影响oplog的大小。To change the maximum oplog size after starting the要在启动mongod, usereplSetResizeOplog.mongod后更改最大操作日志大小,请使用replSetResizeOplog。replSetResizeOplogenables you to resize the oplog dynamically without restarting the使您能够在不重新启动mongodprocess.mongod进程的情况下动态调整oplog的大小。To persist the changes made using要在重新启动时保持使用replSetResizeOplogthrough a restart, update the value ofoplogSizeMB.replSetResizeOplog所做的更改,请更新oplogSizeMB的值。See Oplog Size for more information.有关详细信息,请参阅操作日志大小。Thereplication.oplogSizeMBsetting is available only formongod.replication.oplogSizeMB设置仅适用于mongod。
replication.replSetName-
Type: string
The name of the replica set that themongodis 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.如果应用程序连接到多个复制副本集,则每个复制副本集都必须具有不同的名称。某些驱动程序按副本集名称对副本集连接进行分组。Thereplication.replSetNamesetting is available only formongod.replication.replSetName设置仅可用于mongod。Starting in MongoDB 4.0:从MongoDB 4.0开始:The setting设置replication.replSetNamecannot be used in conjunction withstorage.indexBuildRetry.replication.replSetName不能与storage.indexBuildRetry一起使用。
replication.enableMajorityReadConcern-
Default: true
Configures support for
"majority"read concern.Starting in MongoDB 5.0,从MongoDB 5.0开始,enableMajorityReadConcerncannot be changed and is always set totrue. Attempting to start a storage engine that does not support majority read concern with the--enableMajorityReadConcernoption will fail and return an error message.enableMajorityReadConcern不能更改,并且始终设置为true。尝试使用--enableMajorityReadConcern选项启动不支持多数读取关注的存储引擎将失败,并返回错误消息。In earlier versions of MongoDB,在MongoDB的早期版本中,enableMajorityReadConcernwas configurable.enableMajorityReadConcern是可配置的。WarningIf 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 themongodinstance has in the sharded cluster. Set this setting to one of the following:mongod实例在分片集群中的角色。将此设置设置为以下其中一项:Value值Description描述configsvrStart this instance as a config server.将此实例作为配置服务器启动。The instance starts on port默认情况下,实例在端口27019by default.27019上启动。
When you configure a MongoDB instance as clusterRole当您将MongoDB实例配置为clusterRoleconfigsvryou must also specify areplSetName.configsvr时,还必须指定replSetName。shardsvrStart this instance as a shard.将此实例作为分片启动。The instance starts on port默认情况下,实例在端口27018by default.27018上启动。
When you configure a MongoDB instance as a a clusterRole当您将MongoDB实例配置为clusterRoleshardsvryou must also specify areplSetName.shardsvr时,还必须指定replSetName。NoteSetting设置sharding.clusterRolerequires themongodinstance to be running with replication.sharding.clusterRole需要mongod实例与复制一起运行。To deploy the instance as a replica set member, use the要将实例部署为副本集成员,请使用replSetNamesetting and specify the name of the replica set.replSetName设置并指定副本集的名称。Thesharding.clusterRolesetting is available only formongod.sharding.clusterRole设置仅适用于mongod。
auditLog Options
Available only in MongoDB Enterprise仅在MongoDB Enterprise and MongoDB Atlas
.
和MongoDB 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.auditEncryptionKeyIdentifierandauditLog.localAuditKeyFiletogether.NoteAvailable 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.auditEncryptionKeyIdentifierorauditLog.localAuditKeyFile.auditLog.auditEncryptionKeyIdentifier或auditLog.localAuditKeyFile启用审核日志加密。auditLog.compressionModecan be set to one of these values:可以设置为以下值之一:Value值Description描述zstdUse the zstd algorithm to compress the audit log.使用zstd算法压缩审核日志。none(default)Do not compress the audit log.不要压缩审核日志。NoteAvailable only in MongoDB Enterprise
.
MongoDB Enterprise and Atlas have different configuration requirements.MongoDB Enterprise和Atlas有不同的配置要求。
auditLog.destination-
Type: string
When set,设置后,auditLog.destinationenables auditing and specifies wheremongosormongodsends all audit events.auditLog.destination将启用审核,并指定mongos或mongod发送所有审核事件的位置。auditLog.destinationcan have one of the following values:可以具有以下值之一:Value值Description描述syslogOutput the audit events to syslog in JSON format. Not available on Windows.以JSON格式将审核事件输出到syslog。在Windows上不可用。Audit messages have a syslog severity level of审核消息的系统日志严重性级别为infoand a facility level ofuser.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以JSON格式将审核事件输出到stdoutin JSON format.stdout。fileOutput the audit events to the file specified in将审核事件以auditLog.pathin the format specified inauditLog.format.auditLog.format中指定的格式输出到auditLog.path中指定的文件。NoteAvailable only in MongoDB Enterprise仅在MongoDB Enterpriseand MongoDB Atlas
.
和MongoDB 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格式。NoteAvailable only in MongoDB Enterprise仅在MongoDB Enterpriseand MongoDB Atlas
.
和MongoDB Atlas
中提供。
auditLog.format-
Type: string
The format of the output file for auditing if如果目标是destinationisfile.file,则用于审核的输出文件的格式。TheauditLog.formatoption can have one of the following values:auditLog.format选项可以具有以下值之一:Value值Description描述JSONOutput the audit events in JSON format to the file specified in将审核事件以JSON格式输出到auditLog.path.auditLog.path中指定的文件。BSONOutput the audit events in BSON binary format to the file specified in以BSON二进制格式将审核事件输出到auditLog.path.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格式的文件更能降低服务器性能。NoteAvailable only in MongoDB Enterprise仅在MongoDB Enterpriseand MongoDB Atlas
.
和MongoDB 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.指定用于审核日志加密的本地审核键文件的路径和文件名。NoteOnly use由于键不安全,只能使用auditLog.localAuditKeyFilefor testing because the key is not secured.auditLog.localAuditKeyFile进行测试。To secure the key, use要保护键,请使用auditLog.auditEncryptionKeyIdentifierand an external Key Management Interoperability Protocol (KMIP) server.auditLog.auditEncryptionKeyIdentifier和外部键管理互操作性协议(KMIP)服务器。You cannot use不能同时使用auditLog.localAuditKeyFileandauditLog.auditEncryptionKeyIdentifiertogether.auditLog.localAuditKeyFile和auditLog.auditEncryptionKeyIdentifier。NoteAvailable 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如果destinationhas value offile.destination的值为file,则用于审核的输出文件。TheauditLog.pathoption 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如果为truethe node can take part in Online Audit Filter Management.true,则节点可以参与联机审核筛选器管理。NoteAvailable only in MongoDB Enterprise仅在MongoDB Enterpriseand MongoDB Atlas
.
和MongoDB Atlas
中提供。
mongos -only Options
replication:
localPingThresholdMs: <int>
sharding:
configDB: <string>
replication.localPingThresholdMs-
Type: integer
Default: 15
The ping time, in milliseconds, thatmongosuses to determine which secondary replica set members to pass read operations from clients.mongos用于确定从客户端传递读取操作的辅助副本集成员的ping时间(以毫秒为单位)。The default value of默认值15对应于所有客户端驱动程序中的默认值。15corresponds to the default value in all of the client drivers.When当mongosreceives a request that permits reads to secondary members, themongoswill: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.localPingThresholdMsoption,mongoswill 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.localPingThresholdMssetting 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因此,一些查询可能会到达阈值以上的成员,直到mongosrecalculates the averagemongos重新计算平均值.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分片集群的mongosinstances 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作为Windows服务运行时mongosormongodwhen running as a Windows Service. Use this name with thenet start <name>andnet stop <name>operations.mongos或mongod的服务名称。将此名称用于net start <name>和net stop <name>操作。You must use必须将processManagement.windowsService.serviceNamein conjunction with either the--installor--removeoption.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运行mongosormongodservice description.mongos或mongod服务描述。You must use必须将processManagement.windowsService.descriptionin conjunction with the--installoption.processManagement.windowsService.description与--install选项结合使用。For descriptions that contain spaces, you must enclose the description in quotes.对于包含空格的说明,必须将说明用引号括起来。
processManagement.windowsService.serviceUser-
Type: string
The某个用户上下文中的mongosormongodservice in the context of a certain user. This user must have "Log on as a service" privileges.mongos或mongod服务。此用户必须具有“作为服务登录”权限。You must use必须将processManagement.windowsService.serviceUserin conjunction with the--installoption.processManagement.windowsService.serviceUser与--install选项结合使用。
processManagement.windowsService.servicePassword-
Type: string
The password for当使用<user>formongosormongodwhen running with theprocessManagement.windowsService.serviceUseroption.processManagement.windowsService.serviceUser选项运行时,mongos或mongod的<user>的密码。You must use必须将processManagement.windowsService.servicePasswordin conjunction with the--installoption.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特定的配置选项:
storage.mmapv1.journal.commitIntervalMs | |
storage.mmapv1.journal.debugFlags | mongod --journalOptions |
storage.mmapv1.nsSize | mongod --nssize |
storage.mmapv1.preallocDataFiles | mongod --noprealloc |
storage.mmapv1.quota.enforced | mongod --quota |
storage.mmapv1.quota.maxFilesPerDB | mongod --quotaFiles |
storage.mmapv1.smallFiles | mongod --smallfiles |
storage.repairPath | mongod --repairpath |
replication.secondaryIndexPrefetch | mongod --replIndexPrefetch |
For earlier versions of MongoDB, refer to the corresponding version of the manual. 有关MongoDB的早期版本,请参阅相应版本的手册。For example:例如: