在Mac OS X中,使用homebrew安装的redis无法自动启动的问题

因为有很多人写了关于Redis安装方法的指南,所以只要按照这些方法操作应该是可以的,但不知道为什么自动启动没有成功。

手順は単純にこれ。ちなみにtmux上でlaunchctlを使うとうまくいかないので注意(前にどハマりした)。

$ brew install redis
$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

こんな感じのログが出力されていた。

Feb 23 12:21:34 mac-mini com.apple.xpc.launchd[1] (homebrew.mxcl.redis): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Feb 23 12:21:44 mac-mini com.apple.xpc.launchd[1] (homebrew.mxcl.redis[1959]): Service could not initialize: 15D21: xpcproxy + 12644 [1472][13E77DA5-3602-31BF-B074-49D4EE27E9D8]: 0xd
Feb 23 12:21:44 mac-mini com.apple.xpc.launchd[1] (homebrew.mxcl.redis): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Feb 23 12:21:54 mac-mini com.apple.xpc.launchd[1] (homebrew.mxcl.redis[1961]): Service could not initialize: 15D21: xpcproxy + 12644 [1472][13E77DA5-3602-31BF-B074-49D4EE27E9D8]: 0xd
Feb 23 12:21:54 mac-mini com.apple.xpc.launchd[1] (homebrew.mxcl.redis): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

原因はこれ。ログファイルがroot権限になってた。

$ ls -l /usr/local/var/log/redis.log
-rw-r--r--  1 root  admin  46336  2 23 12:31 /usr/local/var/log/redis.log

一般ユーザーに権限を戻して再度lanchctl loadをかけたらちゃんと起動しました。

$ sudo chown username /usr/local/var/log/redis.log

由于lanchctl没有提供任何关于问题原因的日志,我有点费了些周折。

广告
将在 10 秒后关闭
bannerAds