MongoDB无法在Mac上启动

时间:2014-04-24 03:50:19

标签: macos mongodb

我通过MongoDB安装了Homebrew。手动创建/data/db目录。试图从命令行运行mongod命令,这里发生了什么:

Sanjeet-Suhags-MacBook-Pro:~ sanjeetsuhag$ mongod
mongod --help for help and startup options
2014-04-24T09:18:12.949+0530 [initandlisten] MongoDB starting : pid=19900 port=27017 dbpath=/data/db 64-bit host=Sanjeet-Suhags-MacBook-Pro.local
2014-04-24T09:18:12.949+0530 [initandlisten] 
2014-04-24T09:18:12.949+0530 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2014-04-24T09:18:12.949+0530 [initandlisten] db version v2.6.0
2014-04-24T09:18:12.949+0530 [initandlisten] git version: nogitversion
2014-04-24T09:18:12.949+0530 [initandlisten] build info: Darwin minimavericks.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2014-04-24T09:18:12.949+0530 [initandlisten] allocator: tcmalloc
2014-04-24T09:18:12.949+0530 [initandlisten] options: {}
2014-04-24T09:18:12.949+0530 [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
2014-04-24T09:18:12.949+0530 [initandlisten] dbexit: 
2014-04-24T09:18:12.949+0530 [initandlisten] shutdown: going to close listening sockets...
2014-04-24T09:18:12.949+0530 [initandlisten] shutdown: going to flush diaglog...
2014-04-24T09:18:12.949+0530 [initandlisten] shutdown: going to close sockets...
2014-04-24T09:18:12.950+0530 [initandlisten] shutdown: waiting for fs preallocator...
2014-04-24T09:18:12.950+0530 [initandlisten] shutdown: lock for final commit...
2014-04-24T09:18:12.950+0530 [initandlisten] shutdown: final commit...
2014-04-24T09:18:12.950+0530 [initandlisten] shutdown: closing all files...
2014-04-24T09:18:12.950+0530 [initandlisten] closeAllFiles() finished
2014-04-24T09:18:12.950+0530 [initandlisten] shutdown: removing fs lock...
2014-04-24T09:18:12.950+0530 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
2014-04-24T09:18:12.950+0530 [initandlisten] dbexit: really exiting now
Sanjeet-Suhags-MacBook-Pro:~ sanjeetsuhag$ 

出了什么问题?

修改

Sanjeet-Suhags-MacBook-Pro:~ sanjeetsuhag$ ls -ld /data/db
drwxr-xr-x  2 root  wheel  68 Apr 24 09:15 /data/db
Sanjeet-Suhags-MacBook-Pro:~ sanjeetsuhag$ whoami
sanjeetsuhag
Sanjeet-Suhags-MacBook-Pro:~ sanjeetsuhag$ 

2 个答案:

答案 0 :(得分:5)

问题是mongod尝试写入的文件归root所有,但您以用户mongod的身份运行sanjeetsuhag

正确的解决方法是通过命令更改目录的所有权:

$ sudo chown -R sanjeetsuhag /data/db

这将使目录及其下的所有内容由您运行mongod的同一用户所拥有,这将允许它启动。

答案 1 :(得分:0)

我有同样的问题。我用自制软件安装了MongoDB。

我认为这需要管理层的支持。

我使用过:sudo mongod它对我来说很好用。请试一试。