在您看来,它看起来像Duplicate Question
,但事实并非如此。我有一个mongo设置,以前它在本地运行。工作正常。当我决定从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.0
更改为bindIp: 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
它停止工作了。现在,如果我从服务启动它就不会启动。 谁能说出该怎么做?谢谢
答案 0 :(得分:0)
经过很多努力后,我得到了以下解决方案:
首先,我更改了服务文件中的以下行:
ExecStart=/usr/bin/mongod --config /etc/mongod.conf --quiet
之后,我在conf文件中进行了以下更改。
authorization:[spaceadded]'enabled'
之后,我运行以下命令来更改数据目录的权限:
cd /path/to/data
sudo chown -R mongodb:mongodb *
致谢