Mac 如何安装 redis

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 ~ % 

通过@来指定版本,上面没指定版本的默认是最新版本

  1. 通过brew services 来启动(后台启动) 推荐
  2. 启动: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
 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值