我已经通过 homebrew 安装了 mongodb 2.4:
brew install homebrew/versions/mongodb24
然后我创建了一个到 homebrew 提供的配置的 simlink:
ln -sfv /usr/local/opt/mongodb24/homebrew.mxcl.mongodb24.plist ~/Library/LaunchAgents
该文件包含以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.mongodb24</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mongodb24/bin/mongod</string>
<string>--config</string>
<string>/usr/local/etc/mongod.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>WorkingDirectory</key>
<string>/usr/local</string>
<key>StandardErrorPath</key>
<string>/usr/local/var/log/mongodb/output.log</string>
<key>StandardOutPath</key>
<string>/usr/local/var/log/mongodb/output.log</string>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>1024</integer>
</dict>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>1024</integer>
</dict>
</dict>
</plist>
现在我尝试启动它并出现错误:
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb24.plist
/usr/local/Cellar/mongodb24/2.4.12/homebrew.mxcl.mongodb24.plist: Operation not permitted
似乎权限有问题。但我不确定。我该如何修复?
答案1
我已经通过使用解决了这个问题酿造服务. 首先删除符号链接:
$ rm ~/Library/LaunchAgents/homebrew.mxcl.mongodb24.plist
安装 brew 服务:
$ brew tap gapple/services
启动mongodb:
$ brew services start mongodb24
==> Successfully started `mongodb24` (label: homebrew.mxcl.mongodb24)
就是这样!
更新:
实际上,这是由于 tmux 造成的。当您在 tmux 会话中执行此操作时:
$ brew services start redis
/Users/schfkt/Library/LaunchAgents/homebrew.mxcl.redis.plist: Operation not permitted
==> Successfully started `redis` (label: homebrew.mxcl.redis)
$ brew services list
Warning: No user-space services controlled by `brew services` running...
你得到的结果是一样的:“操作不允许”。当然,redis 也没有启动。
但当你运行相同的命令时,一切都正常不是在 tmux 会话内部:
$ brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)
$ brew services list
redis started 82912 /Users/schfkt/Library/LaunchAgents/homebrew.mxcl.redis.plist