mongodb3.x版本后就是要yaml語法格式的配置文件,下面是yaml配置文件格式如下:
官方y(tǒng)aml配置文件選項參考:https://docs.mongodb.org/manual/ ... #configuration-file
只能使用空格古话,不支持tab鍵,切記
systemLog:
??destination: file//指定是一個文件
??path: /data/logs/mongod.log//日志存放位置
??logAppend: true//產(chǎn)生日志內(nèi)容追加到文件
#??quiet: true//在quite模式下會限制輸出信息
#??timeStampFormat: iso8601-utc //默認(rèn)是iso8601-local低零,日志信息中還有其他時間戳格式:ctime,iso8601-utc,iso8601-local
processManagement:
??fork: true//以守護(hù)進(jìn)程的方式運行MongoDB么库,創(chuàng)建服務(wù)器進(jìn)程
??pidFilePath: "/data/mongo-data/mongod.pid"http://pid文件路徑
net:
# bindIp: 192.168.33.131//綁定ip地址訪問mongodb购笆,多個ip逗號分隔
??port: 27017//端口
??maxIncomingConnections:10000//默認(rèn)65535剃浇,mongodb實例接受的最多連接數(shù),如果高于操作系統(tǒng)接受的最大線程數(shù)蒂萎,設(shè)置無效秆吵。
#??http:
#? ? enabled: true//http端口最好關(guān)閉
#RESTInterfaceEnabled: false//即使http接口選項關(guān)閉,如果這個選項打開后會有更多的不安全因素
storage:
??dbPath: "/data/mongo-data"http://數(shù)據(jù)文件存放路徑
??engine: wiredTiger//數(shù)據(jù)引擎
??wiredTiger:
? ? engineConfig://wt引擎配置
? ?? ?cacheSizeGB: 1//看服務(wù)器情況來進(jìn)行設(shè)置
? ?? ?directoryForIndexes: true//索引是否按數(shù)據(jù)庫名進(jìn)行單獨存儲
? ? collectionConfig:
? ?? ?blockCompressor: zlib//壓縮配置
? ? indexConfig:
? ?? ?prefixCompression: true//索引配置
??journal:
? ? enabled: true//記錄操作日志五慈,防止數(shù)據(jù)丟失纳寂。
??directoryPerDB: true//指定存儲每個數(shù)據(jù)庫文件到單獨的數(shù)據(jù)目錄。如果在一個已存在的系統(tǒng)使用該選項泻拦,需要事先把存在的數(shù)據(jù)文件移動到目錄毙芜。
operationProfiling:
??slowOpThresholdMs: 100 //指定慢查詢時間,單位毫秒争拐,如果打開功能腋粥,則向system.profile集合寫入數(shù)據(jù)
??mode: "slowOp"http://off、slowOp陆错、all,分別對應(yīng)關(guān)閉金赦,僅打開慢查詢音瓷,記錄所有操作。
security:
??keyFile: "/data/mongodb-keyfile"http://指定分片集或副本集成員之間身份驗證的key文件存儲位置
??clusterAuthMode: "keyFile"http://集群認(rèn)證模式夹抗,默認(rèn)是keyFile
??authorization: "disabled"http://訪問數(shù)據(jù)庫和進(jìn)行操作的用戶角色認(rèn)證
復(fù)制集相關(guān)配置绳慎,根據(jù)以上配置文件進(jìn)行如下配置
replication:
??oplogSizeMB: 50//默認(rèn)為磁盤的5%,指定oplog的最大尺寸。對于已經(jīng)建立過oplog.rs的數(shù)據(jù)庫漠烧,指定無效
??replSetName: "rs_zxl"http://指定副本集的名稱
??secondaryIndexPrefetch: "all"http://指定副本集成員在接受oplog之前是否加載索引到內(nèi)存杏愤。默認(rèn)會加載所有的索引到內(nèi)存。none不加載;all加載所有;_id_only僅加載_id
分片集群配置已脓,分片復(fù)制集配置(單實例節(jié)點的基礎(chǔ)上)
replication:?
??oplogSizeMB:50
??replSetName: "rs_zxl"
sharding:
??clusterRole: shardsvr
config server配置(單實例節(jié)點的基礎(chǔ)上)
sharding:
??clusterRole: configsvr
mongos配置珊楼,(與單實例不同)
systemLog:
??destination: file
??path: /data/logs/mongos.log
??logAppend: true
net:
??port: 27019
sharding:
??configDB: 192.168.33.131:30000