Configuration File(配置文件) Core Options(核心設置) mongos-only Options(mongo單獨設置) Windows Service Options(windows系統設置) Configuration File File Format You can ...
Configuration File(配置文件)
File Format(文件格式)
Use the Configuration File(使用配置文件)
Core Options(核心設置)
systemLog Options(系統log設置)
processManagement Options(進程管理設置)
net Options(網路設置)
security Options(安全設置)
setParameter Option(自定義參數設置)
storage Options(存儲設置)
operationProfiling Options(性能設置)
replication Options(複製集設置)
sharding Options(分片設置)
auditLog Options()
snmp Options()
Text Search Options(文本搜索設置)
mongos-only Options(mongo單獨設置)
Windows Service Options(windows系統設置)
Configuration File
File Format
You can configure mongod and mongos instances at startup using a configuration file. The configuration file contains settings that are equivalent to the mongod and mongos command-line options.
Using a configuration file makes managing mongod and mongos options easier, especially for large-scale deployments. You can also add comments to the configuration file to explain the server’s settings.
If you installed from a package and have started MongoDB using your system’s init script, you are already using a configuration file.
您可以使用配置文件在啟動時配置mongod和mongos實例。 配置文件包含等效於mongod和mongos命令行選項的設置。
使用配置文件使管理mongod和mongos選項更容易,特別是對於大規模部署。 您還可以向配置文件添加註釋,以說明伺服器的設置。
如果從一個包安裝並使用系統的init腳本啟動了MongoDB,那麼您已經在使用配置文件了。
File Format
IMPORTANT
Changed in version 2.6: MongoDB 2.6 introduces a YAML-based configuration file format. The 2.4 configuration file format remains for backward compatibility.
MongoDB configuration files use the YAML format [1].
The following sample configuration file contains several mongod settings that you may adapt to your local configuration:
NOTE
YAML does not support tab characters for indentation: use spaces instead.
文件格式
重要
2.6版本更改:MongoDB 2.6引入了基於YAML的配置文件格式。 2.4配置文件格式保持向後相容。
MongoDB配置文件使用YAML格式[1]。
以下示例配置文件包含幾個您可以適應本地配置的mongod設置:
註意
YAML不支持縮進的製表符:使用空格。
systemLog: destination: file path: "/var/log/mongodb/mongod.log" logAppend: true storage: journal: enabled: true processManagement: fork: true net: bindIp: 127.0.0.1 port: 27017 setParameter: enableLocalhostAuthBypass: false ...
The Linux package init scripts included in the official MongoDB packages depend on specific values for systemLog.path, storage.dbpath, and processManagement.fork. If you modify these settings in the default configuration file, mongod may not start.
YAML is a superset of JSON.
官方MongoDB包中包含的Linux包初始化腳本取決於systemLog.path,storage.dbpath和processManagement.fork的特定值。 如果在預設配置文件中修改這些設置,mongod可能無法啟動。
YAML是JSON的超集。
Use the Configuration File
To start mongod or mongos using a config file, specify the config file with the --config option or the -f option, as in the following examples:
The following examples use the --config option for mongod and mongos:
要使用配置文件啟動mongod或mongos,請使用--config選項或-f選項指定配置文件,如以下示例所示:
以下示例使用mongod和mongos的--config選項:
mongod --config /etc/mongod.conf mongos --config /etc/mongos.conf
也可以
mongod -f /etc/mongod.conf mongos -f /etc/mongos.conf
Core Options
systemLog
Options
systemLog: verbosity: <int>(日誌組件記錄等級) quiet: <boolean>(是否限制輸出量) traceAllExceptions: <boolean>(是否列印詳細日誌用於調試) syslogFacility: <string>(設置syslog級別) path: <string>(日常操作記錄日誌目錄) logAppend: <boolean>(日誌是否採用追加形式) logRotate: <string>(日誌重新打開) destination: <string>(所有日誌記錄地址) timeStampFormat: <string>(時間戳格式) component:(以下日誌操作級別都是0-5) accessControl:(訪問控制) verbosity: <int>(日誌記錄級別) command: verbosity: <int>(日誌記錄級別) storage: verbosity: <int>(存儲日誌記錄級別) journal: verbosity: <int> write: verbosity: <int>(寫操作) sharding: verbosity: <int>(分片) replication: verbosity: <int>(複製集) query: verbosity: <int>(查詢) network: verbosity: <int>(網路) index: verbosity: <int>(索引) geo: verbosity: <int>(地理空間) ftdc: verbosity: <int>(診斷數據收集) control: verbosity: <int>(控制操作)
processManagement
Options
processManagement: fork: <boolean>(是否後臺啟動) pidFilePath: <string>(指定一個文件存儲進程ID數據)
processManagement.
fork
Enable a daemon mode that runs the mongos or mongod process in the background. By default mongos or mongod does not run as a daemon: typically you will run mongos or mongod as a daemon, either by using processManagement.fork or by using a controlling process that handles the daemonization process (e.g. as with upstart and systemd).
The Linux package init scripts do not expect processManagement.fork to change from the defaults. If you use the Linux packages and change processManagement.fork, you will have to use your own init scripts and disable the built-in scripts.
指定一個文件位置來保存mongos或mongod進程的進程ID,其中mongos或mongod將會寫入其PID。 這對於跟蹤--fork選項的跟蹤mongos或mongod過程非常有用。 沒有指定的processManagement.pidFilePath選項,該進程將不創建PID文件。
processManagement.
pidFilePath
Specifies a file location to hold the process ID of the mongos or mongod process where mongos or mongod will write its PID. This is useful for tracking the mongos or mongod process in combination with the --fork option. Without a specified processManagement.pidFilePath option, the process creates no PID file.
指定一個文件位置來保存mongos或mongod進程的進程ID,其中mongos或mongod將會寫入其PID。 這對於跟蹤--fork選項的跟蹤mongos或mongod過程非常有用。 沒有指定的processManagement.pidFilePath選項,該進程將不創建PID文件。
net
Options
net: port: <int>(實例埠) bindIp: <string>(指定請求IP) maxIncomingConnections: <int>(實例最大客戶端連接數) wireObjectCheck: <boolean>(寫操作校驗) ipv6: <boolean>(是否啟用ip6,3.0版本預設開啟) unixDomainSocket: enabled: <boolean>(UNIX系統下,是否啟用套接字監聽) pathPrefix: <string>(UNIX套接字地址) filePermissions: <int>(設置套接字文件許可權) http: enabled: <boolean>(3.2版本已棄用) JSONPEnabled: <boolean>(3.2版本已棄用) RESTInterfaceEnabled: <boolean>(3.2版本已棄用) ssl: sslOnNormalPorts: <boolean> (2.6版本已棄用)是否開啟 TSL\SSL mode: <string> PEMKeyFile: <string> PEMKeyPassword: <string> clusterFile: <string> clusterPassword: <string> CAFile: <string> CRLFile: <string> allowConnectionsWithoutCertificates: <boolean> allowInvalidCertificates: <boolean> allowInvalidHostnames: <boolean> disabledProtocols: <string> FIPSMode: <boolean> compression: compressors: <string>
https://docs.mongodb.com/manual/reference/configuration-options/#use-the-configuration-file