Mongodb2.6配置文件 MongoDB引入一個YAML-based格式的配置文件。2.4版本之前的仍然兼容。 個人mongodb配置文件: systemLog: destination: file path: "/var/log/mongo/mongod.log" quiet: true logAppend: true timeStampFormat: iso8601-utc storage: 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: 100 processManagement: 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. systemLog systemLog.verbosity integer 日誌文件輸出的級別,越大級別越低。 systemLog.quite boolean 在quite模式下會限制輸出信息: 數據庫命令輸出,副本集活動,鏈接接受事件,鏈接關閉事件。 systemLog.traceAllExceptions string 打印verbose信息來調試,用來記錄證額外的異常日誌。 systemLog.syslogFacility string,默認爲user 指定syslog日誌信息的設備級別。須要指定--syslog來使用這個選項。 systemLog.path string 發送全部的診斷信息日誌,默認重啓後會覆蓋。 systemLog.logAppend boolean 是否啓用追加日誌。 systemLog.destination string 指定一個文件或syslog。若是指定爲文件,必須同時指定systemLog.path systemLog.timeStampFormat string,默認爲iso8601-local 日誌信息中的時間戳格式: ctime,iso8601-utc,iso8601-local 2. processManagement processManagement.pidFilePath string 指定進程的ID,與--fork配合使用,不指定則不會建立。 processManagement.fork boolean,默認爲false 是守護進程在後臺運行。 3. net net.port interger,默認爲27017 mongodb實例監聽的端口號。 net.bindIp string,2.6版本默認爲127.0.0.1 指定mongodb實例綁定的ip,爲了綁定多個ip,可使用逗號分隔。 net.maxIncomingConnections integer 默認爲1000000 mongodb實例接受的最多鏈接數,若是高於操做系統接受的最大線程數,設置無效。 net.wireObjectCheck boolean,默認爲true 檢查文檔的有效性。會稍微影響性能。 net.http.enabled boolean,默認爲false 打開http端口,會致使更多的不安全因素。 net.unixDomainSocket.enabled boolean,默認爲false 中止UNIX domain socket監聽。 mongodb實例會一直監聽UNIX socket,除非net.unixDomainSocket.enabled設置爲true,bindIp沒有設置,bindIp沒有默認指定爲127.0.0.1。 net.unixDomainSocket.pathPrefix string,默認爲/tmp unix Socket所在的路徑。 net.ipv6 boolean,默認爲false 打開IPV6功能,默認爲關閉的。 net.http.JSONPEnabled boolean,默認爲false 運行json訪問http端口,打開會致使更多的不安全因素。 net.http.RESTInterfaceEnabled boolean,默認爲false 即便http接口選項關閉,打開也會暴露http接口,會致使更多的不安全因素。 4. security security.keyFile string 指定分片集或副本集成員之間身份驗證的key文件存儲位置。 security.clusterAuthMode string 集羣認證中利用到這個模式,若是使用x.509安全機制,能夠在這裏指定。 keyFile,sendKeyFile,sendX509,x509 默認的mongodb發行版是不支持ssl的,可使用專業版的或從新自行編譯mongodb。 security.authorization string,默認爲disabled 打開訪問數據庫和進行操做的用戶角色認證。 enabled,disabled 5. operationProfiling operationProfiling.slowOpThresholdMs integer,默認100 指定慢查詢時間,單位毫秒,若是打開功能,則向system.profile集合寫入數據。 operationProfiling.mode integer,默認0 改變分析日誌輸出級別。 0,1,2,分別對應關閉,僅打開慢查詢,記錄全部操做。 6. storage storage.dbPath string 指定數據文件的路徑。 storage.directoryPerDB boolean,默認關閉 指定存儲每一個數據庫文件到單獨的數據目錄。若是在一個已存在的系統使用該選項,須要事先把存在的數據文件移動到目錄。 storage.indexBuildRetry boolean,默認爲true 指定數據庫在索引創建過程當中中止,重啓後是否從新創建索引。 storage.preallocDataFiles boolean,默認true 是否預先分片好數據文件。 storage.nsSize integer,默認16 指定命名空間的大小,即.ns後綴的文件。最大爲2047MB,16M文件能夠提供大約24000個命名空間。 storage.quota.enforced boolean,默認false 限制每一個數據庫的數據文件數目。能夠經過maxFilesPerDB調整數目。 storage.quota.maxFilesPerDB integer,默認爲8 限制每一個數據庫的數據文件數目。 storage.smallFiles boolean,默認爲false 限制mongodb數據文件大小爲512MB,減少journal文件從1G到128M,適用於有不少數量小的數據文件。 storage.syncPeriodSecs number,默認60 mongodb文件刷新頻率,儘可能不要在生產環境下修改。 storage.repairPath string,默認爲指定dbpath下的_tmp目錄。 指定包含數據文件的根目錄,進行--repair操做。 storage.journal.enabled boolean,默認64bit爲true,32bit爲false 記錄操做日誌,防止數據丟失。 storage.journal.debugFlags integer 提供數據庫在非正常關閉下的功能測試。 storage.journal.commitIntervalMs number,默認爲100或30 journal操做的最大間隔時間。能夠是2-300ms之間的值,低的值有助於持久化,可是會增長磁盤的額外負擔。 若是journal和數據文件在同一磁盤上,默認爲100ms。若是在不一樣的磁盤上爲30ms。 若是強制mongod提交日誌文件,能夠指定j:true,指定後,時間變爲原來的三分之一。 7. replication replication.oplogSizeMB integer,默認爲磁盤的5% 指定oplog的最大尺寸。對於已經創建過oplog.rs的數據庫,指定無效。 replication.replSetName string 指定副本集的名稱。 replication.secondaryIndexPrefetch string,默認爲all 指定副本集成員在接受oplog以前是否加載索引到內存。默認會加載全部的索引到內存。 none,不加載;all,加載全部;_id_only,僅加載_id。 8. sharding sharding.clusterRole string 指定分片集的mongodb角色。 configsvr,配置服務器,端口27019;shardsvr,分片實例,端口27018。 sharding.archiveMovedChunks integer 在塊移動過程當中,該選項強制mongodb實例保存全部移動的文檔到moveChunk目錄。 9. auditLog auditLog.destination string syslog,以json格式保存身份驗證到syslog,windows下不可用,serverity級別爲info,facility級別爲user。 console,以json格式輸出信息到標準輸出。 file,以json格式輸出信息到文件。 auditLog.format string 指定輸出文件的格式 JSON,輸出json格式文件;BSON,輸出bson二進制格式文件。 auditLog.path string 若是--auditDestination的值爲file,則該選項指定文件路徑。 auditLog.filter document 指定過濾系統身份驗證的格式爲: { atype : <expression> } { atype: <expression>, "param.db": <database> } 10. snmp snmp.subagent boolean 運行SNMP爲一個子代理。 snmp.master boolean 運行SNMP爲一個主進程。 僅mongos選項 replication.localPingThresholdMs integer,默認15 當客戶端選定副本集進行讀操做時受影響。 sharding.autoSplit boolean 防止mongos自動在一個分片集合中插入元數據。 由於任何的mongos均可以建立一個分離,若是打開該選項,將會致使分片不平衡,須要謹慎使用。 sharding.configDB string 指定配置數據庫。可使用逗號分隔一到三個服務器。 若是處於不一樣的位置,須要指定最近的一個。 不能移除配置服務器,即便不可用或者離線了。 sharding.chunkSize integer,默認爲64 每一個塊的大小。64MB是理想大小,小的會致使不能在不一樣節點間高效移動。 僅僅在初始化時有效。 Windows服務選項 processManagement.windowsService.serviceName string,默認爲MongoDB 指定mongodb服務名稱。可使用--install,--remove增長或刪除。 processManagement.windowsService.displayName string,默認爲MongoDB 設置mongodb服務應用程序的名稱。 processManagement.windowsService.description string,默認爲MongoDB Server 結合--install,必須指定該選項的值。 processManagement.windowsService.serviceUser 指定運行mongodb服務的用戶 processManagement.windowsService.servicePassword 指定運行mongodb服務的用戶的密碼