Homebrew:如何删除redis / 4.0.2并使用redis@3.2作为我的默认redis

时间:2017-10-05 20:51:52

标签: redis homebrew

我安装了redis / 3.0.3开始这个任务,并希望将我的本地dev redis升级到版本3.2.3,这是我们在生产中运行的。我最终运行了brew upgrade redis,它安装了redis 4.0.2,超出了我想要的版本。然后我发现您可以使用brew install redis@3.2安装3.2.x.此外,在尝试清理4.0.2时,它只清理了3.0.3。

现在我陷入了Homebrew不允许我卸载redis / 4.0.2,并将redis@3.2视为单独的Homebrew Formula的情况。

$ brew switch redis 3.2
Error: redis does not have a version "3.2" in the Cellar.
Versions available: 4.0.2

在酒窖中看到它们如何在这里显示为单独的公式:

$ ls  /usr/local/Cellar/ | grep redis  
redis
redis@3.2

什么是正确的" Homebrew"删除redis / 4.0.2并使用redis@3.2作为我的默认redis的方法,以便redis-serverredis-cli的命令改为引用3.2? 我' m运行Mac OS X Yosemite 10.10.5和Homebrew 1.3.4。

$ ls -l /usr/local/bin/ | grep redis
lrwxr-xr-x  1 jsoro  wheel        41 Oct  5 12:51 redis-benchmark -> ../Cellar/redis/4.0.2/bin/redis-benchmark
lrwxr-xr-x  1 jsoro  wheel        41 Oct  5 12:51 redis-check-aof -> ../Cellar/redis/4.0.2/bin/redis-check-aof
lrwxr-xr-x  1 jsoro  wheel        41 Oct  5 12:51 redis-check-rdb -> ../Cellar/redis/4.0.2/bin/redis-check-rdb
lrwxr-xr-x  1 jsoro  wheel        35 Oct  5 12:51 redis-cli -> ../Cellar/redis/4.0.2/bin/redis-cli
lrwxr-xr-x  1 jsoro  wheel        40 Oct  5 12:51 redis-sentinel -> ../Cellar/redis/4.0.2/bin/redis-sentinel
lrwxr-xr-x  1 jsoro  wheel        38 Oct  5 12:51 redis-server -> ../Cellar/redis/4.0.2/bin/redis-server

1 个答案:

答案 0 :(得分:4)

这个问题很简单,如果Brew文档/常见问题更清楚,可能会更容易。 Brew FAQs表示卸载由brew cleanup <formula>处理,这是导致我的redis / 3.0.3被删除的原因。但是,brew cleanup不会删除redis / 4.0.2。要删除它,我使用了brew uninstall,这是我在文档中找不到的...

$ brew uninstall redis
Uninstalling /usr/local/Cellar/redis/4.0.2... (11 files, 2.7MB)

然后,为了解决在/usr/local/bin/下没有符号链接的剩余问题redis@3.2,我首先尝试卸载/重新安装redis@3.2以查看Homebrew是否会处理它... < / p>

$ ls -l /usr/local/bin/ | grep redis
$ brew uninstall redis@3.2
Uninstalling /usr/local/Cellar/redis@3.2/3.2.11... (11 files, 1.7MB)
$ brew install redis@3.2
==> Downloading http://download.redis.io/releases/redis-3.2.11.tar.gz
## TRIMMED ##
==> Summary
  /usr/local/Cellar/redis@3.2/3.2.11: 11 files, 1.7MB, built in 10 seconds

当然,这并没有创建符号链接 - 实际上我从输出中删除的警告部分明确地说明了建议。我没有使用他们的建议,而是选择手动创建符号链接:

$ cd /usr/local/bin/
$ ls -l | grep redis
$
$ ln -s /usr/local/Cellar/redis\@3.2/3.2.11/bin/redis-check-aof redis-check-aof
$ ln -s /usr/local/Cellar/redis\@3.2/3.2.11/bin/redis-check-rdb redis-check-rdb
$ ln -s /usr/local/Cellar/redis\@3.2/3.2.11/bin/redis-cli redis-cli
$ ln -s /usr/local/Cellar/redis\@3.2/3.2.11/bin/redis-sentinel redis-sentinel
$ ln -s /usr/local/Cellar/redis\@3.2/3.2.11/bin/redis-server redis-server
$ ls -l | grep redis
lrwxr-xr-x  1 jsoro  wheel        54 Oct  5 14:27 redis-check-aof -> /usr/local/Cellar/redis@3.2/3.2.11/bin/redis-check-aof
lrwxr-xr-x  1 jsoro  wheel        54 Oct  5 14:27 redis-check-rdb -> /usr/local/Cellar/redis@3.2/3.2.11/bin/redis-check-rdb
lrwxr-xr-x  1 jsoro  wheel        48 Oct  5 14:27 redis-cli -> /usr/local/Cellar/redis@3.2/3.2.11/bin/redis-cli
lrwxr-xr-x  1 jsoro  wheel        53 Oct  5 14:27 redis-sentinel -> /usr/local/Cellar/redis@3.2/3.2.11/bin/redis-sentinel
lrwxr-xr-x  1 jsoro  wheel        51 Oct  5 14:26 redis-server -> /usr/local/Cellar/redis@3.2/3.2.11/bin/redis-server

最后要注意的是,由于我在redis / 4.0.2版本下运行了redis-server,因此dump.rdb文件不再兼容。在4.x dump.rdb上使用redis 3.2.x运行redis-server会导致服务器立即退出。

$ redis-server
## TRIMMED ##
38504:M 05 Oct 14:29:07.234 # Server started, Redis version 3.2.11
38504:M 05 Oct 14:29:07.259 # Can't handle RDB format version 8
38504:M 05 Oct 14:29:07.260 # Fatal error loading the DB: Invalid argument. Exiting.

不幸的是,你需要rm dump.rdb,或删除/重命名dump.rdb文件,以便让redis-server再次启动。