【问题标题】:Running `mongo` produces `Operation timed out` when using `brew services`使用 `brew services` 时运行 `mongo` 会产生 `Operation timed out`
【发布时间】:2021-11-29 06:39:33
【问题描述】:

我正在使用 brew services 在我的 M1 Mac 上启动 mongodb-community。但是,当我尝试运行 mongo 或在另一台机器上连接到它时,我收到了错误 Operation timed out

根据brew services lsstarted,看起来没有任何错误。

当运行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


    【解决方案1】:

    通过在Security &amp; Privacy 中授予mongod 权限解决了这个问题。

    系统偏好设置 > 安全和隐私 > 隐私 > 文件和文件夹 > mongod > 可移动卷(应该检查)

    【讨论】:

      猜你喜欢
      • 2016-03-17
      • 2021-12-06
      • 2019-09-17
      • 2011-06-02
      • 2012-02-22
      • 1970-01-01
      • 2014-08-19
      • 2018-03-29
      • 1970-01-01
      相关资源
      最近更新 更多