Mongodb 不是从服务开始

Mongodb Doesn't start from Service

您可能看起来像 Duplicate Question,但事实并非如此。我有一个 mongo 设置,以前是 运行ning 在本地。它运作良好。当我决定从 external IP 使用它时,我无法从服务启动它。另外,我有这样的服务配置:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false

# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended- 
settings

[Install]
WantedBy=multi-user.target

和mongo.conf像这样:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
journal:
  enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0


#processManagement:

security:
  authorization:'enabled'

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

在将以下行更改为:bindIp: 0.0.0.0bindIp: 127.0.0.1 之前。并添加了以下行: security: authorization:'enabled'

还有服务日志:Oct 11 13:42:27 bingagepos-sandbox systemd[1]: Started High-performance, schema-free document-oriented database. Oct 11 13:42:27 bingagepos-sandbox systemd[1]: mongod.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Oct 11 13:42:27 bingagepos-sandbox systemd[1]: mongod.service: Unit entered failed state. Oct 11 13:42:27 bingagepos-sandbox systemd[1]: mongod.service: Failed with result 'exit-code'

如果我运行 遵循命令它工作正常:

mongod --dbpath=/var/lib/mongodb

它停止工作了。现在,如果我从服务启动它,它就不会启动。 谁能告诉我可以做什么?谢谢

经过一番努力,我得到了以下解决方案:

首先,我更改了服务文件中的以下行:

ExecStart=/usr/bin/mongod --config /etc/mongod.conf --quiet

之后,我在 conf 文件中进行了以下更改。

authorization:[spaceadded]'enabled'

之后我运行使用以下命令更改数据目录的权限:

cd /path/to/data
sudo chown -R mongodb:mongodb *

此致