根據(jù)官網(wǎng)的提示內(nèi)容挤巡,默認(rèn)的配置文件內(nèi)容為
注意:boolean值為true或者false安拟,首字母不能大寫
systemLog.path為一個文件名癞志,不能為一個文件夾锣笨,如果該文件已存在驻啤,會創(chuàng)建一個新的帶日期的文件
有了這個基礎(chǔ)菲驴,啟動時就可以看啟動日志文件來查看到底是哪里的配置有問題不能啟動
processManagement.pidFilePath為一個文件地址,不存在也沒問題
net.ssl最好全部注釋掉骑冗,暫時不用ssl
security下最好也注釋掉赊瞬,否則需要配置全部安全內(nèi)容,以及keyFile一定要存在贼涩。
storage.repairPath一定要是storage.dbPath的子目錄巧涧,且目錄需要存在。
replication是復(fù)制遥倦,副本啟動褒侧,注釋掉
記得注釋掉一個引擎
這樣就可以啟動了
mongodb3.x版本后就是要yaml語法格式的配置文件,下面是yaml配置文件格式如下:
官方y(tǒng)aml配置文件選項(xiàng)參考:https://docs.mongodb.org/manual/ ... #configuration-file
只能使用空格谊迄,不支持tab鍵
systemLog:
? verbosity: 0
? quiet: false
#? traceAllExceptions: <boolean>
? syslogFacility: user
? path: "/data/mongodb/log"
? logAppend: false
? logRotate: rename
? destination: file
? timeStampFormat: iso8601-local
? component:
? ? ? accessControl:
? ? ? ? verbosity: 0
? ? ? command:
? ? ? ? verbosity: 0
? ? ? # COMMENT some component verbosity settings omitted for brevity
? ? ? storage:
? ? ? ? verbosity: 0
? ? ? ? journal:
? ? ? ? ? ? verbosity: 0
? ? ? write:
? ? ? ? verbosity: 0
processManagement:
? fork: false
? pidFilePath: "/var/run/mongodb/mongod.pid"
net:
? port: 27017
? bindIp: "127.0.0.1"
? maxIncomingConnections: 65536
? wireObjectCheck: true
? ipv6: false
? unixDomainSocket:
? ? ? enabled: true
? ? ? pathPrefix: "/tmp"
? ? ? filePermissions: 0700
? http:
? ? ? enabled: true
? ? ? JSONPEnabled: false
? ? ? RESTInterfaceEnabled: false
#? ssl:
#? ? sslOnNormalPorts: <boolean>? # deprecated since 2.6
#? ? ? mode: disabled
#? ? ? PEMKeyFile: <string>
#? ? ? PEMKeyPassword: <string>
#? ? ? clusterFile: <string>
#? ? ? clusterPassword: <string>
#? ? ? CAFile: <string>
#? ? ? CRLFile: <string>
#? ? ? allowConnectionsWithoutCertificates: <boolean>
#? ? ? allowInvalidCertificates: <boolean>
#? ? ? allowInvalidHostnames: <boolean>
#? ? ? FIPSMode: <boolean>
#security:
#? keyFile: "/var/lib/mongo/mongodb-keyfile"
#? clusterAuthMode: keyFile
#? authorization: disabled
#? javascriptEnabled:? true
#? sasl:
#? ? ? hostName: <string>
#? ? ? serviceName: <string>
#? ? ? saslauthdSocketPath: <string>
#setParameter:
#? <parameter1>: <value1>
#? <parameter2>: <value2>
storage:
? dbPath: "/data/db"
? indexBuildRetry: true
? repairPath: "/data/db/tmp"
? journal:
? ? ? enabled: true
? directoryPerDB: false
? syncPeriodSecs: 60
? engine: mmapv1
? mmapv1:
? ? ? preallocDataFiles: true
? ? ? nsSize: 16
? ? ? quota:
? ? ? ? enforced: false
? ? ? ? maxFilesPerDB: 8
? ? ? smallFiles: false
? ? ? journal:
? ? ? ? debugFlags: 1
? ? ? ? commitIntervalMs: 100
#? wiredTiger:
#? ? ? engineConfig:
#? ? ? ? cacheSizeGB: 1
#? ? ? ? statisticsLogDelaySecs: 0
#? ? ? ? journalCompressor: snappy
#? ? ? ? directoryForIndexes: false
#? ? ? collectionConfig:
#? ? ? ? blockCompressor: snappy
#? ? ? indexConfig:
#? ? ? ? prefixCompression: true
operationProfiling:
? slowOpThresholdMs: 100
? mode: off
#replication:
#? oplogSizeMB: 50
#? replSetName: repl_test
#? secondaryIndexPrefetch: all
#sharding:
#? clusterRole: <string>
#? archiveMovedChunks: <boolean>
#auditLog:
#? destination: file
#? format: JSON
#? path: "/data/mongodb/log"
#? filter: <string>
#snmp:
#? subagent: <boolean>
#? master: <boolean>
#mongos only
#replication:
#? localPingThresholdMs: <boolean>
#sharding:
#? autoSplit: <boolean>
#? configDB: <string>
#? chunkSize: <int>
systemLog:
? verbosity: 0
? quiet: false
#? traceAllExceptions: <boolean>
? syslogFacility: user
? path: "/data/mongodb/log"
? logAppend: false
? logRotate: rename
? destination: file
? timeStampFormat: iso8601-local
? component:
? ? ? accessControl:
? ? ? ? verbosity: 0
? ? ? command:
? ? ? ? verbosity: 0
? ? ? # COMMENT some component verbosity settings omitted for brevity
? ? ? storage:
? ? ? ? verbosity: 0
? ? ? ? journal:
? ? ? ? ? ? verbosity: 0
? ? ? write:
? ? ? ? verbosity: 0
processManagement:
? fork: false
? pidFilePath: "/var/run/mongodb/mongod.pid"
net:
? port: 27017
? bindIp: "127.0.0.1"
? maxIncomingConnections: 65536
? wireObjectCheck: true
? ipv6: false
? unixDomainSocket:
? ? ? enabled: true
? ? ? pathPrefix: "/tmp"
? ? ? filePermissions: 0700
? http:
? ? ? enabled: true
? ? ? JSONPEnabled: false
? ? ? RESTInterfaceEnabled: false
#? ssl:
#? ? sslOnNormalPorts: <boolean>? # deprecated since 2.6
#? ? ? mode: disabled
#? ? ? PEMKeyFile: <string>
#? ? ? PEMKeyPassword: <string>
#? ? ? clusterFile: <string>
#? ? ? clusterPassword: <string>
#? ? ? CAFile: <string>
#? ? ? CRLFile: <string>
#? ? ? allowConnectionsWithoutCertificates: <boolean>
#? ? ? allowInvalidCertificates: <boolean>
#? ? ? allowInvalidHostnames: <boolean>
#? ? ? FIPSMode: <boolean>
#security:
#? keyFile: "/var/lib/mongo/mongodb-keyfile"
#? clusterAuthMode: keyFile
#? authorization: disabled
#? javascriptEnabled:? true
#? sasl:
#? ? ? hostName: <string>
#? ? ? serviceName: <string>
#? ? ? saslauthdSocketPath: <string>
#setParameter:
#? <parameter1>: <value1>
#? <parameter2>: <value2>
storage:
? dbPath: "/data/db"
? indexBuildRetry: true
? repairPath: "/data/db/tmp"
? journal:
? ? ? enabled: true
? directoryPerDB: false
? syncPeriodSecs: 60
? engine: mmapv1
? mmapv1:
? ? ? preallocDataFiles: true
? ? ? nsSize: 16
? ? ? quota:
? ? ? ? enforced: false
? ? ? ? maxFilesPerDB: 8
? ? ? smallFiles: false
? ? ? journal:
? ? ? ? debugFlags: 1
? ? ? ? commitIntervalMs: 100
#? wiredTiger:
#? ? ? engineConfig:
#? ? ? ? cacheSizeGB: 1
#? ? ? ? statisticsLogDelaySecs: 0
#? ? ? ? journalCompressor: snappy
#? ? ? ? directoryForIndexes: false
#? ? ? collectionConfig:
#? ? ? ? blockCompressor: snappy
#? ? ? indexConfig:
#? ? ? ? prefixCompression: true
operationProfiling:
? slowOpThresholdMs: 100
? mode: off
#replication:
#? oplogSizeMB: 50
#? replSetName: repl_test
#? secondaryIndexPrefetch: all
#sharding:
#? clusterRole: <string>
#? archiveMovedChunks: <boolean>
#auditLog:
#? destination: file
#? format: JSON
#? path: "/data/mongodb/log"
#? filter: <string>
#snmp:
#? subagent: <boolean>
#? master: <boolean>
#mongos only
#replication:
#? localPingThresholdMs: <boolean>
#sharding:
#? autoSplit: <boolean>
#? configDB: <string>
#? chunkSize: <int>