安装

源码安装:

  1. wget -c https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.19.tgz
  2. tar xzf mongodb-linux-x86_64-3.4.19.tgz
  3. mv mongodb-linux-x86_64-3.4.19 /usr/local/mongodb

使用 vi/etc/profile.d/mongodb.sh 命令添加全局变量

  1. exportPATH=$PATH:/usr/local/mongodb/bin

配置

  1. 创建数据库文件夹
  2. mkdir -p /data/mongo
  3. 创建日志目录
  4. mkdir -p /var/log/mongodb
  5. 创建配置文件
  6. vi /etc/mongod.conf

配置文件

  1. # mongod.conf
  2. # for documentation of all options, see:
  3. # http://docs.mongodb.org/manual/reference/configuration-options/
  4. # where to write logging data.
  5. systemLog:
  6. destination: file
  7. logAppend: true
  8. path: /var/log/mongodb/mongod.log
  9. # Where and how to store data.
  10. storage:
  11. dbPath: /data/mongo
  12. journal:
  13. enabled: true
  14. # engine:
  15. # mmapv1:
  16. # wiredTiger:
  17. # how the process runs
  18. processManagement:
  19. fork: true # fork and run in background
  20. # pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
  21. # network interfaces
  22. net:
  23. port: 17017
  24. bindIp: 0.0.0.0 # Listen to local interface only, comment to listen on all interfaces.
  25. #security:
  26. # authorization: enabled
  27. #operationProfiling:
  28. #replication:
  29. # replSetName:
  30. #sharding:
  31. ## Enterprise-Only Options
  32. #auditLog:
  33. #snmp: