MongoDB数据库配置文件与启动(二)

本文档介绍mongodb数据库的配置文件mongo.conf的参数
配置文件如下
# 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: /MongoDB/mongo
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
#security:
# authorization: enabled
# keyFile: /MongoDB/key/mongodb-keyfile
#

# 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 # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:
#replication:
# replSetName: Appex

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

需要使用的参数
1,systemLog:
destination: file #文件,默认
logAppend: true #输出日志,默认true,打开
path: /var/log/mongodb/mongod.log #日志路径
2,storage:
dbPath: /MongoDB/mongo #数据库存储数据路径,依生产环境而定
journal:
enabled: true #日记,默认true,存储引擎相关参数
3,net:
port: 27017 #监控端口
bindIp: 0.0.0.0 #允许IP访问,建议0.0.0.0全开,即允许所有人来访问,前提 是开启安全访问控制
4,processManagement:
fork: true # fork and run in background #开启进程模式
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo #时区
5,#security:
# authorization: enabled #密码认证,基于用户角色控制
# keyFile: /MongoDB/key/mongodb-keyfile #密钥认证,副本集之间的认证
PS:此参数默认关闭,打开配置后续讨论
6,#replication:
# replSetName: Appex #副本集名字
PS:副本集功能,后续讨论

启动命令:
service mongod start

你可能感兴趣的:(MongoDB)