Redis由于tcp-backlog无法启动

4
我正在使用OSX并尝试通过Brew安装Redis。
brew install redis
==> Downloading http://download.redis.io/releases/redis-2.8.17.tar.gz
Already downloaded: /Library/Caches/Homebrew/redis-2.8.17.tar.gz
==> make -C /private/tmp/redis-WEL8AT/redis-2.8.17/src CC=clang
==> Caveats
To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf
==> Summary

最终我已经安装了redis,但是当我以以下方式运行它时:
redis-server /usr/local/etc/redis.conf

出现错误信息,

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 54
>>> 'tcp-backlog 511'
Bad directive or wrong number of arguments

我从 Redis tcp-backlog中学到了需要取消注释redis.conf文件中的那一行。但是其他行仍然存在更多的错误。怎么解决呢?


1
只需使用与实际Redis版本对应的配置文件。检查您启动的redis-server是否与您认为已安装的版本相对应。 - Didier Spezia
当前的Redis配置是在从Brew安装Redis后自动生成的。因此,通常它应该对应于正确的Redis版本,不是吗? - user824624
2个回答

15

检查是否安装了两次Redis。在我的情况下,我有另一个来自Anaconda的Redis安装,版本为2.6.9:

检查是否安装了两次Redis。在我的情况下,我有另一个来自Anaconda的Redis安装,版本为2.6.9:

$ which redis-server
/Users/<username>/anaconda/bin/redis-server
$ redis-server -v
Redis server v=2.6.9 sha=00000000:0 malloc=libc bits=64

Homebrew会将redis-server安装到不同的位置:

$ /usr/local/bin/redis-server -v
Redis server v=3.0.1 sha=00000000:0 malloc=libc bits=64 build=bf58331b4c8133f5

要使用自制配置文件启动自制版本,请执行以下操作:

$ /usr/local/bin/redis-server /usr/local/etc/redis.conf

谢谢@asmaier,你真的帮了我很多。 - Eric
这也是我的问题。谢谢! - Kent

0

我曾经遇到过类似的问题,由于之前版本的Redis留下了配置文件。卸载所有Redis版本并重新安装最新版本即可解决问题(另外,在安装Redis之前不要忘记更新brew):

brew uninstall redis --force
brew update
brew install redis

现在你应该可以启动它了。


谢谢,SBBS。我仍然遇到了问题,显示:*** 致命配置文件错误 *** 在读取配置文件时,在第90行
'tcp-keepalive 0' 指令错误或参数数量不正确
- user824624
@user824624,使用brew uninstall redis --force卸载redis应该会删除配置文件。如果没有被删除,请在卸载后手动运行$ rm /usr/local/etc/redis.conf进行删除。然后安装redis,它应该可以正常工作。不要忘记在安装redis之前更新brew。 - Sbbs

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接