I installed MongoDb yesterday on a Mac Snow Leopard and got the following error message
Mongo::ConnectionFailure: Failed to connect to a master node at localhost:27017
when trying to run some tests in Rails that used a mongodb.
Another SO question mongo – ruby connection problem about the same error message had an answer that recommended removing the lock file
sudo rm /var/lib/mongodb/mongod.lock
but when I run that command i’m getting
No such file or directory
Any ideas how I can figure out how to get it working or see if it’s properly installed?
The easiest way to run mongodb on Mac OS is:
Download binary package from http://www.mongodb.org/downloads, for me, I am using lastest 64 bit version (http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.0.2.tgz)
mkdir -p $HOME/optcd $HOME/optwget http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.0.2.tgzto download the latest (2.0.2 for now) 64 bit binary package for Mac OStar xf mongodb-osx-x86_64-2.0.2.tgz -C $HOME/optto unpack the package, and it will be unpacked to$HOME/opt/mongodb-osx-x86_64-2.0.2mkdir -p $HOME/opt/mongodatato create the data directory for mongodb$HOME/opt/mongodb-osx-x86_64-2.0.2/bin/mongod --dbpath=$HOME/opt/mongodata --logpath=$HOME/opt/mongod.logto start the mongodb daemon$HOME/opt/mongodb-osx-x86_64-2.0.2/bin/mongoto connect to your local mongodb serviceYou can also have http://www.mongodb.org/display/DOCS/Quickstart+OS+X as additional reference