mongodb版本是3.6。我想运行mongodb进行生产,并且确实希望mongodb甚至在关闭终端后也能运行。最初sudo服务mongod start可以正常工作,但是在启用身份验证并通过分配角色添加访问控制后,服务mongod start已经停止工作。
/etc/mongod.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: /var/lib/mongo
journal:
enabled: true
# engine:
mmapv1:
smallFiles:true
# 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
security:
authorization: enabled
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all
interfaces.
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
当我使用sudo服务mongod start时;它说启动mongod:失败 但是我的mongod仅在我使用时启动:
mongod --auth --port 27017 --dbpath /data/db1
我要让mongod服务开始工作。