【发布时间】:2021-11-29 06:39:33
【问题描述】:
我正在使用 brew services 在我的 M1 Mac 上启动 mongodb-community。但是,当我尝试运行 mongo 或在另一台机器上连接到它时,我收到了错误 Operation timed out。
根据brew services ls 是started,看起来没有任何错误。
当运行mongod --config /opt/homebrew/etc/mongod.conf 并尝试再次连接时,它工作正常。
查看Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist 文件时,一切看起来都是正确的:
...
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/opt/mongodb-community/bin/mongod</string>
<string>--config</string>
<string>/opt/homebrew/etc/mongod.conf</string>
</array>
...
在我尝试将数据文件夹复制到外部硬盘驱动器后,此问题开始发生。
作为参考,我的 /opt/homebrew/etc/mongod.conf 文件如下所示:
systemLog:
destination: file
path: /opt/homebrew/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /Volumes/Drive13_A/mongodb
net:
bindIp: 0.0.0.0
关于为什么在直接使用 brew services 而不是 mongod 时会失败的任何想法?
编辑:
重启电脑后brew services ls现在报错了。查看日志我看到了这个条目:
{"t":{"$date":"2021-10-09T16:18:50.166-06:00"},"s":"E", "c":"CONTROL", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"DBPathInUse: Unable to create/open the lock file: /Volumes/Drive13_A/mongodb/mongod.lock (Operation not permitted). Ensure the user executing mongod is the owner of the lock file and has the appropriate permissions. Also make sure that another mongod instance is not already running on the /Volumes/Drive13_A/mongodb directory"}}
不存在/Volumes/Drive13_A/mongodb/mongod.lock 文件,我运行了chmod -R 777 /Volumes/Drive13_A/mongodb(它应该修复权限),但它仍然不起作用。
【问题讨论】:
标签: mongodb macos homebrew apple-m1