MongDB 配置文件介紹及調優

1mongdb配置文件介紹

1.1 常規參數
     port= //端口
     fork=true//守護進程方式啓動mongo
     logpath=shard.log //mongo日誌存放路徑
     journal= true//redo log開啓
     nohttpinterface = true //關閉http端口,提高安全性
     directoryperdb = true // 每個db會創建一個單獨的目錄
     logappend = true //日誌輸出模式,當重啓後纔會觸發,默認爲false
     maxConns= 5000 //最大連接數
     slowms=1000 //慢日誌記錄開啓,單位是秒
1.2 WT引擎優化
   engine=wiredTiger//mongo3.2以後都是wt爲默認引擎
   prefixCompression: true//索引壓縮,默認開啓
  blockCompressor: snappy(zlib,snap,none可選 db壓縮)//默認snappy,推薦snappy
  journalCompressor:snappy(zlib,snap,none可選 log壓縮)//默認snappy,推薦snappy
  directoryForIndexes: true//數據和索引文件分離,默認開啓
  cacheSizeGB=linux memory/2 //默認爲系統內存的一半,緩存數據和索引,可以理解成innodb_buffer_pool,推薦默認值,單位G,目的是限制mongo內存的使用
1.3 集羣配置
 shardsvr=true//是否開啓分片集羣
 chunkSize=64//單chunk大小,單位MB,默認64,推薦64
 oplogSize=10240//oplog大小 單位是MB 建議調大
 replSet: rs0//副本集名稱
1.4  驗證配置
 auth=true//開啓認證
 keyFile=keyfile//集羣認證密鑰
1.5 切換日誌
 1 默認Mongodb是開啓--logRotaterename選項的
 2 mongo版本需要大於3.0X
 3 執行切換命令 
 mongo --port admin --quiet --eval "db.runCommand( { logRotate : 1 } )"
注意:由於mongo版本更新頻繁,所以配置文件參數選項可能有變化,只做參考

2 配置文件調優

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /opt/mongodb/mongo       #數據文件位置
  journal:
    enabled: true
#  engine:
#  mmapv1:
 engine: wiredTiger  #使用wiredTiger存儲引擎

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
  timeZoneInfo: /usr/share/zoneinfo

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
  http:
    JSONPEnabled: false  #關閉jsonp調用
    RESTInterfaceEnabled: false  #關閉reset

security:
  authorization: enabled     #開啓數據庫認證

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章