MongoDB活动状态失败


0

我的服务器在Nginx Ubuntu 16.04 LTS上运行。我想安装mongoDB以便将其与node.js结合使用,然后按照本教程进行操作,但是在编写status命令时我有此内容。

● 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

1
该错误消息非常明确地说明了问题所在。
迈克尔·汉普顿

Answers:


3

该错误是不言自明的,/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能够在其中写入。


糟糕的是,我/usr/bin/mongod --quiet --config /etc/mongodb.conf在mongod.conf中尝试过的命令行是错误的,并且可以正常工作。因此,主要的问题在于我的问题中的第一个错误Active: failed
约翰·

Active: failed仅表示mongodb进程无法启动。看一下mongodb应用程序日志。您很可能需要修复权限或创建dbpath。
亨里克·平格尔
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.