Mac 如何安装 redis
通过HomeBrew包管理工具安装
cyol_wenchunyu@wenchunyudeiMac ~ % brew install redis
==> Downloading https://ghcr.io/v2/homebrew/core/redis/manifests/6.2.0
curl: (22) The requested URL returned error: 404
Error: redis: Failed to download resource "redis_bottle_manifest"
Download failed: https://ghcr.io/v2/homebrew/core/redis/manifests/6.2.0
cyol_wenchunyu@wenchunyudeiMac ~ % brew install redis@3.2
Running `brew update --auto-update`...
Warning: redis@3.2 has been deprecated because it is a versioned formula!
==> Downloading https://ghcr.io/v2/homebrew/core/redis/3.2/manifests/3.2.13_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/redis/3.2/blobs/sha256:d016b698
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring redis@3.2--3.2.13_1.big_sur.bottle.tar.gz
==> Caveats
redis@3.2 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have redis@3.2 first in your PATH, run:
echo 'export PATH="/usr/local/opt/redis@3.2/bin:$PATH"' >> ~/.zshrc
To start redis@3.2 now and restart at login:
brew services start redis@3.2
Or, if you don't want/need a background service you can just run:
/usr/local/opt/redis@3.2/bin/redis-server /usr/local/etc/redis.conf
==> Summary
🍺 /usr/local/Cellar/redis@3.2/3.2.13_1: 13 files, 1.9MB
==> Running `brew cleanup redis@3.2`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
cyol_wenchunyu@wenchunyudeiMac ~ %
通过@
来指定版本,上面没指定版本的默认是最新版本
- 通过brew services 来启动(后台启动) 推荐
- 启动:
brew services start redis@3.2
或者使用redis-server /usr/local/etc/redis.conf
启动
查看进程ps axu | grep redis
brew services start redis
启动:brew services start redis@3.2
或者使用
redis-server /usr/local/etc/redis.conf启动
查看进程
ps axu | grep redis
zzpMac:~ zzp$ redis-server /usr/local/etc/redis.conf
zzpMac:~ zzp$ ps axu | grep redis
zzp 13587 0.0 0.0 4286452 824 s001 S+ 12:04PM 0:00.00 grep redis
zzp 13217 0.0 0.0 4305336 716 ?? Ss 11:58AM 0:00.29 redis-server 127.0.0.1:6379
连接本地redis客户端
zzpMac:~ zzp$ redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set testkey testvalue
OK
127.0.0.1:6379> get testkey
"testvalue"
127.0.0.1:6379> del testkey
(integer) 1
127.0.0.1:6379> get testkey
(nil)
127.0.0.1:6379> exit
zzpMac:~ zzp$
关闭杀掉redis
zzpMac:~ zzp$ redis-cli shutdown
zzpMac:~ zzp$ sudo pkill redis-server