我的MongoDB服务器没有启动命令mongod
键入sudo service mongodb status
yeilds
mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2017-11-28 20:08:25 IST; 2s ago
Process: ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 29675 (code=exited, status=1/FAILURE)
系统服务:
#/etc/systemd/system/mongodb.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
mongod conf:
#/etc/mongod.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
但是,如果我正在运行sudo -u mongodb mongod --config /etc/mongod.conf
,它就会运行。
此外,如果我运行sudo mongod
服务器尝试启动,但存储路径为/data/db/
我尚未创建。
mongod --config /etc/mongod.conf
给出以下错误
[main] Failed global initialization: FileNotOpen: Failed to open "/var/log/mongodb/mongod.log"
我跑了chown -R mongodb:mongodb /var/lib/mongodb
权限:
-rw-r--r-- 1 mongodb mongodb 4096 Nov 28 20:19 /var/log/mongodb/mongod.log
drwxr-xr-x 4 mongodb mongodb 20480 Nov 28 21:32 /var/lib/mongodb
现在每当我需要MongoDB服务器时,我都必须使用sudo mongod --dbpath /var/lib/mongodb/
这对我来说似乎是一个许可问题。但我无法弄清楚如何解决这个问题?