Nginx

MongoDB 活動狀態失敗

  • August 12, 2017

我的伺服器在 Nginx Ubuntu 16.04 LTS 上執行。我想安裝 mongoDB 以將它與 node.js 一起使用,然後我按照本教程進行操作,但是當我編寫狀態命令時,我有了這個。

● mongodb.service - High-performance, schema-free document-oriented database
  Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
  Active: failed (Result: exit-code) since Tue 2016-07-26 20:21:15 CEST; 7s ago
 Process: 4527 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=14)
Main PID: 4527 (code=exited, status=14)

Jul 26 20:21:15 ns3039456.ip-94-23-252.eu systemd[1]: Started High-performance, schema-free document-oriented d
Jul 26 20:21:15 ns3039456.ip-94-23-252.eu systemd[1]: mongodb.service: Main process exited, code=exited, status
Jul 26 20:21:15 ns3039456.ip-94-23-252.eu systemd[1]: mongodb.service: Unit entered failed state.
Jul 26 20:21:15 ns3039456.ip-94-23-252.eu systemd[1]: mongodb.service: Failed with result 'exit-code'.

你有什麼辦法可以解決我的問題嗎?如果您有需要完全刪除 mongodb 的解決方案,那沒關係。我的數據庫中沒有任何內容,因為這是我的第一次安裝。

我試過這個命令來刪除 mongodb :

sudo apt-get remove mongodb* --purge

但我有這個錯誤

E: Unable to locate package mongodb.service
E: Couldn't find any package by glob 'mongodb.service'
E: Couldn't find any package by regex 'mongodb.service'

但我確實喜歡教程所說的。我在mongo.service裡面創建了文件/etc/systemd/system

編輯 :

使用 mongod 命令我有這個:

2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] MongoDB starting : pid=6201 port=27017 dbpath=/data/db 64-bit host=ns3039456.ip-94-23-252.eu
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] db version v3.2.8
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips  1 Mar 2016
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] modules: none
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] build environment:
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten]     distmod: ubuntu1404
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten]     distarch: x86_64
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2016-07-26T20:54:46.024+0200 I CONTROL  [initandlisten] options: {}
2016-07-26T20:54:46.056+0200 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-07-26T20:54:46.056+0200 I CONTROL  [initandlisten] dbexit:  rc: 100

該錯誤是不言自明的,/etc/mongodb.conf您的系統上缺少文件,因此您需要創建一個。這個簡單的配置將允許您開始mongod

systemLog:
verbosity: 1
quiet: true
traceAllExceptions: false
path: "/opt/mongo/log/local.log"
logAppend: true
destination: file
storage:
dbPath: "/opt/mongo/db"
journal:
 enabled: true
processManagement:
fork: true
net:
port: 27017
security:
authorization: disabled

只需為日誌/儲存設置適當的路徑並確保mongod能夠在那裡寫入。

引用自:https://serverfault.com/questions/792092