Configuration File Options配置文件选项
On this page本页内容
Configuration File配置文件File Format文件格式Use the Configuration File使用配置文件Core Options核心选项systemLog
Options选项processManagement
Options选项cloud
Options选项net
Options选项security
Options选项setParameter
Option选项storage
Options选项operationProfiling
Options选项replication
Options选项sharding
Options选项auditLog
Options选项仅用于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上使用诸如yum
orapt
on Linux orbrew
on 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
, orzypper
Package Managerapt
、yum
或zypper
软件包管理器/etc/mongod.conf
macOS brew
Package 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.cfg
If you installed MongoDB via a downloaded如果您通过下载的TGZ
orZIP
file, 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详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.是MongoDB的默认日志详细级别,以包括信息消息。1
to5
increases 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.verbosity
to set the verbosity level specifically forACCESS
components.systemLog.component.accessControl.verbosity
专门为ACCESS
组件设置详细级别。See the请参阅systemLog.component.<name>.verbosity
settings for specific component verbosity settings.systemLog.component.<name>.verbosity
特定组件详细信息设置的详细信息设置。For various ways to set the log verbosity level, see Configure Log Verbosity Levels.有关设置日志详细级别的各种方法,请参阅配置日志详细级别。[2] Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages.从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs例如,如果详细级别为2,MongoDB将记录D2
.D2
。In previous versions, MongoDB log messages only specified在以前的版本中,MongoDB日志消息只为调试级别指定了D
for Debug level.D
。
systemLog.quiet
-
Type: boolean
Default: false
Run在安静模式下运行mongos
ormongod
in a quiet mode that attempts to limit the amount of output.mongos
或mongod
,尝试限制输出量。systemLog.quiet
is not recommended for production systems as it may make tracking problems during particular connections much more difficult.systemLog.quiet
不建议用于生产系统,因为它可能会使跟踪特定连接期间的问题更加困难。
systemLog.traceAllExceptions
-
Type: boolean
Default: false
Print verbose information for debugging. Use for additional logging for support-related troubleshooting.打印详细信息以进行调试。用于其他日志记录以进行与支持相关的故障排除。
systemLog.syslogFacility
-
Type: string
Default: user
The facility level used when logging messages to syslog.将消息记录到系统日志时使用的设施级别。The value you specify must be supported by your operating system's implementation of syslog.操作系统的syslog实现必须支持您指定的值。To use this option, you must set要使用此选项,必须将systemLog.destination
tosyslog
.systemLog.destination
设置为syslog
。
systemLog.path
-
Type: string
The path of the log file to whichmongod
ormongos
should send all diagnostic logging information, rather than the standard output or the host's syslog. MongoDB creates the log file at the specified path.mongod
或mongos
应向其发送所有诊断日志信息的日志文件的路径,而不是标准输出或主机的syslog。MongoDB在指定的路径创建日志文件。The Linux package init scripts do not expectLinux包init脚本不希望systemLog.path
to 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
,mongos
ormongod
appends new entries to the end of the existing log file when themongos
ormongod
instance restarts.true
时,mongos
或mongod
实例重新启动时,会在现有日志文件的末尾添加新条目。Without this option,如果没有此选项,mongod
will back up the existing log and create a new file.mongod
将备份现有日志并创建一个新文件。
systemLog.logRotate
-
Type: string
Default: rename
Determines the behavior for the确定在旋转服务器日志和/或审核日志时logRotate
command when rotating the server log and/or the audit log.logRotate
命令的行为。Specify either指定rename
orreopen
:rename
或reopen
:rename
renames the log file.重命名日志文件。reopen
closes and reopens the log file following the typical Linux/Unix log rotate behavior.按照典型的Linux/Unix日志旋转行为关闭并重新打开日志文件。Use使用Linux/Unix logrotate实用程序时请使用reopen
when using the Linux/Unix logrotate utility to avoid log loss.reopen
以避免日志丢失。If you specify如果指定reopen
, you must also setsystemLog.logAppend
totrue
.reopen
,还必须将systemLog.logAppend
设置为true
。
systemLog.destination
-
Type: string
The destination to which MongoDB sends all log output.MongoDB将所有日志输出发送到的目的地。Specify either指定file
orsyslog
.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会将所有日志输出发送到标准输出。WarningThesyslog
daemon generates timestamps when it logs a message, not when MongoDB issues the message.syslog
守护进程在记录消息时生成时间戳,而不是在MongoDB发出消息时生成。This can lead to misleading timestamps for log entries, especially when the system is under heavy load.这可能会导致日志条目的时间戳产生误导,尤其是当系统负载过重时。We recommend using the我们建议生产系统使用file
option for production systems to ensure accurate timestamps.file
选项,以确保准确的时间戳。
systemLog.timeStampFormat
-
Type: string
Default: iso8601-local
The time format for timestamps in log messages. Specify one of the following values:日志消息中时间戳的时间格式。指定以下值之一:Value值Description描述iso8601-utc
Displays timestamps in Coordinated Universal Time (UTC) in the ISO-8601 format.以ISO-8601格式显示协调世界时(UTC)的时间戳。For example, for New York at the start of the Epoch:例如,大纪元初期的纽约:1970-01-01T00:00:00.000Z
iso8601-local
Displays timestamps in local time in the ISO-8601 format.以ISO-8601格式显示本地时间的时间戳。For example, for New York at the start of the Epoch:例如,大纪元初期的纽约:1969-12-31T19:00:00.000-05:00
NoteStarting in MongoDB 4.4,从MongoDB 4.4开始,systemLog.timeStampFormat
no longer supportsctime
. An example ofctime
formatted 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请参阅ACCESS
components.ACCESS
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见COMMAND
components.COMMAND
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅CONTROL
components.CONTROL
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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与诊断数据集合操作相关的组件的日志消息详细级别。请参阅FTDC
components.FTDC
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见GEO
components.GEO
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见INDEX
components.INDEX
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅NETWORK
components.NETWORK
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅QUERY
components.QUERY
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见REPL
components.REPL
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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与选举相关的组件的日志消息详细级别。请参见ELECTION
components.ELECTION
组件。If如果未设置systemLog.component.replication.election.verbosity
is unset,systemLog.component.replication.verbosity
level also applies to election components.systemLog.component.replication.election.verbosity
,则systemLog.component.replication.verbosity
级别也适用于选举组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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_HB
components.REPL_HB
组件。If如果未设置systemLog.component.replication.heartbeats.verbosity
is unset,systemLog.component.replication.verbosity
level also applies to heartbeats components.systemLog.component.replication.heartbeats.verbosity
,则systemLog.component.replication.verbosity
级别也适用于检测信号组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅INITSYNC
components.INITSYNC
组件。If如果未设置systemLog.component.replication.initialSync.verbosity
is unset,systemLog.component.replication.verbosity
level also applies to initialSync components.systemLog.component.replication.initialSync.verbosity
,则systemLog.component.replication.verbosity
级别也适用于initialSync组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见ROLLBACK
components.ROLLBACK
组件。If如果未设置systemLog.component.replication.rollback.verbosity
is unset,systemLog.component.replication.verbosity
level also applies to rollback components.systemLog.component.replication.rollback.verbosity
,则systemLog.component.replication.verbosity
级别也适用于回滚组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅SHARDING
components.SHARDING
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅STORAGE
components.STORAGE
组件。If如果未设置systemLog.component.storage.journal.verbosity
is unset,systemLog.component.storage.verbosity
level also applies to journaling components.systemLog.component.storage.journal.verbosity
,则systemLog.component.storage.verbosity
级别也适用于日志组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅JOURNAL
components.JOURNAL
组件。If如果未设置systemLog.component.storage.journal.verbosity
is unset, the journaling components have the same verbosity level as the parent storage components: i.e. either thesystemLog.component.storage.verbosity
level if set or the default verbosity level.systemLog.component.storage.journal.verbosity
,则日志记录组件与父存储组件具有相同的详细级别:即,如果设置了systemLog.component.storage.verbosity
级别,则为默认详细级别。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅RECOVERY
components.RECOVERY
组件。If如果未设置systemLog.component.storage.recovery.verbosity
is unset,systemLog.component.storage.verbosity
level also applies to recovery components.systemLog.component.storage.recovery.verbosity
,则systemLog.component.storage.verbosity
级别也适用于恢复组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见WT
components.WT
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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存储引擎执行的备份操作相关的组件的日志消息详细级别。请参阅WTBACKUP
components.WTBACKUP
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参见WTCHKPT
components.WTCHKPT
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTCMPCT
components.WTCMPCT
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTEVICT
components.WTEVICT
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTHS
components.WTHS
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTRECOV
components.WTRECOV
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTRTS
components.WTRTS
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTSLVG
components.WTSLVG
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTTIER
components.WTTIER
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTTS
components.WTTS
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTTXN
components.WTTXN
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTVRFY
components.WTVRFY
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WTWRTLOG
components.WTWRTLOG
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅TXN
components.TXN
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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请参阅WRITE
components.WRITE
组件。The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.0
是MongoDB的默认日志详细级别,包括信息消息。1
to5
increases 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启用后台运行mongos
ormongod
process in the background.mongos
或mongod
进程的守护程序模式。By default默认情况下,mongos
ormongod
does not run as a daemon: typically you will runmongos
ormongod
as a daemon, either by usingprocessManagement.fork
or by using a controlling process that handles the daemonization process (e.g. as withupstart
andsystemd
).mongos
或mongod
不作为守护进程运行:通常,您将通过使用processManagement.fork
或通过使用处理守护进程的控制进程(例如,与upstart
和systemd
一样)将mongos
和mongod
作为守护进程来运行。TheWindows不支持processManagement.fork
option is not supported on Windows.processManagement.fork
选项。The Linux package init scripts do not expectLinux包init脚本不希望processManagement.fork
to 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指定用于存储mongos
ormongod
process.mongos
或mongod
进程的进程ID(PID)的文件位置。The user running the运行mongod
ormongos
process must be able to write to this path.mongod
或mongos
进程的用户必须能够写入此路径。If the如果未指定processManagement.pidFilePath
option is not specified, the process does not create a PID file.processManagement.pidFilePath
选项,则进程不会创建PID文件。This option is generally only useful in combination with the此选项通常只在与processManagement.fork
setting.processManagement.fork
设置结合使用时有用。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.d
directory, or a systemd unit file registered withsystemctl
./etc/init.d
目录中的服务文件,或者是在systemctl
中注册的systemd单元文件。Only use the只有当您没有使用这些init系统时,才使用processManagement.pidFilePath
option 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.pidFilePath
option if you are not usingbrew
on 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/zoneinfo
by 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,
timelib
could 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并使用timeZoneInfo
parameter.timeZoneInfo
参数。
cloud
Options
New in version 4.0. 4.0版新增。
cloud:
monitoring:
free:
state: <string>
tags: <string>
cloud.monitoring.free.state
-
Type: string
New in version 4.0:4.0版新增:Available for MongoDB Community Edition.适用于MongoDB社区版。Enables or disables free MongoDB Cloud monitoring.启用或禁用免费的MongoDB云监控。cloud.monitoring.free.state
accepts the following values:接受以下值:runtime
Default.违约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()
。on
Enables free monitoring at startup; i.e. registers for free monitoring.启用启动时的免费监控;即注册免费监控。When enabled at startup, you cannot disable free monitoring during runtime.如果在启动时启用,则无法在运行时禁用免费监视。off
Disables 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) ormongos
instancemongod
(如果不是分片成员或配置服务器成员)或mongos
实例为2701727018 if如果mongod
is ashard member
mongod
是分片成员则为2701827019 if如果mongod
is aconfig server member
mongod
是配置服务器成员则为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 whichmongos
ormongod
should listen for client connections.mongos
或mongod
应在其上侦听客户端连接的主机名和/或IP地址和/或完整Unix域套接字路径。You may attach您可以将mongos
ormongod
to any interface.mongos
或mongod
附加到任何接口。To bind to multiple addresses, enter a list of comma-separated values.要绑定到多个地址,请输入逗号分隔的值列表。Examplelocalhost,/tmp/mongod.sock
You can specify both IPv4 and IPv6 addresses, or hostnames that resolve to an IPv4 or IPv6 address.可以指定IPv4和IPv6地址,也可以指定解析为IPv4或IPv6地址的主机名。Examplelocalhost, 2001:0DB8:e132:ba26:0d5c:2774:e7f9:d513
NoteIf specifying an IPv6 address or a hostname that resolves to an IPv6 address to如果指定IPv6地址或解析为net.bindIp
, you must startmongos
ormongod
withnet.ipv6 : true
to enable IPv6 support.net.bindIp
的IPv6地址的主机名,则必须使用net.ipv6 : true
启动mongos
或mongod
才能启用IPv6支持。Specifying an IPv6 address to为net.bindIp
does 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%enp0s3
ImportantTo 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.0
or 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.bindIpAll
setting.net.bindIpAll
设置。Notenet.bindIp
andnet.bindIpAll
are mutually exclusive. That is, you can specify one or the other, but not both.net.bindIp
和net.bindIpAll
是互斥的。也就是说,您可以指定一个或另一个,但不能同时指定两者。The command-line option命令行选项--bind_ip
overrides 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开始,replSetInitiate
andreplSetReconfig
reject configurations that use IP addresses instead of hostnames.replSetInitiate
和replSetReconfig
拒绝使用IP地址而不是主机名的配置。Use使用disableSplitHorizonIPCheck
to modify nodes that cannot be updated to use host names.disableSplitHorizonIPCheck
可以修改无法更新为使用主机名的节点。The parameter only applies to the configuration commands.该参数仅适用于配置命令。mongod
andmongos
do not rely ondisableSplitHorizonIPCheck
for validation at startup. Legacymongod
andmongos
instances 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如果为mongos
ormongod
instance binds to all IPv4 addresses (i.e.0.0.0.0
).true
,mongos
或mongod
实例将绑定到所有IPv4地址(即0.0.0.0
)。If如果mongos
ormongod
starts withnet.ipv6 : true
,net.bindIpAll
also binds to all IPv6 addresses (i.e.::
).mongos
或mongod
以net.ipv6 : true
开头,那么net.bindIpAll
也会绑定到所有IPv6地址(即::
)。mongos
ormongod
only supports IPv6 if started withnet.ipv6 : true
.mongos
或mongod
仅支持以net.ipv6 : true
启动的IPv6。Specifying单独指定net.bindIpAll
alone 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.bindIp
to::,0.0.0.0
or, starting in MongoDB 4.2, to an asterisk"*"
(enclose the asterisk in quotes to distinguish from YAML alias nodes) to bind to all IP addresses.
net.bindIp
设置为::,0.0.0.0
,或者设置为星号"*"
(用引号括起星号以区别于YAML别名节点),以绑定到所有IP地址。
Notenet.bindIp
andnet.bindIpAll
are mutually exclusive. Specifying both options causesmongos
ormongod
to throw an error and terminate.net.bindIp
和net.bindIpAll
是互斥的。指定这两个选项会导致mongos
或mongod
抛出错误并终止。
net.maxIncomingConnections
-
Type: integer
Default: 65536
The maximum number of simultaneous connections thatmongos
ormongod
will 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如果您有一个创建多个连接并允许它们超时而不是关闭的客户端,那么这对mongos
if you have a client that creates multiple connections and allows them to timeout rather than closing them.mongos
来说尤其有用。In this case, set在这种情况下,请将maxIncomingConnections
to a value slightly higher than the maximum number of connections that the client creates, or the maximum size of the connection pool.maxIncomingConnections
设置为略高于客户端创建的最大连接数或连接池的最大大小的值。This setting prevents the此设置可防止mongos
from causing connection spikes on the individual shards. Spikes like these may disrupt the operation and memory allocation of the sharded cluster.mongos
在单个分片上造成连接尖峰。像这样的尖峰可能会破坏分片集群的操作和内存分配。
net.wireObjectCheck
-
Type: boolean
Default: true
When当为true
, themongod
ormongos
instance 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.wireObjectCheck
can have a small impact on performance.net.wireObjectCheck
可能会对性能产生较小影响。
net.ipv6
-
Type: boolean
Default: false
Set将net.ipv6
totrue
to enable IPv6 support.mongos
/mongod
disables IPv6 support by default.net.ipv6
设置为true
以启用IPv6支持。mongos
/mongod
默认禁用IPv6支持。Setting设置net.ipv6
does not direct themongos
/mongod
to listen on any local IPv6 addresses or interfaces.net.ipv6
不会指示mongos
/mongod
侦听任何本地IPv6地址或接口。To configure the要将mongos
/mongod
to listen on an IPv6 interface, you must either:mongos
/mongod
配置为在IPv6接口上侦听,您必须:Configure使用一个或多个IPv6地址或解析为IPv6地址的主机名配置net.bindIp
with one or more IPv6 addresses or hostnames that resolve to IPv6 addresses, ornet.bindIp
,或者Set将net.bindIpAll
totrue
.net.bindIpAll
设置为true
。
net.unixDomainSocket
Options
net:
unixDomainSocket:
enabled: <boolean>
pathPrefix: <string>
filePermissions: <int>
net.unixDomainSocket.enabled
-
Type: boolean
Default: true
Enable or disable listening on the UNIX domain socket.启用或禁用对UNIX域套接字的侦听。net.unixDomainSocket.enabled
applies only to Unix-based systems.仅适用于基于Unix的系统。When当net.unixDomainSocket.enabled
istrue
,mongos
ormongod
listens on the UNIX socket.net.unixDomainSocket.enabled
为true
时,mongos
或mongod
侦听UNIX套接字。Themongos
ormongod
process always listens on the UNIX socket unless one of the following is true:mongos
或mongod
进程始终侦听UNIX套接字,除非以下情况之一为真:net.unixDomainSocket.enabled
is为false
--nounixsocket
is set.已设置。The command line option takes precedence over the configuration file setting.命令行选项优先于配置文件设置。net.bindIp
is not set未设置net.bindIp
does not specify未指定localhost
or its associated IP addresslocalhost
或其关联的IP地址
默认情况下,从官方.deb和.rpm包安装的mongos
ormongod
installed from official .deb and .rpm packages have thebind_ip
configuration set to127.0.0.1
by 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.pathPrefix
applies only to Unix-based systems.仅适用于基于Unix的系统。If this option has no value, the如果该选项没有值,mongos
ormongod
process creates a socket with/tmp
as a prefix.mongos
或mongod
进程将创建一个以/tmp为前缀的套接字。MongoDB creates and listens on a UNIX socket unless one of the following is true:MongoDB在UNIX套接字上创建和侦听,除非以下情况之一为真:net.unixDomainSocket.enabled
is为false
--nounixsocket
is set已设置net.bindIp
is not set未设置net.bindIp
does not specify未指定localhost
or its associated IP addresslocalhost
或其关联的IP地址
net.unixDomainSocket.filePermissions
-
Type: int
Default:
0700
Sets the permission for the UNIX domain socket file.设置UNIX域套接字文件的权限。net.unixDomainSocket.filePermissions
applies only to Unix-based systems.仅适用于基于Unix的系统。
net.http
Options
Changed in version 3.6:3.6版更改:MongoDB 3.6 removes the deprecated 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.mode
setting can be one of the following:net.tls.mode
设置的参数可以是以下参数之一:Value值Description描述disabled
The server does not use TLS.服务器不使用TLS。allowTLS
Connections between servers do not use TLS. For incoming connections, the server accepts both TLS and non-TLS.服务器之间的连接不使用TLS。对于传入连接,服务器同时接受TLS和非TLS。preferTLS
Connections between servers use TLS. For incoming connections, the server accepts both TLS and non-TLS.服务器之间的连接使用TLS。对于传入连接,服务器同时接受TLS和非TLS。requireTLS
The server uses and accepts only TLS encrypted connections.服务器仅使用并接受TLS加密的连接。If如果未指定--tlsCAFile
ortls.CAFile
is not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS-enabled server.--tlsCAFile
或tls.CAFile
,并且您未使用x.509身份验证,则在连接到启用TLS的服务器时将使用系统范围的CA证书存储。If using x.509 authentication,如果使用x.509身份验证,则必须指定--tlsCAFile
ortls.CAFile
must be specified unless using--tlsCertificateSelector
.--tlsCAFile
或tls.CAFile
,除非使用--tlsCertificateSelector
。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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证书和键的.pem
file 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.certificateSelector
setting to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.tls.certificateSelector
设置从操作系统的安全证书存储中指定证书,而不是PEM键文件。certificateKeyFile
and和net.tls.certificateSelector
are mutually exclusive.相互排斥。You can only specify one.您只能指定一个。On Linux/BSD, you must specify在Linux/BSD上,启用TLS时,必须指定net.tls.certificateKeyFile
when TLS is enabled.net.tls.certificateKeyFile
。On Windows or macOS, you must specify either在Windows或macOS上,启用TLS时,必须指定net.tls.certificateKeyFile
ornet.tls.certificateSelector
when 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文件。如果mongod
fails 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配置mongod
andmongos
for 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.certificateKeyFilePassword
option only if the certificate-key file is encrypted.net.tls.certificateKeyFilePassword
选项。In all cases, the在所有情况下,mongos
ormongod
will 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.certificateKeyFilePassword
option, 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.certificateKeyFilePassword
option.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如果mongod
fails if it encounters an encrypted PEM file.mongod
遇到加密的PEM文件,它就会失败。Use:请改用net.tls.certificateSelector
instead.net.tls.certificateSelector
。
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.certificateKeyFile
andnet.tls.certificateSelector
options are mutually exclusive. You can only specify one.net.tls.certificateKeyFile
和net.tls.certificateSelector
选项是互斥的。您只能指定一个。net.tls.certificateSelector
accepts an argument of the format接受格式为<property>=<value>
where the property can be one of the following:<property>=<value>
的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subject
ASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprint
hex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprint
is 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(联机证书状态协议)用于验证证书的吊销状态。Themongod
searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified TLS certificate.mongod
在操作系统的安全证书存储中搜索验证指定TLS证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the TLS certificate.特别是,安全证书存储必须包含根CA和构建TLS证书的完整证书链所需的任何中间CA证书。Do not use不要使用net.tls.CAFile
ornet.tls.clusterFile
to 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当使用设置为指纹的rotateCertificates
command or thedb.rotateCertificates()
shell method when usingnet.tls.certificateSelector
or--tlsCertificateSelector
set tothumbprint
net.tls.certificateSelector
或--tlsCertificateSelector
时,不能使用rotateCertificates
命令或db.rotateCertificates()
shell方法
net.tls.clusterCertificateSelector
-
Type: string
New in version 4.2:4.2版新增:Available on Windows and macOS as an alternative to可在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.clusterFile
andnet.tls.clusterCertificateSelector
options are mutually exclusive. You can only specify one.net.tls.clusterFile
和net.tls.clusterCertificateSelector
选项相互排斥。您只能指定一个。net.tls.clusterCertificateSelector
accepts an argument of the format接受格式为<property>=<value>
where the property can be one of the following:<property>=<value>
的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subject
ASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprint
hex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprint
is sometimes referred to as afingerprint
.thumbprint
有时被称为fingerprint
。Themongod
searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified cluster certificate.mongod
在操作系统的安全证书存储中搜索验证指定群集证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the cluster certificate.特别是,安全证书存储必须包含根CA和构建到群集证书的完整证书链所需的任何中间CA证书。Do not use不要使用net.tls.CAFile
ornet.tls.clusterCAFile
to 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
/mongos
logs a warning on connection if the presented x.509 certificate expires within如果提供的x.509证书在30
days of themongod/mongos
host 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.pem
file that contains the x.509 certificate-key file for membership authentication for the cluster or replica set..pem
文件,包含用于集群或副本集成员身份验证的x.509证书键文件。Starting with MongoDB 4.0 on macOS or Windows, you can use the从macOS或Windows上的MongoDB 4.0开始,您可以使用net.tls.clusterCertificateSelector
option to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.tls.clusterCertificateSelector
选项从操作系统的安全证书存储中指定证书,而不是PEM键文件。net.tls.clusterFile
andnet.tls.clusterCertificateSelector
options are mutually exclusive.net.tls.clusterFile
和net.tls.clusterCertificateSelector
选项相互排斥。You can only specify one.您只能指定一个。If如果net.tls.clusterFile
does not specify the.pem
file for internal cluster authentication or the alternativenet.tls.clusterCertificateSelector
, the cluster uses the.pem
file specified in thecertificateKeyFile
setting 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身份验证,则必须指定--tlsCAFile
ortls.CAFile
must be specified unless using--tlsCertificateSelector
.--tlsCAFile
或tls.CAFile
,除非使用--tlsCertificateSelector
。Changed in version 4.4:4.4版更改:mongod
/mongos
logs a warning on connection if the presented x.509 certificate expires within如果提供的x.509证书在30
days of themongod/mongos
host 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配置mongod
andmongos
for 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如果mongod
fails to start if it encounters an encrypted PEM file.mongod
遇到加密的PEM文件,它将无法启动。To securely store and access a certificate for use with membership authentication on Windows, use要在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.clusterPassword
option only if the certificate-key file is encrypted.net.tls.clusterPassword
选项。In all cases, the在所有情况下,mongos
ormongod
will 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.clusterPassword
option, 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.clusterPassword
option.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如果mongod
fails 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配置mongod
andmongos
for TLS/SSL and TLS/SSL Configuration for Clients .mongod
和mongos
和针对客户端的TLS/SSL配置。
net.tls.clusterAuthX509
New in version 7.0.7.0版新增。net:
tls:
clusterAuthX509:
attributes: <string>
extensionValue: <string>
net.tls.clusterAuthX509.attributes
-
Type: string
New in version 7.0.7.0版新增。Specifies a set of X.509 Distinguished Name (DN) attributes and values that the server expects cluster member nodes to contain in their certificate subject names.指定一组X.509可分辨名称(DN)属性和值,服务器希望群集成员节点在其证书使用者名称中包含这些属性和值。This lets you use certificates that don't contain DC, O, and OU values to authenticate cluster members.这允许您使用不包含DC、O和OU值的证书来对集群成员进行身份验证。When设置attributes
is set, MongoDB matches certificates using the DN and ignores extension values.attributes
后,MongoDB将使用DN匹配证书,并忽略扩展值。
net.tls.clusterAuthX509.extensionValue
-
Type: string
New in version 7.0.7.0版新增。Specifies an extension value that corresponds to the MongoDB cluster membership extension OID, 1.3.6.1.4.1.34601.2.1.2, that the server expects cluster member nodes to contain in their certificates. This allows you to use certificates that don't contain DC, O, and OU values to authenticate cluster members.指定一个扩展值,该值对应于MongoDB集群成员资格扩展OID 1.3.6.1.4.1.3046011.2.1.2,服务器希望集群成员节点在其证书中包含该OID。这允许您使用不包含DC、O和OU值的证书来对集群成员进行身份验证。When当设置extensionValue
is set, MongoDB matches certificates using certificate extension values and ignores the Distinguished Name (DN).extensionValue
时,MongoDB使用证书扩展值匹配证书,并忽略可分辨名称(DN)。
net.tls.CAFile
-
Type: string
New in version 4.2:4.2版新增:The包含证书颁发机构的根证书链的.pem
file that contains the root certificate chain from the Certificate Authority..pem
文件。Specify the file name of the使用相对路径或绝对路径指定.pem
file using relative or absolute paths..pem
文件的文件名。- Windows/macOS Only
If using如果使用net.tls.certificateSelector
and/ornet.tls.clusterCertificateSelector
, do not usenet.tls.CAFile
to specify the root and intermediate CA certificates.net.tls.certificateSelector
和/或net.tls.clusterCertificateSelector
,请不要使用net.tls.CAFile
指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the将验证net.tls.certificateSelector
and/ornet.tls.clusterCertificateSelector
certificates 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配置mongod
andmongos
for 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.pem
file that contains the root certificate chain from the Certificate Authority used to validate the certificate presented by a client establishing a connection..pem
文件,包含证书颁发机构的根证书链,用于验证建立连接的客户端提供的证书。Specify the file name of the使用相对路径或绝对路径指定pem文件的文件名。.pem
file using relative or absolute paths.net.tls.clusterCAFile
requires that要求设置net.tls.CAFile
is set.net.tls.CAFile
。If如果net.tls.clusterCAFile
does not specify the.pem
file for validating the certificate from a client establishing a connection, the cluster uses the.pem
file specified in thenet.tls.CAFile
option.net.tls.clusterCAFile
没有指定.pem
文件来验证来自建立连接的客户端的证书,则集群将使用net.tls.CAFile
选项中指定的.pem
文件。net.tls.clusterCAFile
lets you use separate Certificate Authorities to verify the client to server and server to client portions of the TLS handshake.允许您使用单独的证书颁发机构来验证TLS握手的客户端到服务器和服务器到客户端部分。Starting in 4.0, on macOS or Windows, you can use a certificate from the operating system's secure store instead of a PEM key file.从4.0开始,在macOS或Windows上,您可以使用操作系统安全存储中的证书,而不是PEM键文件。See请参阅net.tls.clusterCertificateSelector
.net.tls.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.certificateSelector
and/ornet.tls.clusterCertificateSelector
, do not usenet.tls.clusterCAFile
to specify the root and intermediate CA certificates.net.tls.certificateSelector
和/或net.tls.clusterCertificateSelector
,请不要使用net.tls.clusterCAFile
指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the将验证net.tls.certificateSelector
and/ornet.tls.clusterCertificateSelector
certificates 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配置mongod
andmongos
for 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包含证书吊销列表的.pem
file that contains the Certificate Revocation List. Specify the file name of the.pem
file using relative or absolute paths..pem
文件。使用相对路径或绝对路径指定.pem
文件的文件名。NoteStarting in MongoDB 4.0, you cannot specify从MongoDB 4.0开始,您不能在macOS上指定net.tls.CRLFile
on 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.certificateSelector
in MongoDB 4.0 andnet.tls.certificateSelector
in 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证书存储的替代方案。enables
the use of OCSP (Online Certificate Status Protocol) by default as an alternative to specifying a CRL file or using the system SSL certificate store.
For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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,对于不提供证书的客户端,假设连接成功,mongod
ormongos
encrypts the TLS/SSL connection, assuming the connection is successfully made.mongod
或mongos
会对TLS/SSL连接进行加密。For clients that present a certificate, however,然而,对于提供证书的客户端,mongos
ormongod
performs certificate validation using the root certificate chain specified byCAFile
and reject clients with invalid certificates.mongos
或mongod
使用CAFile
指定的根证书链执行证书验证,并拒绝具有无效证书的客户端。Use the如果您的混合部署包括不向net.tls.allowConnectionsWithoutCertificates
option if you have a mixed deployment that includes clients that do not or cannot present certificates to themongos
ormongod
.mongos
或mongod
提供证书或不能向其提供证书的客户端,请使用net.tls.allowConnectionsWithoutCertificates
选项。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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身份验证时指定--tlsAllowInvalidCertificates
ortls.allowInvalidCertificates: true
when 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.allowInvalidCertificates
setting, MongoDB logs a warning regarding the use of the invalid certificate.net.tls.allowInvalidCertificates
设置时,MongoDB会记录有关使用无效证书的警告。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for TLS/SSL and TLS/SSL Configuration for Clients .mongod
和mongos
和针对客户端的TLS/SSL配置。
net.tls.allowInvalidHostnames
-
Type: boolean
Default: false
When当net.tls.allowInvalidHostnames
istrue
, MongoDB disables the validation of the hostnames in TLS certificates, allowingmongod
to 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配置mongod
andmongos
for 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.disabledProtocols
recognizes 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_1
and leave bothTLS1_0
andTLS1_2
enabled.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,请将none
tonet.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为mongos
ormongod
.mongos
或mongod
启用或禁用TLS库的FIPS模式。Your system must have a FIPS compliant library to use the您的系统必须具有符合FIPS的库才能使用net.tls.FIPSMode
option.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指示mongos
ormongod
to 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若要指示mongos
ormongod
to log a message when a client connects using either TLS 1.2 or TLS 1.3, setnet.tls.logVersions
to"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: requireTLS
instead.net.tls.mode: requireTLS
。Enable or disable TLS/SSL for为mongos
ormongod
.mongos
或mongod
启用或禁用TLS/SSL。With使用net.ssl.sslOnNormalPorts
, amongos
ormongod
requires 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.sslOnNormalPorts
is disabled.net.ssl.sslOnNormalPorts
处于禁用状态。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.mode
instead.net.tls.mode
。Enables TLS/SSL or mixed TLS/SSL used for all network connections.启用用于所有网络连接的TLS/SSL或混合TLS/SSL。The argument to thenet.ssl.mode
setting can be one of the following:net.ssl.mode
设置的参数可以是以下参数之一:Value值Description描述disabled
The server does not use TLS/SSL.服务器未使用TLS/SSL。allowSSL
Connections 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。preferSSL
Connections 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。requireSSL
The 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身份验证,必须指定--tlsCAFile
ornet.tls.CAFile
must be specified unless you are using--tlsCertificateSelector
or--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配置mongod
andmongos
for 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.certificateKeyFile
instead.net.tls.certificateKeyFile
。The包含TLS/SSL证书和键的.pem
file 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.certificateSelector
setting to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.ssl.certificateSelector
设置从操作系统的安全证书存储中指定证书,而不是PEM键文件。PEMKeyFile
and和net.ssl.certificateSelector
are mutually exclusive.相互排斥。You can only specify one.您只能指定一个。On Linux/BSD, you must specify在Linux/BSD上,启用TLS/SSL时,必须指定net.ssl.PEMKeyFile
when TLS/SSL is enabled.net.ssl.PEMKeyFile
。On Windows or macOS, you must specify either在Windows或macOS上,启用TLS/SSL时,必须指定net.ssl.PEMKeyFile
ornet.ssl.certificateSelector
when 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文件。如果mongod
fails 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配置mongod
andmongos
for 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.certificateKeyFilePassword
instead.net.tls.certificateKeyFilePassword
。The password to de-crypt the certificate-key file (i.e.对证书键文件(即PEMKeyFile
).PEMKeyFile
)进行解密的密码。Use the仅当证书键文件已加密时,才使用net.ssl.PEMKeyPassword
option only if the certificate-key file is encrypted.net.ssl.PEMKeyPassword
选项。In all cases, the在所有情况下,mongos
ormongod
will 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.PEMKeyPassword
option, 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.PEMKeyPassword
option.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如果mongod
fails if it encounters an encrypted PEM file. Usenet.ssl.certificateSelector
instead.mongod
遇到加密的PEM文件,它就会失败。请改用net.ssl.certificateSelector
。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.certificateSelector
instead.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.PEMKeyFile
and和net.ssl.certificateSelector
options are mutually exclusive. You can only specify one.选项是相互排斥的。您只能指定一个。net.ssl.certificateSelector
accepts an argument of the format接受格式为<property>=<value>
where the property can be one of the following:<property>=<value>
的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subject
ASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprint
hex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprint
is 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(联机证书状态协议)用于验证证书的吊销状态。Themongod
searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified TLS/SSL certificate.mongod
在操作系统的安全证书存储中搜索验证指定TLS/SSL证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the TLS/SSL certificate.特别是,安全证书存储必须包含根CA和构建TLS/SSL证书的完整证书链所需的任何中间CA证书。Do not use不要使用net.ssl.CAFile
ornet.ssl.clusterFile
to 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.clusterCertificateSelector
instead.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.clusterFile
and和net.ssl.clusterCertificateSelector
options are mutually exclusive.选项是相互排斥的。You can only specify one.您只能指定一个。net.ssl.clusterCertificateSelector
accepts an argument of the format接受格式为<property>=<value>
where the property can be one of the following:<property>=<value>
的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subject
ASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprint
hex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprint
is sometimes referred to as afingerprint
.thumbprint
有时被称为fingerprint
。Themongod
searches the operating system's secure certificate store for the CA certificates required to validate the full certificate chain of the specified cluster certificate.mongod
在操作系统的安全证书存储中搜索验证指定群集证书的完整证书链所需的CA证书。Specifically, the secure certificate store must contain the root CA and any intermediate CA certificates required to build the full certificate chain to the cluster certificate.特别是,安全证书存储必须包含根CA和构建到群集证书的完整证书链所需的任何中间CA证书。Do not use不要使用net.ssl.CAFile
ornet.ssl.clusterFile
to 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.clusterFile
instead.net.tls.clusterFile
。The.pem
file that contains the x.509 certificate-key file for membership authentication for the cluster or replica set..pem
文件,包含用于集群或副本集成员身份验证的x.509证书键文件。Starting with MongoDB 4.0 on macOS or Windows, you can use the从macOS或Windows上的MongoDB 4.0开始,您可以使用net.ssl.clusterCertificateSelector
option to specify a certificate from the operating system's secure certificate store instead of a PEM key file.net.ssl.clusterCertificateSelector
选项从操作系统的安全证书存储中指定证书,而不是PEM键文件。net.ssl.clusterFile
and和net.ssl.clusterCertificateSelector
options are mutually exclusive.选项是相互排斥的。You can only specify one.您只能指定一个。If如果net.ssl.clusterFile
does not specify the.pem
file for internal cluster authentication or the alternativenet.ssl.clusterCertificateSelector
, the cluster uses the.pem
file specified in thePEMKeyFile
setting 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身份验证,必须指定--tlsCAFile
ornet.tls.CAFile
must be specified unless you are using--tlsCertificateSelector
or--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配置mongod
andmongos
for 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如果mongod
fails to start if it encounters an encrypted PEM file.mongod
遇到加密的PEM文件,它将无法启动。To securely store and access a certificate for use with membership authentication on Windows, use要在Windows上安全存储和访问用于成员身份验证的证书,请使用net.ssl.clusterCertificateSelector
.net.ssl.clusterCertificateSelector
。
net.ssl.clusterPassword
-
Type: string
Deprecated since version 4.2自4.2版起弃用: Use:请改用net.tls.clusterPassword
instead.net.tls.clusterPassword
。The password to de-crypt the x.509 certificate-key file specified with对用--sslClusterFile
.--sslClusterFile
指定的x.509证书键文件进行解密的密码。Use the仅当证书键文件已加密时,才使用net.ssl.clusterPassword
option only if the certificate-key file is encrypted.net.ssl.clusterPassword
选项。In all cases, the在所有情况下,mongos
ormongod
will 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.clusterPassword
option, 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.clusterPassword
option.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如果mongod
fails 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配置mongod
andmongos
for 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.CAFile
instead.net.tls.CAFile
。The.pem
file that contains the root certificate chain from the Certificate Authority..pem
文件,包含来自证书颁发机构的根证书链。Specify the file name of the使用相对路径或绝对路径指定.pem
file using relative or absolute paths..pem
文件的文件名。- Windows/macOS Only
If using如果使用net.ssl.certificateSelector
and/ornet.ssl.clusterCertificateSelector
, do not usenet.ssl.CAFile
to specify the root and intermediate CA certificates.net.ssl.certificateSelector
和/或net.ssl.clusterCertificateSelector
,请不要使用net.ssl.CAFile
指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the将验证net.ssl.certificateSelector
and/ornet.ssl.clusterCertificateSelector
certificates in the secure certificate store.net.ssl.certificateSelector
和/或net.ssl.clusterCertificateSelector
证书的完整信任链所需的所有CA证书存储在安全证书存储中。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.clusterCAFile
instead.net.tls.clusterCAFile
。The.pem
file that contains the root certificate chain from the Certificate Authority used to validate the certificate presented by a client establishing a connection..pem
文件,包含证书颁发机构的根证书链,用于验证建立连接的客户端提供的证书。Specify the file name of the使用相对路径或绝对路径指定.pem
file using relative or absolute paths..pem
文件的文件名。net.ssl.clusterCAFile
requires thatnet.ssl.CAFile
is set.If如果net.ssl.clusterCAFile
does not specify the.pem
file for validating the certificate from a client establishing a connection, the cluster uses the.pem
file specified in thenet.ssl.CAFile
option.net.ssl.clusterCAFile
没有指定用于验证来自建立连接的客户端的证书的.pem
文件,则集群将使用net.ssl.CAFile
选项中指定的.pem
。net.ssl.clusterCAFile
lets you use separate Certificate Authorities to verify the client to server and server to client portions of the TLS handshake.允许您使用单独的证书颁发机构来验证TLS握手的客户端到服务器和服务器到客户端部分。Starting in 4.0, on macOS or Windows, you can use a certificate from the operating system's secure store instead of a PEM key file.从4.0开始,在macOS或Windows上,您可以使用操作系统安全存储中的证书,而不是PEM键文件。See请参阅net.ssl.clusterCertificateSelector
.net.ssl.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.certificateSelector
and/ornet.ssl.clusterCertificateSelector
, do not usenet.ssl.clusterCAFile
to specify the root and intermediate CA certificates.net.ssl.certificateSelector
和/或net.ssl.clusterCertificateSelector
,请不要使用net.ssl.clusterCAFile
来指定根证书和中间CA证书。Store all CA certificates required to validate the full trust chain of the将验证net.ssl.certificateSelector
and/ornet.ssl.clusterCertificateSelector
certificates in the secure certificate store.net.ssl.certificateSelector
和/或net.ssl.clusterCertificateSelector
证书的完整信任链所需的所有CA证书存储在安全证书存储中。
For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.CRLFile
instead.net.tls.CRLFile
。The包含证书吊销列表的.pem
file that contains the Certificate Revocation List. Specify the file name of the.pem
file using relative or absolute paths..pem
文件。使用相对路径或绝对路径指定.pem
文件的文件名。NoteStarting in MongoDB 4.0, you cannot specify从MongoDB 4.0开始,您不能在macOS上指定net.ssl.CRLFile
on 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.certificateSelector
in MongoDB 4.0 andnet.tls.certificateSelector
in 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配置mongod
andmongos
for 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.allowConnectionsWithoutCertificates
instead.net.tls.allowConnectionsWithoutCertificates
。For clients that don't provide certificates,对于不提供证书的客户端,假设连接成功,mongod
ormongos
encrypts the TLS/SSL connection, assuming the connection is successfully made.mongod
或mongos
会对TLS/SSL连接进行加密。For clients that present a certificate, however,然而,对于提供证书的客户端,mongos
ormongod
performs certificate validation using the root certificate chain specified byCAFile
and reject clients with invalid certificates.mongos
或mongod
使用CAFile
指定的根证书链执行证书验证,并拒绝具有无效证书的客户端。Use the如果您的混合部署包括不向net.ssl.allowConnectionsWithoutCertificates
option if you have a mixed deployment that includes clients that do not or cannot present certificates to themongos
ormongod
.mongos
或mongod
提供证书或不能向其提供证书的客户端,请使用net.ssl.allowConnectionsWithoutCertificates
选项。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.allowInvalidCertificates
instead.net.tls.allowInvalidCertificates
。Enable or disable the validation checks for TLS/SSL certificates on other servers in the cluster and allows the use of invalid certificates to connect.启用或禁用群集中其他服务器上TLS/SSL证书的验证检查,并允许使用无效证书进行连接。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连接,但不足以进行身份验证:--sslAllowInvalidCertificates
ornet.ssl.allowInvalidCertificates: true
for MongoDB 4.0 and later--tlsAllowInvalidCertificates
ornet.tls.allowInvalidCertificates: true
for MongoDB 4.2 and later
When using the当使用net.ssl.allowInvalidCertificates
setting, MongoDB logs a warning regarding the use of the invalid certificate.net.ssl.allowInvalidCertificates
设置时,MongoDB会记录有关使用无效证书的警告。For more information about TLS/SSL and MongoDB, see Configure有关TLS/SSL和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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.allowInvalidHostnames
instead.net.tls.allowInvalidHostnames
。When当net.ssl.allowInvalidHostnames
istrue
, MongoDB disables the validation of the hostnames in TLS/SSL certificates, allowingmongod
to 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配置mongod
andmongos
for 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.disabledProtocols
instead.net.tls.disabledProtocols
。Prevents a MongoDB server running with TLS/SSL from accepting incoming connections that use a specific protocol or protocols. To specify multiple protocols, use a comma separated list of protocols.阻止使用TLS/SSL运行的MongoDB服务器接受使用特定协议的传入连接。要指定多个协议,请使用逗号分隔的协议列表。net.ssl.disabledProtocols
recognizes the following protocols:TLS1_0
,TLS1_1
,TLS1_2
, and starting in version 4.0.4 (and 3.6.9),TLS1_3
.net.ssl.disabledProtocols
可识别以下协议:TLS1_0
、TLS1_1
、TLS1_2
,以及从版本4.0.4(和3.6.9)开始的TLS1_3
。On macOS, you cannot disable在macOS上,不能禁用TLS1_1
and leave bothTLS1_0
andTLS1_2
enabled.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,请为none
tonet.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.FIPSMode
instead.net.tls.FIPSMode
。Enable or disable the use of the FIPS mode of the TLS/SSL library for the为mongos
ormongod
. Your system must have a FIPS compliant library to use thenet.ssl.FIPSMode
option.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指定用于此mongod
ormongos
instance and:mongod
或mongos
实例与以下对象之间通信的默认压缩器:other members of the deployment if the instance is part of a replica set or a sharded cluster部署的其他成员(如果实例是副本集或分片集群的一部分)mongosh
drivers that support the支持OP_COMPRESSED
message format.OP_COMPRESSED
消息格式的驱动程序。
MongoDB supports the following compressors:MongoDB支持以下压缩器:- snappy
- zlib
(Available starting in MongoDB 3.6)(从MongoDB 3.6开始提供) - zstd
(Available starting in MongoDB 4.2)(从MongoDB 4.2开始提供)
In versions 3.6 and 4.0,在3.6和4.0版本中,mongod
andmongos
enable network compression by default withsnappy
as the compressor.mongod
和mongos
默认启用网络压缩,并使用snappy
作为压缩器。Starting in version 4.2,从4.2版本开始,mongod
andmongos
instances default to bothsnappy,zstd,zlib
compressors, 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例如,如果mongosh
specifies the following network compressorszlib,snappy
and themongod
specifiessnappy,zlib
, messages betweenmongosh
andmongod
useszlib
.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例如,如果mongosh
specifies the network compressorzlib
andmongod
specifiessnappy
, messages betweenmongosh
andmongod
are 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实例使用该共享机密在分片集群或副本集中相互验证。keyFile
impliessecurity.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描述keyFile
Use a keyfile for authentication. Accept only keyfiles.使用键文件进行身份验证。仅接受关键文件。sendKeyFile
For rolling upgrade purposes. Send a keyfile for authentication but can accept both keyfiles and x.509 certificates.用于滚动升级。发送键文件进行身份验证,但可以接受键文件和x.509证书。sendX509
For rolling upgrade purposes. Send the x.509 certificate for authentication but can accept both keyfiles and x.509 certificates.用于滚动升级。发送x.509证书进行身份验证,但可以同时接受键文件和x.509证书。x509
Recommended. Send the x.509 certificate for authentication and accept only x.509 certificates.推荐。发送x.509证书进行身份验证,只接受x.509证书。If如果未指定--tlsCAFile
ortls.CAFile
is not specified and you are not using x.509 authentication, the system-wide CA certificate store will be used when connecting to an TLS-enabled server.--tlsCAFile
或tls.CAFile
,并且您未使用x.509身份验证,则在连接到启用TLS的服务器时将使用系统范围的CA证书存储。If using x.509 authentication,如果使用x.509身份验证,则必须指定--tlsCAFile
ortls.CAFile
must be specified unless using--tlsCertificateSelector
.--tlsCAFile
或tls.CAFile
,除非使用--tlsCertificateSelector
。For more information about TLS and MongoDB, see Configure有关TLS和MongoDB的更多信息,请参阅为TLS/SSL配置mongod
andmongos
for 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描述enabled
A user can access only the database resources and actions for which they have been granted privileges.用户只能访问被授予权限的数据库资源和操作。disabled
A user can access any database and perform any action.用户可以访问任何数据库并执行任何操作。See Role-Based Access Control for more information.有关详细信息,请参阅基于角色的访问控制。Thesecurity.authorization
setting is available only formongod
.security.authorization
设置仅适用于mongod
。
security.transitionToAuth
-
Type: boolean
Default: false
Allows the允许mongod
ormongos
to accept and create authenticated and non-authenticated connections to and from othermongod
andmongos
instances 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进行内部身份验证,mongod
ormongos
creates an authenticated connection with anymongod
ormongos
in the deployment using a matching keyfile.mongod
或mongos
将使用匹配的键文件创建与部署中的任何mongod
和mongos
的已验证连接。If the security mechanisms do not match, the如果安全机制不匹配,mongod
ormongos
utilizes a non-authenticated connection instead.mongod
或mongos
将使用未经身份验证的连接。A使用mongod
ormongos
running withsecurity.transitionToAuth
does 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使用内部身份验证而不使用mongod
ormongos
running with internal authentication and withoutsecurity.transitionToAuth
requires clients to connect using user access controls.security.transitionToAuth
运行的mongod
或mongos
要求客户端使用用户访问控制进行连接。Update clients to connect to the在没有mongod
ormongos
using the appropriate user prior to restartingmongod
ormongos
withoutsecurity.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代码的服务器端执行的操作,例如$where
query operator,mapReduce
command,$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.javascriptEnabled
is available for bothmongod
andmongos
.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使用mongod
ormongos
running withsecurity.redactClientLogData
redacts any message accompanying a given log event before logging.security.redactClientLogData
运行的mongod
或mongos
会在日志记录之前对给定日志事件附带的任何消息进行编辑。This prevents the这可以防止mongod
ormongos
from 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.redactClientLogData
in conjunction with Encryption at Rest and TLS/SSL (Transport Encryption) to assist compliance with regulatory requirements.security.redactClientLogData
与静态加密和TLS/SSL(传输加密)结合使用,有助于遵守法规要求。For example, a MongoDB deployment might store Personally Identifiable Information (PII) in one or more collections.例如,MongoDB部署可能将个人识别信息(PII)存储在一个或多个集合中。Themongod
ormongos
logs events such as those related to CRUD operations, sharding metadata, etc.mongod
或mongos
记录事件,例如与CRUD操作、分片元数据等相关的事件。It is possible that themongod
ormongos
may expose PII as a part of these logging operations.mongod
或mongos
可能会将PII作为这些日志操作的一部分进行公开。A使用mongod
ormongos
running withsecurity.redactClientLogData
removes any message accompanying these events before being output to the log, effectively removing the PII.security.redactClientLogData
运行的mongod
或mongos
会在将这些事件输出到日志之前删除伴随这些事件的任何消息,从而有效地删除PII。Diagnostics on a由于缺少与日志事件相关的数据,在使用mongod
ormongos
running withsecurity.redactClientLogData
may 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.redactClientLogData
on log output.security.redactClientLogData
对日志输出的影响的示例,请参阅进程日志记录手册页面。On a running在运行的mongod
ormongos
, usesetParameter
with theredactClientLogData
parameter 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
mongod
validates authentication requests from other members of the replica set and, if part of a sharded cluster, themongos
instances.)范围的列表,
mongod
根据该列表验证来自副本集其他成员的身份验证请求,如果是分片集群的一部分,则验证mongos
实例。Themongod
verifies that the originating IP is either explicitly in the list or belongs to a CIDR range in the list.mongod
验证始发IP是否明确在列表中,或者是否属于列表中的CIDR范围。If the IP address is not present, the server does not authenticate the如果IP地址不存在,则服务器不会对mongod
ormongos
.mongod
或mongos
进行身份验证。security.clusterIpSourceAllowlist
has no effect on amongod
started without authentication.security.clusterIpSourceAllowlist
对未经身份验证启动的mongod
没有影响。security.clusterIpSourceAllowlist
requires 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.clusterIpSourceAllowlist
includes the IP address or CIDR ranges that include the IP address of each replica set member ormongos
in the deployment to ensure healthy communication between cluster components.security.clusterIpSourceAllowlist
包括IP地址或CIDR范围,其中包括部署中每个副本集成员或mongos
的IP地址,以确保集群组件之间的通信正常。
security.clusterIpSourceWhitelist
-
Type: list
Deprecated in version 5.0:在版本5.0中已弃用:Use请改用security.clusterIpSourceAllowlist
instead.security.clusterIpSourceAllowlist
。A list of IP addresses/CIDR (Classless Inter-Domain RoutingIP地址/CIDR(无类别域间路由) ranges against which the
mongod
validates authentication requests from other members of the replica set and, if part of a sharded cluster, themongos
instances.)范围的列表,
mongod
根据该列表验证来自副本集其他成员的身份验证请求,如果是分片集群的一部分,则验证mongos
实例。Themongod
verifies that the originating IP is either explicitly in the list or belongs to a CIDR range in the list.mongod
验证始发IP是否明确在列表中,或者是否属于列表中的CIDR范围。If the IP address is not present, the server does not authenticate the如果IP地址不存在,则服务器不会对mongod
ormongos
.mongod
或mongos
进行身份验证。security.clusterIpSourceWhitelist
has no effect on a对未经身份验证启动的mongod
started without authentication.mongod
没有影响。security.clusterIpSourceWhitelist
requires specifying each IPv4/6 address or Classless Inter-Domain Routing (CIDR要求将每个IPv4/6地址或无类别域间路由(CIDR) range as a YAML list:
)范围指定为YAML列表:
security:
clusterIpSourceWhitelist:
- 192.0.2.0/24
- 127.0.0.1
- ::1ImportantEnsure确保security.clusterIpSourceWhitelist
includes the IP address or CIDR ranges that include the IP address of each replica set member ormongos
in the deployment to ensure healthy communication between cluster components.security.clusterIpSourceWhitelist
包括IP地址或CIDR范围,其中包括部署中每个副本集成员或mongos
的IP地址,以确保集群组件之间的通信正常。
Key Management Configuration Options键管理配置选项
security:
enableEncryption: <boolean>
encryptionCipherMode: <string>
encryptionKeyFile: <string>
kmip:
keyIdentifier: <string>
rotateMasterKey: <boolean>
serverName: <string>
port: <string>
clientCertificateFile: <string>
clientCertificatePassword: <string>
clientCertificateSelector: <string>
serverCAFile: <string>
connectRetries: <int>
connectTimeoutMS: <int>
activateKeys: <boolean>
keyStatePollingSeconds: <int>
security.enableEncryption
-
Type: boolean
Default: false
Enables encryption for the WiredTiger storage engine.为WiredTiger存储引擎启用加密。You must set to必须设置为true
to pass in encryption keys and configurations.true
才能传入加密键和配置。NoteEnterprise Feature企业功能Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。
security.encryptionCipherMode
-
Type: string
Default:
AES256-CBC
The cipher mode to use for encryption at rest:用于静态加密的密码模式:Mode Description描述AES256-CBC
256-bit Advanced Encryption Standard in Cipher Block Chaining Mode256位高级加密标准在密码块链接模式下的应用AES256-GCM
256-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.enableEncryption
to 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您只能在第一次为mongod
instance.mongod
实例启用加密时使用该设置。Requires要求security.enableEncryption
to 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.enableEncryption
to 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启动时,mongod
will attempt to establish a connection to each server in the order listed, and will select the first server to which it can successfully establish a connection. KMIP server selection occurs only at startup.mongod
将尝试按照列出的顺序建立与每个服务器的连接,并选择第一个可以成功建立连接的服务器。KMIP服务器选择仅在启动时发生。mongod
verifies the connection to the KMIP server on startup.在启动时验证与KMIP服务器的连接。The server name specified in在--kmipServerName
must match either the Subject Alternative NameSAN
or the Common NameCN
on the certificate presented by the KMIP server.--kmipServerName
中指定的服务器名称必须与KMIP服务器提供的证书上的使用者备用名称SAN
或公用名称CN
匹配。SAN
can be a system name or an IP address.可以是系统名称或IP地址。If如果存在SAN
is present,mongod
does not try to match againstCN
.SAN
,mongod
不会尝试与CN
进行匹配。If the hostname or IP address of the KMIP server does does not match either如果KMIP服务器的主机名或IP地址与SAN
orCN
,mongod
does 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.enableEncryption
to be true.security.kmip.serverName
。要求security.enableEncryption
为true
。If specifying multiple KMIP servers with如果使用security.kmip.serverName
, themongod
will use the port specified withsecurity.kmip.port
for 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的.pem
file used to authenticate MongoDB to the KMIP server..pem
文件的路径。The specified指定的.pem
file must contain both the TLS/SSL certificate and key..pem
文件必须同时包含TLS/SSL证书和键。To use this setting, you must also specify the若要使用此设置,还必须指定security.kmip.serverName
setting.security.kmip.serverName
设置。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.clientCertificateFile
and和security.kmip.clientCertificateSelector
options are mutually exclusive. You can only specify one.选项是相互排斥的。您只能指定一个。Specifies a certificate property in order to select a matching certificate from the operating system's certificate store to authenticate MongoDB to the KMIP server.指定一个证书属性,以便从操作系统的证书存储中选择一个匹配的证书,以向KMIP服务器验证MongoDB。security.kmip.clientCertificateSelector
accepts an argument of the format接受格式为<property>=<value>
where the property can be one of the following:<property>=<value>
的参数,其中该属性可以是以下内容之一:Property属性Value type值类型Description描述subject
ASCII string Subject name or common name on certificate证书上的使用者名称或通用名称thumbprint
hex string A sequence of bytes, expressed as hexadecimal, used to identify a public key by its SHA-1 digest.一种字节序列,用十六进制表示,用于通过SHA-1摘要识别公钥。
Thethumbprint
is 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与connectTimeoutMS
to control how long themongod
waits 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如果指定了connectRetries
setting is specified, themongod
will wait up to the value specified withconnectTimeoutMS
for each retry.connectRetries
设置,则mongod
将在每次重试时等待connectTimeoutMS
指定的值。Value must be值必须大于或等于1000
or 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.activateKeys
istrue
and you have existing keys on a KMIP server, the key must be activated first or themongod
node 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如果mongod
node will shut down unlesskmipActivateKeys
is 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
,mongod
uses 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中使用审核日志加密,必须在启动时指定auditEncryptKeyWithKMIPGet
at 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,请替换您的本地值,并在mongod
configuration 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只允许在启动时设置此选项。setParameter
can not change this setting.setParameter
无法更改此设置。This option is available only in MongoDB Enterprise.此选项仅在MongoDB Enterprise中可用。ImportantEnsure that your driver supports alternate service names. For确保您的驱动程序支持备用服务名称。要想让mongosh
and other MongoDB tools to connect to the newserviceName
, see thegssapiServiceName
option.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 themongod
ormongos
authenticates 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.servers
for listing every LDAP server in your infrastructure.security.ldap.servers
来列出基础结构中的每个LDAP服务器。This setting can be configured on a running可以使用mongod
ormongos
usingsetParameter
.setParameter
在正在运行的mongod
或mongos
上配置此设置。If unset,如果未设置,mongod
ormongos
cannot 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服务器上执行查询时,mongod
ormongos
binds 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必须将queryUser
withqueryPassword
.queryUser
与queryPassword
一起使用。If unset,如果未设置,mongod
ormongos
will not attempt to bind to the LDAP server.mongod
或mongos
将不会尝试绑定到LDAP服务器。This setting can be configured on a running可以使用mongod
ormongos
usingsetParameter
.setParameter
在正在运行的mongod
或mongos
上配置此设置。NoteWindows MongoDB deployments can useWindows MongoDB部署可以使用useOSDefaults
instead ofqueryUser
andqueryPassword
.useOSDefaults
而不是queryUser
和queryPassword
。You cannot specify both不能同时指定queryUser
anduseOSDefaults
at 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您必须将queryPassword
withqueryUser
.queryPassword
与queryUser
一起使用。If not set,如果未设置,mongod
ormongos
does not attempt to bind to the LDAP server.mongod
或mongos
不会尝试绑定到LDAP服务器。You can configure this setting on a running您可以使用mongod
ormongos
usingsetParameter
.setParameter
在正在运行的mongod
或mongos
上配置此设置。Starting in MongoDB 4.4, the从MongoDB 4.4开始,ldapQueryPassword
setParameter
command accepts either a string or an array of strings.ldapQueryPassword
setParameter
命令接受字符串或字符串数组。If如果ldapQueryPassword
is set to an array, MongoDB tries each password in order until one succeeds. Use a password array to roll over the LDAP account password without downtime.ldapQueryPassword
设置为数组,MongoDB会按顺序尝试每个密码,直到成功为止。使用密码数组可以在不停机的情况下滚动LDAP帐户密码。NoteWindows MongoDB deployments can useWindows MongoDB部署可以使用useOSDefaults
instead ofqueryUser
andqueryPassword
.useOSDefaults
而不是queryUser
和queryPassword
。You cannot specify both不能同时指定queryPassword
anduseOSDefaults
at 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允许mongod
ormongos
to 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使用useOSDefaults
to replacequeryUser
andqueryPassword
.useOSDefaults
替换queryUser
和queryPassword
。
security.ldap.bind.method
-
Type: string
Default: simple
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。The methodmongod
ormongos
uses to authenticate to an LDAP server.mongod
或mongos
用于向LDAP服务器进行身份验证的方法。Use with与queryUser
andqueryPassword
to connect to the LDAP server.queryUser
和queryPassword
一起使用可连接到LDAP服务器。method
supports the following values:支持以下值:simple
-mongod
ormongos
uses simple authentication.mongod
或mongos
使用简单的身份验证。sasl
-mongod
ormongos
uses 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机制。mongod
ormongos
defaults to usingDIGEST-MD5
mechanism.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 mechanismsmongod
ormongos
can use when authenticating to the LDAP server.mongod
或mongos
在向LDAP服务器进行身份验证时可以使用的SASL机制的逗号分隔列表。Themongod
ormongos
and the LDAP server must agree on at least one mechanism.mongod
或mongos
和LDAP服务器必须至少在一种机制上达成一致。Themongod
ormongos
dynamically 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在mongod
ormongos
host 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身份验证一起使用,请为GSSAPI
SASL mechanism for use with Kerberos Authentication, verify the following for themongod
ormongos
host machine:mongod
或mongos
主机验证以下内容:Linux
-
TheKRB5_CLIENT_KTNAME
environment variable resolves to the name of the client Linux Keytab Files for the host machine.KRB5_CLIENT_KTNAME
环境变量解析为主机的客户端Linux Keytab Files的名称。For more on Kerberos environment variables, please defer to the Kerberos documentation.有关Kerberos环境变量的更多信息,请参阅Kerberos文档。
The client keytab includes a User Principal for the客户端键选项卡包括一个用户主体,供mongod
ormongos
to use when connecting to the LDAP server and execute LDAP queries.mongod
或mongos
在连接到LDAP服务器并执行LDAP查询时使用。
Windows
If 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将useOSDefaults
totrue
to allowmongod
ormongos
to use the generated credentials when connecting to the Active Directory server and execute queries.useOSDefaults
设置为true
,以允许mongod
或mongos
在连接到活动目录服务器并执行查询时使用生成的凭据。
Set将method
tosasl
to 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,默认情况下,mongod
ormongos
creates 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.conf
file./etc/openldap/ldap.conf
文件中配置适当的TLS选项。Your operating system's package manager creates this file as part of the MongoDB Enterprise installation, via the您的操作系统的包管理器通过libldap
dependency.libldap
依赖关系将此文件创建为MongoDB Enterprise安装的一部分。See the documentation for有关更完整的说明,请参阅TLS Options
in the ldap.conf OpenLDAP documentationfor more complete instructions.
ldap.conf
OpenLDAP文档中的TLS选项文档。
For Windows deployment, you must add the LDAP server CA certificates to the Windows certificate management tool.对于Windows部署,必须将LDAP服务器CA证书添加到Windows证书管理工具中。The exact name and functionality of the tool may vary depending on operating system version.该工具的确切名称和功能可能因操作系统版本而异。Please see the documentation for your version of Windows for more information on certificate management.有关证书管理的详细信息,请参阅Windows版本的文档。Set将transportSecurity
tonone
to disable TLS/SSL betweenmongod
ormongos
and the LDAP server.transportSecurity
设置为none可禁用mongod
或mongos
与LDAP服务器之间的TLS/SSL。WarningSetting将transportSecurity
tonone
transmits plaintext information and possibly credentials betweenmongod
ormongos
and 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 millisecondsmongod
ormongos
should wait for an LDAP server to respond to a request.mongod
或mongos
应等待LDAP服务器响应请求的时间(以毫秒为单位)。Increasing the value of如果故障源是连接超时,那么增加timeoutMS
may prevent connection failure between the MongoDB server and the LDAP server, if the source of the failure is a connection timeout.timeoutMS
的值可以防止MongoDB服务器和LDAP服务器之间的连接故障。Decreasing the value of减少timeoutMS
reduces the time MongoDB waits for a response from the LDAP server.timeoutMS
的值可以减少MongoDB等待LDAP服务器响应的时间。This setting can be configured on a running可以使用mongod
ormongos
usingsetParameter
.setParameter
在正在运行的mongod
或mongos
上配置此设置。
security.ldap.retryCount
New in version 6.1.6.1版新增。Type: int
Default: 0
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。Number of operation retries by the server LDAP manager after a network error.网络错误后服务器LDAP管理器重试操作的次数。This setting can be configured on a running可以使用mongod
ormongos
usingsetParameter
.setParameter
在正在运行的mongod
或mongos
上配置此设置。
security.ldap.userToDNMapping
-
Type: string
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。Maps the username provided to将提供给mongod
ormongos
for authentication to a LDAP Distinguished Name (DN).mongod
或mongos
进行身份验证的用户名映射到LDAP可分辨名称(DN)。You may need to use在以下情况下,您可能需要使用userToDNMapping
to transform a username into an LDAP DN in the following scenarios:userToDNMapping
将用户名转换为LDAP DN:Performing LDAP authentication with simple LDAP binding, where users authenticate to MongoDB with usernames that are not full LDAP DNs.使用简单的LDAP绑定执行LDAP身份验证,其中用户使用非完整LDAP DN的用户名向MongoDB进行身份验证。Using an使用需要DN的LDAP授权查询模板。LDAP authorization query template
that 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以进行授权。
userToDNMapping
expects a quote-enclosed JSON-string representing an ordered array of documents.需要一个带引号的JSON字符串,该字符串表示文档的有序数组。Each document contains a regular expression每个文档都包含一个正则表达式匹配和一个用于转换传入用户名的match
and either asubstitution
orldapQuery
template 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示例match
An ECMAScript-formatted regular expression (regex) to match against a provided username.ECMAScript格式的正则表达式(regex)与提供的用户名匹配。Each parenthesis-enclosed section represents a regex capture group used by每个带括号的部分表示substitution
orldapQuery
.substitution
或ldapQuery
使用的regex捕获组。"(.+)ENGINEERING"
"(.+)DBA"
substitution
An LDAP distinguished name (DN) formatting template that converts the authentication name matched by theLDAP可分辨名称(DN)格式模板,用于将匹配正则表达式匹配的身份验证名称转换为LDAP DN。match
regex 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
match
regex.match
正则表达式从身份验证用户名中提取的相应正则表达式捕获组所替换。
The result of the substitution must be an RFC4514替换的结果必须是RFC4514escaped string.
转义字符串。
"cn={0},ou=engineering, dc=example,dc=com"
ldapQuery
A LDAP query formatting template that inserts the authentication name matched by theLDAP查询格式化模板,将match
regex 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
match
expression.所替换。
mongod
ormongos
executes the query against the LDAP server to retrieve the LDAP DN for the authenticated user.mongod
或mongos
对LDAP服务器执行查询,以检索经过身份验证的用户的LDAP DN。mongod
ormongos
requires exactly one returned result for the transformation to be successful, ormongod
ormongos
skips 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对于数组中的每个文档,必须使用substitution
orldapQuery
. You cannot specify both in the same document.substitution
或ldapQuery
。不能在同一文档中同时指定两者。When performing authentication or authorization,在执行身份验证或授权时,mongod
ormongos
steps through each document in the array in the given order, checking the authentication username against thematch
filter.mongod
或mongos
按给定顺序遍历数组中的每个文档,并根据匹配筛选器检查身份验证用户名。If a match is found,如果找到匹配项,mongod
ormongos
applies the transformation and uses the output for authenticating the user.mongod
或mongos
将应用转换并使用输出对用户进行身份验证。mongod
ormongos
does not check the remaining documents in the array.mongod
或mongos
不检查数组中的其余文档。If the given document does not match the provided authentication name,如果给定的文档与提供的身份验证名称不匹配,mongod
ormongos
continues 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,如果在任何文档中都找不到匹配项,或者文档描述的转换失败,mongod
ormongos
returns an error.mongod
或mongos
将返回错误。Starting in MongoDB 4.4,从MongoDB 4.4开始,如果其中一个转换由于LDAP服务器的网络或身份验证失败而无法评估,mongod
ormongos
also returns an error if one of the transformations cannot be evaluated due to networking or authentication failures to the LDAP server.mongod
或mongos
也会返回一个错误。mongod
ormongos
rejects the connection request and does not check the remaining documents in the array.mongod
或mongos
拒绝连接请求,并且不检查数组中的其余文档。Starting in MongoDB 5.0,从MongoDB 5.0开始,userToDNMapping
accepts 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.COM
matches 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.COM
matches 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)"
.mongod
ormongos
executes this query against the LDAP server, returning the result"cn=bob,ou=dba,dc=example,dc=com"
.If
userToDNMapping
is unset,mongod
ormongos
applies no transformations to the username when attempting to authenticate or authorize a user against the LDAP server.This setting can be configured on a running
mongod
ormongos
using thesetParameter
database command.
security.ldap.authz.queryTemplate
-
Type: string
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。A relative LDAP query URL formatted conforming to RFC4515
and RFC4516
that
mongod
executes to obtain the LDAP groups to which the authenticated user belongs to. The query is relative to the host or hosts specified insecurity.ldap.servers
.In the URL, you can use the following substitution tokens:在URL中,您可以使用以下替换令牌:Substitution Token Description描述{USER}
Substitutes the authenticated username, or the transformed
username if auserToDNMapping
is 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,如果您的查询包含一个属性,mongod
assumes that the query retrieves a list of the DNs which this entity is a member of.mongod
假设该查询检索该实体所属的DN列表。If your query does not include an attribute,如果您的查询不包括属性,mongod
assumes the query retrieves all entities which the user is member of.mongod
假设查询检索用户所属的所有实体。For each LDAP DN returned by the query,对于查询返回的每个LDAP DN,mongod
assigns the authorized user a corresponding role on theadmin
database.mongod
在admin
数据库中为授权用户分配相应的角色。If a role on the on the如果admin
database exactly matches the DN,mongod
grants the user the roles and privileges assigned to that role.admin
数据库上的角色与DN完全匹配,mongod
将向用户授予分配给该角色的角色和权限。See the有关创建角色的更多信息,请参阅db.createRole()
method for more information on creating roles.db.createRole()
方法。ExampleThis LDAP query returns any groups listed in the LDAP user object's此LDAP查询返回LDAP用户对象的memberOf
attribute.memberOf
属性中列出的任何组。"{USER}?memberOf?base"
Your LDAP configuration may not include theLDAP配置可能不包括memberOf
attribute as part of the user schema, may possess a different attribute for reporting group membership, or may not track group membership through attributes. Configure your query with respect to your own unique LDAP configuration.memberOf
属性作为用户架构的一部分,可能拥有用于报告组成员身份的不同属性,或者可能不通过属性跟踪组成员身份。根据您自己的唯一LDAP配置配置查询。If unset,如果未设置,mongod
cannot authorize users using LDAP.mongod
将无法使用LDAP对用户进行授权。This setting can be configured on a running可以使用mongod
using thesetParameter
database command.setParameter
数据库命令在正在运行的mongod
上配置此设置。
security.ldap.validateLDAPServerConfig
-
Type: boolean
Default: true
Available in MongoDB Enterprise在MongoDB Enterprise中可用A flag that determines if the一个标志,用于确定mongod
ormongos
instance checks the availability of theLDAP server(s)
as part of its startup:mongod
或mongos
实例是否在启动时检查LDAP服务器的可用性:If如果为true
, themongod
ormongos
instance performs the availability check and only continues to start up if the LDAP server is available.true
,mongod
或mongos
实例将执行可用性检查,并且只有在LDAP服务器可用时才会继续启动。If如果为false
, themongod
ormongos
instance 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例如,要在配置文件中指定enableLocalhostAuthBypass
in the configuration file:enableLocalhostAuthBypass
:setParameter:
enableLocalhostAuthBypass: false
LDAP ParametersLDAP参数
setParameter.ldapUserCacheInvalidationInterval
-
Type: int
Default: 30
For use with用于使用LDAP授权的mongod
servers using LDAP Authorization.mongod
服务器。The interval (in seconds)外部用户缓存刷新之间的间隔时间(以秒为单位)。mongod
waits between external user cache flushes.Aftermongod
flushes the external user cache, MongoDB reacquires authorization data from the LDAP server the next time an LDAP-authorized user issues an operation.mongod
刷新外部用户缓存后,下次LDAP授权用户发出操作时,MongoDB会从LDAP服务器重新获取授权数据。Increasing the value specified increases the amount of time增加指定的值会增加mongod
and the LDAP server can be out of sync, but reduces the load on the LDAP server.mongod
和LDAP服务器可能不同步的时间,但会减少LDAP服务器上的负载。Conversely, decreasing the value specified decreases the time相反,减少指定的值会减少时间间隔,并且LDAP服务器可能不同步,同时增加LDAP服务器上的负载。mongod
and 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.enabled
option and the corresponding--journal
and--nojournal
command-line options.storage.journal.enabled
选项以及相应的--journal
和--nojournal
命令行选项。
Changed in version 4.4:4.4版更改:
MongoDB removes theMongoDB删除了storage.indexBuildRetry
option and the corresponding--noIndexBuildRetry
command-line option.storage.indexBuildRetry
选项和相应的--noIndexBuildRetry
命令行选项。MongoDB deprecatesMongoDB弃用storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB
option.storage.wiredTiger.engineConfig.maxCacheOverflowFileSizeGB
选项。The option has no effect starting in MongoDB 4.4.该选项在MongoDB 4.4中启动时没有任何效果。
storage:
dbPath: <string>
journal:
commitIntervalMs: <num>
directoryPerDB: <boolean>
syncPeriodSecs: <int>
engine: <string>
wiredTiger:
engineConfig:
cacheSizeGB: <number>
journalCompressor: <string>
directoryForIndexes: <boolean>
maxCacheOverflowFileSizeGB: <number> // deprecated in MongoDB 4.4
collectionConfig:
blockCompressor: <string>
indexConfig:
prefixCompression: <boolean>
inMemory:
engineConfig:
inMemorySizeGB: <number>
oplogMinRetentionHours: <double>
storage.dbPath
-
Type: string
Default:
/data/db
on Linux and macOS\data\db
on Windows
The directory where themongod
instance stores its data.mongod
实例存储其数据的目录。Thestorage.dbPath
setting is available only formongod
.storage.dbPath
设置仅适用于mongod
。NoteConfiguration Files配置文件The default包管理器安装中包含的默认mongod.conf
configuration file included with package manager installations uses the following platform-specific default values forstorage.dbPath
:mongod.conf
配置文件使用以下特定于平台的storage.dbPath
默认值:Platform Package Manager程序包管理器Default storage.dbPath
RHEL / CentOS and Amazon yum
/var/lib/mongo
SUSE zypper
/var/lib/mongo
Ubuntu and Debian apt
/var/lib/mongodb
macOS brew
/usr/local/var/mongodb
The Linux package init scripts do not expectLinux包init脚本不希望storage.dbPath
to 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 themongod
process allows between journal operations.mongod
进程在日志操作之间允许的最大时间(以毫秒为单位)。Values can range from 1 to 500 milliseconds.值的范围可以是1到500毫秒。Lower values increase the durability of the journal, at the expense of disk performance.较低的值会以牺牲磁盘性能为代价,提高日志的持久性。On WiredTiger, the default journal commit interval is 100 milliseconds.在WiredTiger上,默认的日志提交间隔为100毫秒。Additionally, a write that includes or implies此外,包含或暗示j:true
will cause an immediate sync of the journal.j:true
的写入将导致日志的立即同步。For details or additional conditions that affect the frequency of the sync, see Journaling Process.有关影响同步频率的详细信息或其他条件,请参阅日志处理。Thestorage.journal.commitIntervalMs
setting is available only formongod
.storage.journal.commitIntervalMs
设置仅适用于mongod
。Not available for不适用于使用内存中存储引擎的mongod
instances that use the in-memory storage engine.mongod
实例。NoteKnown Issue in 4.2.0: The4.2.0中的已知问题:4.2.0中缺少storage.journal.commitIntervalMs
is 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.dbPath
directory, and each subdirectory name corresponds to the database name.storage.dbPath
目录下,每个子目录名称都与数据库名称相对应。Thestorage.directoryPerDB
setting is available only formongod
.storage.directoryPerDB
设置仅适用于mongod
。Not available for不适用于使用内存中存储引擎的mongod
instances that use the in-memory storage engine.mongod
实例。Starting in MongoDB 5.0, dropping the final collection in a database (or dropping the database itself) when从MongoDB 5.0开始,在启用storage.directoryPerDB
is enabled deletes the newly empty subdirectory for that database.storage.directoryPerDB
时,删除数据库中的最终集合(或删除数据库本身)会删除该数据库的新空子目录。To change the要更改现有部署的storage.directoryPerDB
option for existing deployments:storage.directoryPerDB
选项,请执行以下操作:For standalone instances:对于独立实例:Use对现有mongodump
on the existingmongod
instance to generate a backup.mongod
实例使用mongodump
生成备份。Stop the停止mongod
instance.mongod
实例。Add the添加storage.directoryPerDB
value and configure a new data directorystorage.directoryPerDB
值并配置新的数据目录Restart the重新启动mongod
instance.mongod
实例。Use使用mongorestore
to populate the new data directory.mongorestore
填充新的数据目录。
For replica sets:对于复制副本集:Stop a secondary member.停止辅助成员。Add the添加storage.directoryPerDB
value 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.syncPeriodSecs
to0
, MongoDB will not sync the memory mapped files to disk.storage.syncPeriodSecs
设置为0
,MongoDB将不会将内存映射文件同步到磁盘。Themongod
process writes data very quickly to the journal and lazily to the data files.mongod
进程非常快速地将数据写入日志,并缓慢地写入数据文件。storage.syncPeriodSecs
has no effect on Journaling, but if对日志记录没有影响,但如果storage.syncPeriodSecs
is set to0
the journal will eventually consume all available disk space.storage.syncPeriodSecs
设置为0
,则日志记录最终将消耗所有可用磁盘空间。Thestorage.syncPeriodSecs
setting is available only formongod
.storage.syncPeriodSecs
设置仅适用于mongod
。Not available for不适用于使用内存中存储引擎的mongod
instances that use the in-memory storage engine.mongod
实例。
storage.engine
-
Default:
wiredTiger
NoteStarting in version 4.2, MongoDB removes the deprecated MMAPv1 storage engine.从4.2版本开始,MongoDB删除了不推荐使用的MMAPv1存储引擎。The storage engine for themongod
database. Available values include:mongod
数据库的存储引擎。可用值包括:Value值Description描述wiredTiger
To specify the WiredTiger Storage Engine.指定WiredTiger存储引擎。inMemory
To specify the In-Memory Storage Engine.指定内存中存储引擎。
Available in MongoDB Enterprise only.仅在MongoDB Enterprise中可用。
If you attempt to start a如果您尝试使用mongod
with astorage.dbPath
that contains data files produced by a storage engine other than the one specified bystorage.engine
,mongod
will refuse to start.storage.dbPath
启动mongod
,该storage.engine
包含存储引擎(而不是storage.engine
指定的存储引擎)生成的数据文件,mongod
将拒绝启动。
storage.oplogMinRetentionHours
-
Type: double
New in version 4.4:4.4版新增:Specifies the minimum number of hours to preserve an oplog entry, where the decimal values represent the fractions of an hour.指定保留操作日志项的最小小时数,其中十进制值表示小时的小数。For example, a value of例如,值1.5
represents one hour and thirty minutes.1.5
表示一小时三十分钟。The value must be greater than or equal to该值必须大于或等于0
.0
。A value of值0
indicates that themongod
should truncate the oplog starting with the oldest entries to maintain the configured maximum oplog size.0
表示mongod
应该从最旧的条目开始截断oplog,以保持配置的最大oplog大小。Defaults to默认值为0。0
.A以mongod
started withoplogMinRetentionHours
only removes an oplog entry if:oplogMinRetentionHours
开头的mongod
仅在以下情况下删除oplog条目:The oplog has reached the maximum configured oplog size andoplog已达到配置的最大oplog大小,并且The oplog entry is older than the configured number of hours based on the host system clock.oplog条目早于基于主机系统时钟配置的小时数。
The当配置了最短oplog保留期时,mongod
has 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恢复到其最大大小或配置为更小的最大大小,mongod
may continue to hold that disk space even if the oplog returns to its maximum size or is configured for a smaller maximum size.mongod
也可能继续保留该磁盘空间。See Reducing Oplog Size Does Not Immediately Return Disk Space.请参阅减少操作日志大小不会立即返回磁盘空间。Themongod
compares the system wall clock to an oplog entries creation wall clock time when enforcing oplog entry retention. Clock drift between cluster components may result in unexpected oplog retention behavior.mongod
在强制执行oplog条目保留时,将系统墙时钟与oplog条目创建墙时钟时间进行比较。集群组件之间的时钟漂移可能会导致意外的oplog保留行为。See Clock Synchronization for more information on clock synchronization across cluster members.有关集群成员间时钟同步的详细信息,请参阅时钟同步。
To change the minimum oplog retention period after starting the要在启动mongod
, usereplSetResizeOplog
.mongod
后更改oplog的最小保留期,请使用replSetResizeOplog
。replSetResizeOplog
enables you to resize the oplog dynamically without restarting the使您能够在不重新启动mongod
process.mongod
进程的情况下动态调整oplog的大小。To persist the changes made using要在重新启动时保持使用replSetResizeOplog
through a restart, update the value 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.25
GB to10000
GB.Starting in MongoDB 3.4, the default WiredTiger internal cache size is the larger of either:从MongoDB 3.4开始,默认的WiredTiger内部缓存大小是以下两者中较大的一个:- 50% of (RAM - 1 GB), or
- 256 MB.
For example, on a system with a total of 4GB of RAM the WiredTiger cache will use 1.5GB of RAM (例如,在总内存为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.cacheSizeGB
limits the size of the WiredTiger internal cache.storage.wiredTiger.engineConfig.cacheSizeGB
限制了WiredTiger内部缓存的大小。The operating system will use the available free memory for filesystem cache, which allows the compressed MongoDB data files to stay in memory. In addition, the operating system will use any free RAM to buffer file system blocks and file system cache.操作系统将使用可用的空闲内存进行文件系统缓存,这允许压缩的MongoDB数据文件留在内存中。此外,操作系统将使用任何空闲的RAM来缓冲文件系统块和文件系统缓存。To accommodate the additional consumers of RAM, you may have to decrease WiredTiger internal cache size.为了容纳更多的RAM消耗者,您可能需要减小WiredTiger内部缓存的大小。The default WiredTiger internal cache size value assumes that there is a single默认的WiredTiger内部缓存大小值假定每台机器有一个mongod
instance per machine.mongod
实例。If a single machine contains multiple MongoDB instances, then you should decrease the setting to accommodate the other如果一台机器包含多个MongoDB实例,那么应该减少设置以容纳其他mongod
instances.mongod
实例。If you run如果在无法访问系统中所有可用RAM的容器(例如mongod
in a container (e.g.lxc
,cgroups
, Docker, etc.) that does not have access to all of the RAM available in a system, you must setstorage.wiredTiger.engineConfig.cacheSizeGB
to 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.directoryForIndexes
istrue
,mongod
stores indexes and collections in separate subdirectories under the data (i.e.storage.dbPath
) directory.storage.wiredTiger.engineConfig.directoryForIndexes
为true
时,mongod
将索引和集合存储在data(即storage.dbPath
)目录下的单独子目录中。Specifically,具体来说,mongod
stores the indexes in a subdirectory namedindex
and 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具体地说,当mongod
instance is not running, move theindex
subdirectory to the destination and create a symbolic link namedindex
under 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.maxCacheOverflowFileSizeGB
option.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.wt
for MongoDB 4.2.1-4.2.x and 4.0.12-4.0.x. The file no longer exists starting in version 4.4.WiredTigerLAS.wt
的最大大小(以GB为单位)。该文件从4.4版开始不再存在。The setting can accept the following values:该设置可以接受以下值:Value值Description描述0
The default value.默认值。If set to如果设置为0
, the file size is unbounded.0
,则文件大小是无限制的。number >= 0.1 The maximum size (in GB).最大大小(以GB为单位)。If the如果WiredTigerLAS.wt
file exceeds this size,mongod
exits with a fatal assertion.WiredTigerLAS.wt
文件超过此大小,mongod
将退出并发出致命断言。You can clear the您可以清除WiredTigerLAS.wt
file and restartmongod
.WiredTigerLAS.wt
文件并重新启动mongod
。To change the maximum size during runtime, use the要在运行时更改最大大小,请使用wiredTigerMaxCacheOverflowSizeGB
parameter.wiredTigerMaxCacheOverflowSizeGB
参数。Available starting in MongoDB 4.2.1 (and 4.0.12)从MongoDB 4.2.1(和4.0.12)开始提供
storage.wiredTiger.engineConfig.zstdCompressionLevel
-
Type: integer
Default: 6
Specifies the level of compression applied when using the zstd compressor.指定使用zstd压缩器时应用的压缩级别。Values can range from 1 to 22.值的范围从1到22。The higher the specified value forzstdCompressionLevel
the higher the compression which is applied.zstdCompressionLevel
的指定值越高,应用的压缩就越高。Only applicable when仅当blockCompressor
is 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.blockCompressor
affects all collections created.影响所有创建的集合。If you change the value of如果更改现有MongoDB部署上storage.wiredTiger.collectionConfig.blockCompressor
on an existing MongoDB deployment, all new collections will use the specified compressor. Existing collections will continue to use the compressor specified when they were created, or the default compressor at that time.storage.wiredTiger.collectionConfig.blockCompressor
的值,则所有新集合都将使用指定的压缩器。现有集合将继续使用创建时指定的压缩器,或当时的默认压缩器。
storage.wiredTiger.indexConfig.prefixCompression
-
Default: true
Enables or disables prefix compression for index data.启用或禁用索引数据的前缀压缩。Specify为true
forstorage.wiredTiger.indexConfig.prefixCompression
to enable prefix compression for index data, orfalse
to disable prefix compression for index data.storage.wiredTiger.indexConfig.prefixCompression
指定true
可启用索引数据的前缀压缩,或为false
可禁用索引数据的后缀压缩。Thestorage.wiredTiger.indexConfig.prefixCompression
setting affects all indexes created.storage.wiredTiger.indexConfig.prefixCompression
设置会影响所有创建的索引。If you change the value of如果在现有MongoDB部署上更改storage.wiredTiger.indexConfig.prefixCompression
on 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(如果mongod
is 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:
off
Specifies which operations should be profiled. The following profiler levels are available:指定应探查哪些操作。以下探查器级别可用:Level Description描述off
The profiler is off and does not collect any data. This is the default profiler level.探查器已关闭,不集合任何数据。这是默认的探查器级别。slowOp
The profiler collects data for operations that take longer than the value of探查器为耗时超过slowms
.slowms
值的操作集合数据。all
The 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当logLevel
is set to0
, MongoDB records slow operations to the diagnostic log at a rate determined byslowOpSampleRate
.logLevel
设置为0时,MongoDB会以slowOpSampleRate
确定的速率将慢速操作记录到诊断日志中。At higher在更高的logLevel
settings, all operations appear in the diagnostic log regardless of their latency with the following exception: the logging of slow oplog entry messages by the secondaries.logLevel
设置下,所有操作都会显示在诊断日志中,无论其延迟如何,但以下情况除外:由secondary记录慢速操作日志条目消息。The secondaries log only the slow oplog entries; increasing the辅助设备只记录慢速操作日志条目;增加logLevel
does not log all oplog entries.logLevel
不会记录所有oplog条目。This setting is available for此设置可用于mongod
andmongos
.mongod
和mongos
。For对于mongod
instances, the setting affects both the diagnostic log and, if enabled, the profiler.mongod
实例,该设置会影响诊断日志,如果启用,还会影响探查器。For对于mongos
instances, the setting affects the diagnostic log only and not the profiler, since profiling is not available onmongos
.mongos
实例,该设置仅影响诊断日志,而不影响探查器,因为在mongos
上无法进行探查。
operationProfiling.slowOpSampleRate
-
Type: double
Default: 1.0
The fraction of slow operations that should be profiled or logged.应该对慢速操作进行分析或记录的部分。operationProfiling.slowOpSampleRate
accepts values between 0 and 1, inclusive.接受0和1之间的值(包括0和1)。Changed in version 4.0:4.0版更改:TheslowOpSampleRate
setting is available formongod
andmongos
.slowOpSampleRate
设置可用于mongod
和mongos
。In earlier versions,在早期版本中,slowOpSampleRate
is available formongod
only.slowOpSampleRate
仅适用于mongod
。For对于mongod
instances, the setting affects both the diagnostic log and, if enabled, the profiler.mongod
实例,该设置会影响诊断日志,如果启用,还会影响探查器。For对于mongos
instances, the setting affects the diagnostic log only and not the profiler since profiling is not available onmongos
.mongos
实例,该设置仅影响诊断日志,而不影响探查器,因为在mongos
上无法进行探查。
operationProfiling.filter
-
Type
: string representation of a query document:查询文档的字符串表示A filter expression that controls which operations are profiled and logged.一个筛选器表达式,用于控制对哪些操作进行分析和记录。When设置filter
is set,slowOpThresholdMs
andslowOpSampleRate
are 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例如,以下filter
configures the profiler to logquery
operations that take longer than 2 seconds:filter
将探查器配置为记录耗时超过2秒的查询操作:operationProfiling:
mode: all
filter: '{ op: "query", millis: { $gt: 2000 } }'New in version 4.4.2.4.4.2版新增。
replication
Options
replication:
oplogSizeMB: <int>
replSetName: <string>
enableMajorityReadConcern: <boolean>
replication.oplogSizeMB
-
Type: integer
The maximum size in megabytes for the replication operation log (i.e., the oplog).复制操作日志(即oplog)的最大大小(MB)。NoteThe oplog can grow past its configured size limit to avoid deleting theoplog可以超过其配置的大小限制,以避免删除majority commit point
.majority commit point
多数提交点。By default, the默认情况下,mongod
process 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一旦mongod
has created the oplog for the first time, changing thereplication.oplogSizeMB
option will not affect the size of the oplog.mongod
第一次创建了oplog,更改replication.oplogSizeMB
选项将不会影响oplog的大小。To change the maximum oplog size after starting the要在启动mongod
, usereplSetResizeOplog
.mongod
后更改最大操作日志大小,请使用replSetResizeOplog
。replSetResizeOplog
enables you to resize the oplog dynamically without restarting the使您能够在不重新启动mongod
process.mongod
进程的情况下动态调整oplog的大小。To persist the changes made using要在重新启动时保持使用replSetResizeOplog
through a restart, update the value ofoplogSizeMB
.replSetResizeOplog
所做的更改,请更新oplogSizeMB
的值。See Oplog Size for more information.有关详细信息,请参阅操作日志大小。Thereplication.oplogSizeMB
setting is available only formongod
.replication.oplogSizeMB
设置仅适用于mongod
。
replication.replSetName
-
Type: string
The name of the replica set that themongod
is part of.mongod
所属的复制集的名称。All hosts in the replica set must have the same set name.复制副本集中的所有主机都必须具有相同的集名称。If your application connects to more than one replica set, each set must have a distinct name. Some drivers group replica set connections by replica set name.如果应用程序连接到多个复制副本集,则每个复制副本集都必须具有不同的名称。某些驱动程序按副本集名称对副本集连接进行分组。Thereplication.replSetName
setting is available only formongod
.replication.replSetName
设置仅可用于mongod
。Starting in MongoDB 4.0:从MongoDB 4.0开始:The setting设置replication.replSetName
cannot 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开始,enableMajorityReadConcern
cannot be changed and is always set totrue
. Attempting to start a storage engine that does not support majority read concern with the--enableMajorityReadConcern
option will fail and return an error message.enableMajorityReadConcern
不能更改,并且始终设置为true
。尝试使用--enableMajorityReadConcern
选项启动不支持多数读取关注的存储引擎将失败,并返回错误消息。In earlier versions of MongoDB,在MongoDB的早期版本中,enableMajorityReadConcern
was 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 themongod
instance has in the sharded cluster. Set this setting to one of the following:mongod
实例在分片集群中的角色。将此设置设置为以下其中一项:Value值Description描述configsvr
Start this instance as a config server.将此实例作为配置服务器启动。The instance starts on port默认情况下,实例在端口27019
by default.27019
上启动。
When you configure a MongoDB instance as clusterRole当您将MongoDB实例配置为clusterRoleconfigsvr
you must also specify areplSetName
.configsvr
时,还必须指定replSetName
。shardsvr
Start this instance as a shard.将此实例作为分片启动。The instance starts on port默认情况下,实例在端口27018
by default.27018
上启动。
When you configure a MongoDB instance as a a clusterRole当您将MongoDB实例配置为clusterRoleshardsvr
you must also specify areplSetName
.shardsvr
时,还必须指定replSetName
。NoteSetting设置sharding.clusterRole
requires themongod
instance to be running with replication.sharding.clusterRole
需要mongod
实例与复制一起运行。To deploy the instance as a replica set member, use the要将实例部署为副本集成员,请使用replSetName
setting and specify the name of the replica set.replSetName
设置并指定副本集的名称。Thesharding.clusterRole
setting 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.auditEncryptionKeyIdentifier
andauditLog.localAuditKeyFile
together.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.auditEncryptionKeyIdentifier
orauditLog.localAuditKeyFile
.auditLog.auditEncryptionKeyIdentifier
或auditLog.localAuditKeyFile
启用审核日志加密。auditLog.compressionMode
can be set to one of these values:可以设置为以下值之一:Value值Description描述zstd
Use 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.destination
enables auditing and specifies wheremongos
ormongod
sends all audit events.auditLog.destination
将启用审核,并指定mongos
或mongod
发送所有审核事件的位置。auditLog.destination
can have one of the following values:可以具有以下值之一:Value值Description描述syslog
Output the audit events to syslog in JSON format. Not available on Windows.以JSON格式将审核事件输出到syslog。在Windows上不可用。Audit messages have a syslog severity level of审核消息的系统日志严重性级别为info
and a facility level 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.审计系统既不会检测到截断,也不会在出现错误时检测到。console
Output the audit events to以JSON格式将审核事件输出到stdout
in JSON format.stdout
。file
Output the audit events to the file specified in将审核事件以auditLog.path
in 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如果目标是destination
isfile
.file
,则用于审核的输出文件的格式。TheauditLog.format
option can have one of the following values:auditLog.format
选项可以具有以下值之一:Value值Description描述JSON
Output the audit events in JSON format to the file specified in将审核事件以JSON格式输出到auditLog.path
.auditLog.path
中指定的文件。BSON
Output 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.localAuditKeyFile
for testing because the key is not secured.auditLog.localAuditKeyFile
进行测试。To secure the key, use要保护键,请使用auditLog.auditEncryptionKeyIdentifier
and an external Key Management Interoperability Protocol (KMIP) server.auditLog.auditEncryptionKeyIdentifier
和外部键管理互操作性协议(KMIP)服务器。You cannot use不能同时使用auditLog.localAuditKeyFile
andauditLog.auditEncryptionKeyIdentifier
together.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如果destination
has value offile
.destination
的值为file,则用于审核的输出文件。TheauditLog.path
option can take either a full path name or a relative path name.auditLog.path
选项可以采用完整路径名,也可以采用相对路径名。
auditLog.runtimeConfiguration
-
Type: boolean
Specifies if a node allows runtime configuration of audit filters and the auditAuthorizationSuccess variable.指定节点是否允许运行时配置审核筛选器和auditAuthenticationSuccess变量。If如果为true
the node can take part in Online Audit Filter Management.true
,则节点可以参与联机审核筛选器管理。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, thatmongos
uses to determine which secondary replica set members to pass read operations from clients.mongos
用于确定从客户端传递读取操作的辅助副本集成员的ping时间(以毫秒为单位)。The default value of默认值15对应于所有客户端驱动程序中的默认值。15
corresponds to the default value in all of the client drivers.When当mongos
receives a request that permits reads to secondary members, themongos
will:mongos
收到允许secondary成员读取的请求时,mongos
将:Find the member of the set with the lowest ping time.查找ping时间最低的集合中的成员。Construct a list of replica set members that is within a ping time of 15 milliseconds of the nearest suitable member of the set.构造副本集成员的列表,该列表位于该集最近的合适成员的ping时间(15毫秒)内。If you specify a value for the如果为replication.localPingThresholdMs
option,mongos
will construct the list of replica members that are within the latency allowed by this value.replication.localPingThresholdMs
选项指定一个值,mongos
将构造在该值允许的延迟内的副本成员的列表。Select a member to read from at random from this list.从该列表中随机选择一个成员进行阅读。
The ping time used for a member compared by the由replication.localPingThresholdMs
setting is a moving average of recent ping times, calculated at most every 10 seconds.replication.localPingThresholdMs
设置比较的成员使用的ping时间是最近ping时间的移动平均值,最多每10秒计算一次。As a result, some queries may reach members above the threshold until the因此,一些查询可能会到达阈值以上的成员,直到mongos
recalculates the 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分片集群的mongos
instances for the sharded cluster must specify the same config server replica set name but can specify hostname and port of different members of the replica set.mongos
实例必须指定相同的配置服务器副本集名称,但可以指定副本集不同成员的主机名和端口。
Windows Service Options
processManagement:
windowsService:
serviceName: <string>
displayName: <string>
description: <string>
serviceUser: <string>
servicePassword: <string>
processManagement.windowsService.serviceName
-
Type: string
Default: MongoDB
The service name of作为Windows服务运行时mongos
ormongod
when 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.serviceName
in conjunction with either the--install
or--remove
option.processManagement.windowsService.serviceName
与--install
或--remove
选项结合使用。
processManagement.windowsService.displayName
-
Type: string
Default: MongoDB
The name listed for MongoDB on the Services administrative application.服务管理应用程序上为MongoDB列出的名称。
processManagement.windowsService.description
-
Type: string
Default: MongoDB Server
Run运行mongos
ormongod
service description.mongos
或mongod
服务描述。You must use必须将processManagement.windowsService.description
in conjunction with the--install
option.processManagement.windowsService.description
与--install
选项结合使用。For descriptions that contain spaces, you must enclose the description in quotes.对于包含空格的说明,必须将说明用引号括起来。
processManagement.windowsService.serviceUser
-
Type: string
The某个用户上下文中的mongos
ormongod
service in the context of a certain user. This user must have "Log on as a service" privileges.mongos
或mongod
服务。此用户必须具有“作为服务登录”权限。You must use必须将processManagement.windowsService.serviceUser
in conjunction with the--install
option.processManagement.windowsService.serviceUser
与--install
选项结合使用。
processManagement.windowsService.servicePassword
-
Type: string
The password for当使用<user>
formongos
ormongod
when running with theprocessManagement.windowsService.serviceUser
option.processManagement.windowsService.serviceUser
选项运行时,mongos
或mongod
的<user>
的密码。You must use必须将processManagement.windowsService.servicePassword
in conjunction with the--install
option.processManagement.windowsService.servicePassword
与--install
选项结合使用。
Removed MMAPv1 Options
Starting in version 4.2, MongoDB removes the deprecated MMAPv1 storage engine and the MMAPv1-specific configuration options:从4.2版本开始,MongoDB删除了不推荐使用的MMAPv1存储引擎和MMAPv1特定的配置选项:
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:例如: