gpt4 book ai didi

macos - MongoDB 无法在 Mac 上启动

转载 作者:可可西里 更新时间:2023-11-01 09:59:11 26 4
gpt4 key购买 nike

我通过 Homebrew 安装了 MongoDB。手动创建了/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$

最佳答案

问题是 mongod 试图写入的文件属于 root 但您正在以用户 身份运行 mongod sanjeetsuhag.

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

$ sudo chown -R sanjeetsuhag /data/db

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

关于macos - MongoDB 无法在 Mac 上启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23259471/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com