0

I'm trying to run MongoDB on OSX and encountering a common problem, Error with exit code 1.

Here's my very simple mongod.conf:

systemLog:
  destination: file
  logAppend: true
  path: ~/Documents/test/mongodb/mongodb.log

storage:
  directoryPerDB: true
  dbPath: ~/Documents/test/mongodb/mongodb_data
  journal:
    enabled: true

processManagement:
  fork: true  # fork and run in background

net:
  port: 27017

I 777'd all the folders so there's no way it can be a permissions issue (right? :P)

mac$ ls -lah ~/Documents/test/mongodb/
total 8
drwxr-xr-x   5 mac  staff   170B Dec  4 15:34 .
drwxr-xr-x  11 mac  staff   374B Dec  4 15:19 ..
-rwxrwxrwx   1 mac  staff   301B Dec  4 15:21 mongod.conf
-rwxrwxrwx   1 mac  staff     0B Dec  4 15:21 mongodb.log
drwxrwxrwx   2 mac  staff    68B Dec  4 15:18 mongodb_data

But it still gets this error code!

mac$ sudo mongod -f ~/Documents/test/mongodb/mongod.conf 
about to fork child process, waiting until server is ready for connections.
forked process: 70062
ERROR: child process failed, exited with error number 1

Things I've tried from other questions:

  1. Apparently I shouldn't have to run this as sudo (?), I've tried both sudo and no sudo, same result
  2. Could be a permissions issue (Starting mongod fails unless run as root) - well the mongodb_data directory and the conf and log are all 777 so can that really be the case? I've tried chown on all of them too but no effect.
  3. Remove the pid location in your mongod.conf (done, doesn't have any effect) Starting mongod fork, ERROR: child process failed, exited with error number 1

Also:

  • mongodb.log has nothing in it after multiple start attempts
  • mongodb_data/ has nothing in it either (no .lock file or whatever, just empty)

Any ideas?

Community
  • 1
  • 1
LittleBobbyTables
  • 4,361
  • 9
  • 38
  • 67
  • As a next step I would try running mongod without the config file. Running "mongod --dbpath DB_PATH", substituting DB_PATH for your actual dbpath. I would also use absolute paths rather than using "~" as the base for both log and dbpath. – James Wahlin Dec 04 '15 at 20:55
  • Changing the paths to absolutes rather than relatives doesn't have any effect. However, calling the entire thing from the command line seems to work like: sudo mongod --dbpath /Users/mac/Documents/test/mongodb/mongodb_data/ --fork --logpath /Users/mac/Documents/test/mongodb/mongodb.log - but why not using a conf file? – LittleBobbyTables Dec 04 '15 at 21:03

1 Answers1

2

This is probably error with log file. It's strange that yours is 0 bytes. Anyway you do not need to make 777 permissions, you do not need to run mongod with sudo on OSX system. Try to do the following:

  1. mkdir ~/sometest
  2. cd ~/sometest
  3. cp ~/Documents/test/mongodb/mongod.conf .
  4. Replace systemLog path to mongodb.log, replace dbpath to data
  5. mkdir data
  6. Start mongod (mongod -f mongod.conf)
miholeus
  • 1,537
  • 1
  • 9
  • 8
  • Thanks for the suggestion. Have tried this but get another error: mac$ mkdir ~/sometest mac$ cd ~/sometest/ mac$ cp ~/Documents/test/mongodb/mongod.conf . mac$ vim mongod.conf mac$ mkdir data mac$ mongod -f mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 73375 ERROR: child process failed, exited with error number 14 (Edit: it destroyed my formatting) – LittleBobbyTables Dec 04 '15 at 21:46
  • Check your config http://stackoverflow.com/questions/30476447/mongodb-error-child-process-failed-exited-with-error-number-14 – miholeus Dec 04 '15 at 21:48