[英]Mongodb Doesn't start from Service
對您來說,它可能看起來像一個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
from 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'
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 *
問候
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.