mongod.conf,mongodbmongodb.conf

來源:互聯網
上載者:User

mongod.conf,mongodbmongodb.conf

mongod -f 'config path'MongoDB引入一個YAML-based格式的設定檔。2.4版本以前的仍然相容。我的mongodb設定檔:systemLog:   destination: file  path: "/var/log/mongo/mongod.log"  quiet: true  logAppend: true  timeStampFormat: iso8601-utcstorage:   dbPath: "/var/lib/mongo"  directoryPerDB: true  indexBuildRetry: false  preallocDataFiles: true  nsSize: 16# quota:#   enforced: false#   maxFilesPerDB: 8  smallFiles: false  syncPeriodSecs: 60# repairPath: "/var/lib/mongo/_tmp"  journal:    enabled: true#   debugFlags: 1    commitIntervalMs: 100processManagement:   fork: true  pidFilePath: "/var/run/mongodb/mongod.pid"net: # bindIp: 192.168.11.52   port: 27017  http:    enabled: true    RESTInterfaceEnabled: false # ssl:#   mode: "requireSSL"#   PEMKeyFile: "/etc/ssl/mongodb.pem"operationProfiling:  slowOpThresholdMs: 100   mode: "slowOp"security:  keyFile: "/var/lib/mongo/mongodb-keyfile"  clusterAuthMode: "keyFile"  authorization: "disabled"replication:  oplogSizeMB: 50  replSetName: "repl_test"  secondaryIndexPrefetch: "all"設定選項:1. systemLogsystemLog.verbosity integer記錄檔輸出的層級,越大層級越低。systemLog.quiteboolean在quite模式下會限制輸出資訊:資料庫命令輸出,複本集活動,串連接受事件,串連關閉事件。systemLog.traceAllExceptions string列印verbose資訊來調試,用來記錄證額外的異常日誌。systemLog.syslogFacilitystring,預設為user指定syslog日誌資訊的裝置層級。需要指定--syslog來使用這個選項。systemLog.path string發送所有的診斷資訊日誌,預設重啟後會覆蓋。systemLog.logAppendboolean是否啟用追加日誌。systemLog.destinationstring指定一個檔案或syslog。如果指定為檔案,必須同時指定systemLog.pathsystemLog.timeStampFormatstring,預設為iso8601-local日誌資訊中的時間戳記格式:ctime,iso8601-utc,iso8601-local2. processManagementprocessManagement.pidFilePathstring指定進程的ID,與--fork配合使用,不指定則不會建立。processManagement.forkboolean,預設為false是守護進程在後台運行。3. netnet.portinterger,預設為27017mongodb執行個體監聽的連接埠號碼。net.bindIpstring,2.6版本預設為127.0.0.1指定mongodb執行個體綁定的ip,為了綁定多個ip,可以使用逗號分隔。net.maxIncomingConnectionsinteger 預設為1000000mongodb執行個體接受的最多串連數,如果高於作業系統接受的最大線程數,設定無效。net.wireObjectCheckboolean,預設為true檢查文檔的有效性。會稍微影響效能。net.http.enabledboolean,預設為false開啟http連接埠,會導致更多的不安全因素。net.unixDomainSocket.enabledboolean,預設為false停止UNIX domain socket監聽。mongodb執行個體會一直監聽UNIXsocket,除非net.unixDomainSocket.enabled設定為true,bindIp沒有設定,bindIp沒有預設指定為127.0.0.1。net.unixDomainSocket.pathPrefixstring,預設為/tmpunix Socket所在的路徑。net.ipv6boolean,預設為false開啟IPV6功能,預設為關閉的。net.http.JSONPEnabledboolean,預設為false運行json訪問http連接埠,開啟會導致更多的不安全因素。net.http.RESTInterfaceEnabledboolean,預設為false即使http介面選項關閉,開啟也會暴露http介面,會導致更多的不安全因素。4. securitysecurity.keyFilestring指定分區集或複本集成員之間身分識別驗證的key檔案儲存體位置。security.clusterAuthModestring叢集認證中利用到這個模式,如果使用x.509安全機制,可以在這裡指定。keyFile,sendKeyFile,sendX509,x509預設的mongodb發行版是不支援ssl的,可以使用專業版的或重新自行編譯mongodb。security.authorizationstring,預設為disabled開啟訪問資料庫和進行操作的使用者角色認證。enabled,disabled5. operationProfilingoperationProfiling.slowOpThresholdMsinteger,預設100指定慢查詢時間,單位毫秒,如果開啟功能,則向system.profile集合寫入資料。operationProfiling.modeinteger,預設0改變分析日誌輸出層級。0,1,2,分別對應關閉,僅開啟慢查詢,記錄所有操作。6. storagestorage.dbPathstring指定資料檔案的路徑。storage.directoryPerDBboolean,預設關閉指定儲存每個資料庫檔案到單獨的資料目錄。如果在一個已存在的系統使用該選項,需要事先把存在的資料檔案移動到目錄。storage.indexBuildRetryboolean,預設為true指定資料庫在索引建立過程中停止,重啟後是否重建立立索引。storage.preallocDataFilesboolean,預設true是否預先分區好資料檔案。storage.nsSizeinteger,預設16指定命名空間的大小,即.ns尾碼的檔案。最大為2047MB,16M檔案可以提供大約24000個命名空間。storage.quota.enforcedboolean,預設false限制每個資料庫的資料檔案數目。可以通過maxFilesPerDB調整數目。storage.quota.maxFilesPerDBinteger,預設為8限制每個資料庫的資料檔案數目。storage.smallFilesboolean,預設為false限制mongodb資料檔案大小為512MB,減小journal檔案從1G到128M,適用於有很多數量小的資料檔案。storage.syncPeriodSecsnumber,預設60mongodb檔案重新整理頻率,盡量不要在生產環境下修改。storage.repairPathstring,預設為指定dbpath下的_tmp目錄。指定包含資料檔案的根目錄,進行--repair操作。storage.journal.enabledboolean,預設64bit為true,32bit為false記錄動作記錄,防止資料丟失。storage.journal.debugFlagsinteger提供資料庫在非正常關閉下的功能測試。storage.journal.commitIntervalMsnumber,預設為100或30journal操作的最大間隔時間。可以是2-300ms之間的值,低的值有助於持久化,但是會增加磁碟的額外負擔。如果journal和資料檔案在同一磁碟上,預設為100ms。如果在不同的磁碟上為30ms。如果強制mongod提交記錄檔,可以指定j:true,指定後,時間變為原來的三分之一。7. replicationreplication.oplogSizeMBinteger,預設為磁碟的5%指定oplog的最大尺寸。對於已經建立過oplog.rs的資料庫,指定無效。replication.replSetNamestring指定複本集的名稱。replication.secondaryIndexPrefetchstring,預設為all指定複本集成員在接受oplog之前是否載入索引到記憶體。預設會載入所有的索引到記憶體。none,不載入;all,載入所有;_id_only,僅載入_id。8. shardingsharding.clusterRolestring指定分區集的mongodb角色。configsvr,設定管理員,連接埠27019;shardsvr,分區執行個體,連接埠27018。sharding.archiveMovedChunksinteger在塊移動過程中,該選項強制mongodb執行個體儲存所有移動的文檔到moveChunk目錄。9. auditLogauditLog.destinationstringsyslog,以json格式儲存身分識別驗證到syslog,windows下不可用,serverity層級為info,facility層級為user。console,以json格式輸出資訊到標準輸出。file,以json格式輸出資訊到檔案。auditLog.formatstring指定輸出檔案的格式JSON,輸出json格式檔案;BSON,輸出bson二進位格式檔案。auditLog.pathstring如果--auditDestination的值為file,則該選項指定檔案路徑。auditLog.filterdocument指定過濾系統身分識別驗證的格式為:{ atype : <expression> }{ atype: <expression>, "param.db": <database> }10. snmpsnmp.subagentboolean運行SNMP為一個子代理。snmp.masterboolean運行SNMP為一個主進程。僅mongos選項replication.localPingThresholdMsinteger,預設15當用戶端選定複本集進行讀操作時受影響。sharding.autoSplitboolean防止mongos自動在一個分區集合中插入中繼資料。因為任何的mongos都可以建立一個分離,如果開啟該選項,將會導致分區不平衡,需要謹慎使用。sharding.configDBstring指定設定資料庫。可以使用逗號分隔一到三個伺服器。如果處於不同的位置,需要指定最近的一個。不能移除設定管理員,即使不可用或者離線了。sharding.chunkSizeinteger,預設為64每個塊的大小。64MB是理想大小,小的會導致不能在不同節點間高效移動。僅僅在初始化時有效。Windows服務選項processManagement.windowsService.serviceNamestring,預設為MongoDB指定mongodb服務名稱。可以使用--install,--remove增加或刪除。processManagement.windowsService.displayNamestring,預設為MongoDB設定mongodb服務應用程式的名稱。processManagement.windowsService.descriptionstring,預設為MongoDB Server結合--install,必須指定該選項的值。processManagement.windowsService.serviceUser指定運行mongodb服務的使用者processManagement.windowsService.servicePassword指定運行mongodb服務的使用者的密碼

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.