macOS 11.5 安装、使用redis

1,379 阅读1分钟

看了写网络上的方法,基本都是使用homebrew进行安装,但是执行下面安装语句时

brew install redis

会报错:

Error: Could not find an SDK that supports macOS 11.5.
You may have have an outdated or incompatible CLT.
Homebrew found the following SDKs in the CLT install:
  10.14
  10.15

网络上查了,大该说在macOS Big Sur上brew有些不支持,正在更新。。。 image.png

没想花时间在研究brew上,所以我选择了最直接了当的手动安装: 首先进入redis官网:redis.io/download

下载稳定版本的redis。 image.png

本地解压后,将redis文件夹移动到/usr/local/目录下,然后打开终端,进入到/usr/local/目录,进行编译和安装:

cd /usr/local/redis-6.2.5
make
make install

然后执行redis-server可以启动redis服务。 image.png 再重新打开一个终端,输入:

redis-cli

即可进入。 image.png

关闭服务,可以在终端输入下面指令:

redis-cli shutdown

也可以查出redis对应的pid,进行强制停止。

ps aux|grep redis
kill -9 查出来的pid

image.png

另外我们还可以设置daemonize守护进程(默认为no),打开redis.conf文件,找到daemonize,将no改为yes即可,输入以下指令:

cd /usr/local/redis-6.2.5
vim redis.conf

image.png 在该模式下,redis会在后台运行,并将进程pid号写入至redis.conf选项pidfile设置的文件中,此时redis将一直运行,除非手动kill该进程。

参考:

Redis daemonize介绍 www.jianshu.com/p/5a187bfd4…

mac os 安装 redis www.jianshu.com/p/3bdfda703…