mongodbterminalhomebrewlocomotivecms

Unable to run Mongo shell (Mac)


I'm new to web development and I wanted to get started with some RoR (using Locomotive CMS).

One of the things Locomotive asks for is to have Mongodb. I installed using homebrew by following this link http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

It installs fine but then im not able to run it!

When I type 'mongo' on terminal I get the following output :

"MongoDB shell version: 2.4.3
connecting to: test
Mon May  6 11:12:28.927 
JavaScript execution failed: 
Error: couldn't connect to server        
127.0.0.1:27017 at   src/mongo/shell/mongo.js:L112
exception: connect failed"

BACKGROUND TO HELP DEBUGGING ( on Terminal) :

1.When I type in mongod I get the following :

"all output going to: /usr/local/var/log/mongodb/mongo.log"

Ownership of mongo.log :

-rw-r--r--  1 username  admin  22133 May  6 11:13 mongo.log

2.When I input mongod --fork I get the following :

about to fork child process, waiting until server is ready for connections.
forked process: 77566
all output going to: /usr/local/var/log/mongodb/mongo.log
ERROR: child process failed, exited with error number 100

3.Typing mongod --help gives the following warning:

* WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

4.I have a folder called data (which acts as amongodb database, is this where it should be?)in root (PATH : /data) Ownership of data folder :

 "drwxr-xr-x   3 username  wheel       102 Apr 23 21:38 data"

5.Checking if ports are free: lsof -i :27017. Ive also tried to check for a running mongo process using activity montior and found zilch!

No output

6.Ive also tried : mongo --repair. Dint help!

Ive been stuk on this for a while, I've looked at most responses on stackoverflow and searched around to find a solution to this but nothing has helped so far!

UPDATE:

When I tried to start the mongo shell, I was getting the following l log message from mongo.log:

5/6/13 1:33:27.616 PM com.apple.launchd: 
(org.mongodb.mongod[79133])          
open("/private/var/log/mongodb/output.log", ...): Permission denied

So I did a chmod777 for the particular folder and the shell launches!

Although I still get a warning when it launches as:

Server has startup warnings: 
Mon May  6 13:33:27.693 [initandlisten] 
Mon May  6 13:33:27.693 [initandlisten] 
** WARNING: soft rlimits too low. 
Number of files is 256, should be at least 1000

Any idea how I can silence these warnings?


Solution

  • To get the information you need to determine the cause of failure you need to look in (and post for us) the output from /usr/local/var/log/mongodb/mongo.log when it is trying to start.

    However, the most common reason for the failure is the lack of the default database path - at /data/db. Either create that folder (and don't forget to make sure your user has permission to read/write to it) or specify a different path with the --dbpath option.

    UPDATE: as you have since found, bad permissions on the log file can cause the issue, in a similar way to bad permissions on the data path.

    In terms of the warning, the information you need is here:

    https://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x-10-7-1

    It is just that though, a warning - you can run MongoDB without an issue with those limits as long as it is not under heavy load. So, if this is a development environment, unless you plan on load testing, you should be fine