this is the error:
(mysite)zjm1126@zjm1126-G41MT-S2:~$ /usr/local/mongodb/bin/mongod
/usr/local/mongodb/bin/mongod --help for help and startup options
Wed A
On Mac OSX Yosemite after standard install with brew:
sudo chown -R `id -u` /data/db
if it not starts (check if there are no hanging and blocking connections):
lsof -i:27017
outputs something like:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mongod 16948 andi 8u IPv4 0x883a71bc9412939d 0t0 TCP *:27017 (LISTEN)
take value of PID
and run:
kill -9 <PID>
now you should be able to start mongo server: mongod
and then e.g in separate console window connect to it with mongo
I resolved this by doing a chown on mongodb ie.
sudo chown -R mongodb:mongodb /data
This is because, when you do
ls -lrth /data
drwxr-xr-x 2 mongodb mongodb 6 Jan 5 02:31 journal
-rwxr-xr-x 1 mongodb mongodb 0 Jan 5 02:31 mongod.lock
drwxr-xr-x 2 ubuntu root 24 May 8 20:02 configdb
Hope this helps.
Either sudo
the call to mongod
or change the permissions of /data/db/mongod.lock
so that it is writable by you.
Make sure you do not have a mongod instance running.
This is what worked for me. I checked to see if there was an instance running in the background at first by looking in the terminal like this: ps aux | grep mongo
and I saw that there was: 48358 bla bla mongod
so I killed it: kill 48358
and then I was able to run it fine.
If you want to rescue a member of a replica set don't use this methods described above. Instead use the procedures described in the ReSync-documentation of MongoDB.
Here, how i solved it
sudo mongod --repair --config=/etc/mongodb.conf
,
After this I Checked mongod.lock permission using ls -l /var/lib/mongodb/mongod.lock
sudo chown mongodb:mongodb /var/lib/mongodb/*
sudo service mongodb restart