2020年9月21日 星期一

Mongodb 不正常關機後,重啟出現 Permission denied


確認Mongodb 設定檔 /etc/mongodb.conf

檢查Mongodb Log  /var/log/mongodb/mongod.log

2020-09-22T08:56:41.623+0800 W  STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.

2020-09-22T08:56:41.623+0800 F  STORAGE  [initandlisten] Reason: 13: Permission denied

2020-09-22T08:56:41.623+0800 F  -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 915


步驟一(重啟DB沒效)
# mongod --dbpath  /var/lib/mongodb --repair

步驟二
# sudo chown -R mongodb:mongodb /var/lib/mongodb
# sudo chown -R mongodb:mongodb /var/log/mongodb

檢查系統狀態,Mongodb成功開啟
# systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-09-22 09:06:11 CST; 11min ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 11682 (mongod)
   CGroup: /system.slice/mongod.service
           └─11682 /usr/bin/mongod --config /etc/mongod.conf

Sep 22 09:06:11 db systemd[1]: Started MongoDB Database Server