redis 无法开机自启
macos 版本: 10.13.6
redis 版本: 4.0.11
redis 通过编译安装(不是brew)
通过网上教程,我在 /Library/LaunchDaemons
下编辑了com.redis.plist
<?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>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>com.redis</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/redis-server</string>
<string>/Users/me/conf/redis/redis.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/Users/me/conf/redis</string>
<key>StandardErrorPath</key>
<string>/Users/me/conf/redisError.log</string>
<key>StandardOutPath</key>
<string>/Users/me/conf/redisStandardOut.log</string>
</dict>
</plist>
再此文件目录下我运行了以下命令:
launchctl load com.redis.plis
launchctl start com.redis
均无报错信息(sudo 也一样),查看redis日志文件:
2044:C 03 Nov 22:08:20.366 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2044:C 03 Nov 22:08:20.366 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=2044, just started
2044:C 03 Nov 22:08:20.366 # Configuration loaded
到此就结束了,我能确定的是redis-server
和redis.conf
的路径均无错误,我将命令复制到shell 中是可以正常启动的:
> /usr/local/bin/redis-server /Users/me/conf/redis/redis.conf
#log:
2050:C 03 Nov 22:09:18.529 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2050:C 03 Nov 22:09:18.530 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=2050, just started
2050:C 03 Nov 22:09:18.530 # Configuration loaded
2051:M 03 Nov 22:09:18.532 * Increased maximum number of open files to 10032 (it was originally set to 256).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.11 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 2051
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
2051:M 03 Nov 22:09:18.537 # Server initialized
2051:M 03 Nov 22:09:18.538 * DB loaded from disk: 0.001 seconds
2051:M 03 Nov 22:09:18.538 * Ready to accept connections