千家信息网

【Mongo】mongo配置文件

发表于:2025-02-10 作者:千家信息网编辑
千家信息网最后更新 2025年02月10日,大于等于3.2按这种写法[ root@ ip - 172 - 31 - 33 - 43 conf ] # more shard1 . conf# where to write logging data
千家信息网最后更新 2025年02月10日【Mongo】mongo配置文件

大于等于3.2按这种写法

  1. [ root@ ip - 172 - 31 - 33 - 43 conf ] # more shard1 . conf

  2. # where to write logging data .

  3. systemLog :

  4. destination : file

  5. logAppend : true

  6. path : /data/shard1/log/shard1 . log


  7. # Where and how to store data .

  8. storage :

  9. dbPath : /data/shard1/data

  10. journal :

  11. enabled : true

  12. wiredTiger :

  13. engineConfig :

  14. cacheSizeGB : 5 ##限制内存使用大小


  15. # how the process runs

  16. processManagement :

  17. fork : true

  18. pidFilePath : /data/shard1/log/shard1 . pid


  19. # network interfaces

  20. net :

  21. port : 27001

  22. bindIp : 172 . 31 . 33 . 43


  23. #security :

  24. # authorization : enabled


  25. #operationProfiling :

  26. replication :

  27. replSetName : shard1

  28. sharding :

  29. clusterRole : shardsvr

security: ###开启权限认证

keyFile: /usr/local/mongodb/keyfile

authorization: enabled


  1. [ root@ ip - 172 - 31 - 33 - 43 conf ] # more config . conf

  2. ## content

  3. systemLog :

  4. destination : file

  5. logAppend : true

  6. path : /data/config/log/config . log


  7. # Where and how to store data .

  8. storage :

  9. dbPath : /data/config/data

  10. journal :

  11. enabled : true

  12. # how the process runs

  13. processManagement :

  14. fork : true

  15. pidFilePath : /data/config/log/configsrv . pid


  16. # network interfaces

  17. net :

  18. port : 21000

  19. bindIp : 172 . 31 . 33 . 43


  20. #operationProfiling :

  21. replication :

  22. replSetName : config


  23. sharding :

  24. clusterRole : configsvr


  25. [ root@ ip - 172 - 31 - 33 - 43 conf ] # more mongos . conf

  26. systemLog :

  27. destination : file

  28. logAppend : true

  29. path : /data/mongos/log/mongos . log

  30. processManagement :

  31. fork : true


  32. # network interfaces


  33. net :

  34. port : 20000

  35. bindIp : 172 . 31 . 33 . 43

  36. #监听的配置服务器 , 只能有1个或者3个 configs为配置服务器的副本集名字

  37. sharding :

  38. configDB : config/172 . 31 . 33 . 43 : 21000 , 172 . 31 . 45 . 127 : 21000 , 172 . 31 . 36 . 162 : 21000



小于3.2一般按这种格式

  1. port = 27017

  2. dbpath = / data/mongodb/data

  3. logpath = / data/mongodb/logs/mongodb . log

  4. pidfilepath = / data/mongodb/logs/mongodb . pid

  5. logappend = true

  6. auth = true

  7. fork = true

  8. wiredTigerCacheSizeGB = 20


0