I needed to learn node.js and mongodb which requires me to use my mac osx, so I am new to the shell command line interface.
Problem: When I followed the instructs on mongodb website and installed mongodb and tried to run, I get the following error messages. Any idea what went wrong?
What I Did:
brew install mongodbsudo mkdir -p /data/dbsudo chmod 0755 /data/dbsudo chown mongod:mongod /data/db
Error: chown: mongod: Invalid argument
What I Did Next:
mongod
Error:
Mon Nov 21 18:55:08 [initandlisten] MongoDB starting : pid=28304 port=27017 dbpath=/data/db/ 64-bit host=MacBook-Air.local
Mon Nov 21 18:55:08 [initandlisten] db version v2.0.1, pdfile version 4.5
Mon Nov 21 18:55:08 [initandlisten] git version: 3a5cf0e2134a830d38d2d1aae7e88cac31bdd684
Mon Nov 21 18:55:08 [initandlisten] build info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Mon Nov 21 18:55:08 [initandlisten] options: {}
Mon Nov 21 18:55:08 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Mon Nov 21 18:55:08 dbexit:
Mon Nov 21 18:55:08 [initandlisten] shutdown: going to close listening sockets...
Mon Nov 21 18:55:08 [initandlisten] shutdown: going to flush diaglog...
Mon Nov 21 18:55:08 [initandlisten] shutdown: going to close sockets...
Mon Nov 21 18:55:08 [initandlisten] shutdown: waiting for fs preallocator...
Mon Nov 21 18:55:08 [initandlisten] shutdown: lock for final commit...
Mon Nov 21 18:55:08 [initandlisten] shutdown: final commit...
Mon Nov 21 18:55:08 [initandlisten] shutdown: closing all files...
Mon Nov 21 18:55:08 [initandlisten] closeAllFiles() finished
Mon Nov 21 18:55:08 [initandlisten] shutdown: removing fs lock...
Mon Nov 21 18:55:08 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Mon Nov 21 18:55:08 dbexit: really exiting now
Doing a ls -ld /data/db gives:
drwxr-xr-x 2 root wheel 68 Nov 21 18:46 /data/db
Nyxynyx-
It looks like a file permissions problem. You created the /data/db as root, so root is the owner, and the chown command failed (do you already have a user on your system named mongod? if not, that command will fail) so the owner was still root. But then you ran mongod as a normal user so it was unable to create any lock file in the data directory.
You could: