下指令service mongod start 先遇到mongodb log status = 2
嘗試把/etc/mongod.conf 下列行刪掉
systemLog:
logAppend: true
logRotate: reopen
以及把下列檔案刪掉
/etc/logrotate.d/mongodb
再下指令
service mongod start
確認執行狀態
service mongod status
出現下列錯誤訊息
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2017-08-09 10:58:29 CST; 13s ago
Docs: https://docs.mongodb.org/manual
Process: 25673 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=51)
Process: 25670 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 25668 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 25666 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Main PID: 25673 (code=exited, status=51)
Aug 09 10:58:28 chttl-97d3548f99e4a8cb.local.com systemd[1]: Starting High-performance, schema-free document-oriented database...
Aug 09 10:58:28 chttl-97d3548f99e4a8cb.local.com systemd[1]: Started High-performance, schema-free document-oriented database.
Aug 09 10:58:28 chttl-97d3548f99e4a8cb.local.com mongod[25673]: about to fork child process, waiting until server is ready for connections.
Aug 09 10:58:28 chttl-97d3548f99e4a8cb.local.com mongod[25673]: forked process: 25676
Aug 09 10:58:29 chttl-97d3548f99e4a8cb.local.com systemd[1]: mongod.service: main process exited, code=exited, status=51/n/a
Aug 09 10:58:29 chttl-97d3548f99e4a8cb.local.com systemd[1]: Unit mongod.service entered failed state.
Aug 09 10:58:29 chttl-97d3548f99e4a8cb.local.com systemd[1]: mongod.service failed.
參考這篇 https://stackoverflow.com/questions/18524925/mongodb-service-wont-start
將/var/lib/mongo的權限都換成mongod 重啟成功!
原文:
- Check the file permissions inside your database folder
- note you need to be in your dbpath folder mine was /var/lib/mongo I went to cd /var/lib
- I ran ls -l mongo
- This showed me that databases were owned by root, which is wrong. I ran the following to fix this: chown -R mongod:mongod mongo.
我的权限 本来就是mongod mongod 但是也出现了这个问题
回覆刪除