MongoDB-配置翻譯
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
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