Ubuntu – Unable to start MongoDB on Ubuntu

mongodbUbuntuubuntu-16.04

I recently upgraded an Ubuntu 14 server to 16, and now I'm unable to start the MongoDB service.

I'm using MongoDB 3.4, from Mongo's Xenial PPA at http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4.

If I run:

sudo rm -Rf /var/log/mongodb/*
sudo service mongodb start

and then wait a few minutes, and in /var/log/mongodb/mongodb.log I see:

2018-02-06T17:42:07.322+0000 [initandlisten] exception in initAndListen: 28574 Cannot start server. Detected data files in /var/lib/mongodb created by storage engine 'wiredTiger'. The configured storage engine is 'mmapv1'., terminating

I'm assuming the default storage engine changed between releases, from "wiredTiger" to "mmapv1"? How do I set the storage engine back to "wiredTiger"?

If I add:

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
  engine: wiredTiger

to my /etc/mongod.conf, I get the same error. If I try adding that to my /etc/mongodb.conf, I get the error:

Error parsing INI config file: the options configuration file contains an invalid line 'storage:'

Best Answer

According to reference documentation storage section should look like this:

engine: <string>
   mmapv1:
      preallocDataFiles: <boolean>
      nsSize: <int>
      quota:
         enforced: <boolean>
         maxFilesPerDB: <int>
      smallFiles: <boolean>
      journal:
         debugFlags: <int>
         commitIntervalMs: <num>
   wiredTiger:
      engineConfig:
         cacheSizeGB: <number>
         journalCompressor: <string>
         directoryForIndexes: <boolean>
      collectionConfig:
         blockCompressor: <string>
      indexConfig:
         prefixCompression: <boolean>

Your piece looks slightly different. You may try to change your section for snippet below for the sake of testing and see if it's start. This piece is working on mongo 3.4 server right now:

storage:
  dbPath: /my/data/path
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

Also if it won't help and you still get error parsing INI file, you may want to check whole file against reference documentation. And i suggest you trying to run mongodb -vvv -f /path/to/config to see if mongodb is still using your config file.