0

My server running on Nginx Ubuntu 16.04 LTS. I want to install mongoDB to use it with node.js then I followed this tutorial but when I write the status command I have this.

● 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'.

Do you have any solution to fix my problem ? If you have a solution who need to completly remove mongodb it's ok. I have nothing in my database because this is my first installation.

I tried this command to remove mongodb :

sudo apt-get remove mongodb* --purge

But I have this error

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'

But I did like as the tutorial said. I created the mongo.service files inside /etc/systemd/system

Edit :

With the mongod command I have this :

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
John
  • 129
  • 1
  • 6

1 Answers1

3

The error is self-explanatory, file /etc/mongodb.conf is missing on your system, so you need to create one. This simple config will allow you to start 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

Just set appropriate path for logs/storage and ensure that mongod is able to write there.

user1700494
  • 1,642
  • 2
  • 11
  • 20
  • My bad I was wrong about my command line `/usr/bin/mongod --quiet --config /etc/mongodb.conf` I tried with mongod.conf and it works. So the main problem is on the first error in my question about `Active: failed` – John Jul 26 '16 at 18:50
  • `Active: failed` just means that the mongodb process failed to start. Take a look at the mongodb application log. Most likely you need to fix permissions or create dbpath. – Henrik Pingel Jul 26 '16 at 18:55