mongodb-Configuration

命令行和配制后文件接口为Mongodb的管理者提供了大量的控制选项。在这篇文章中提供了对于一般应用场景的最佳实践配置。

mongod --config /etc/mongod.conf
mongod -f /etc/mongod.conf
#在启动服务时,加上应用的配制文件,有这两种方式

  

Configure the Database

processManagement:
   fork: true
net:
   bindIp: localhost
   port: 27017
storage:
   dbPath: /srv/mongodb
systemLog:
   destination: file
   path: "/var/log/mongodb/mongod.log"
   logAppend: true
storage:
   journal:
      enabled: true
#这是默认的配制后,使用YAML format。

  

对于绝大多数会单服务,这个配置足够了。

  • fork is true,就是允许以daemon模式运行。
  • bindIp is localhost,就是设定只监听在本地或者0.0.0.0
  • port is 27017,这是默认的监听端口
  • dbPath ,数据的存储路径
  • systemLog.path ,日志输出路劲,不配置的话会打印到stdout。
  • logAppend is true,保证服务启动时不会覆盖存在的日志文件
  • storage.journal.enabled is true,在64位系统上是多余的,随它去。

Security Considerations

security:
   authorization: enabled
#启用认证机制

  

Replication and Sharding Configuration

https://docs.mongodb.com/manual/administration/configuration/

原文地址:https://www.cnblogs.com/jabbok/p/10083506.html