巴拉巴拉
小魔仙

brew安装redis

0x00 搜索redis

brew search redis
==> Formulae
hiredis                    redis                      redis-leveldb              redis@3.2                  redis@4.0
==> Casks
another-redis-desktop-manager                 redis                                         redisinsight

0x01 安装redis@4.0

brew install redis@4.0
Warning: redis@4.0 has been deprecated because it is a versioned formula!
==> Downloading https://homebrew.bintray.com/bottles/redis%404.0-4.0.14_1.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/a3da3a3af97a3ca5c36c2399defd06e6cbbd0b105980b2d626f224e384adc017?response-con
######################################################################## 100.0%
==> Pouring redis@4.0-4.0.14_1.catalina.bottle.tar.gz
==> Caveats
redis@4.0 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@4.0 first in your PATH run:
  echo 'export PATH="/usr/local/opt/redis@4.0/bin:$PATH"' >> /Users/ankang/.bash_profile

To have launchd start redis@4.0 now and restart at login:
  brew services start redis@4.0
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/redis@4.0/bin/redis-server /usr/local/etc/redis.conf
==> Summary
  /usr/local/Cellar/redis@4.0/4.0.14_1: 13 files, 2.8MB

0x02 修改redis配置为守护线程

vim /usr/local/etc/redis.conf 
daemonize no改成yes

0x03启动redis服务

brew services start redis@4.0
==> Successfully started redis@4.0 (label: homebrew.mxcl.redis@4.0)

0x04 查看redis进程号

ps axu | grep redis
ankang           10751   0.0  0.0  4268324    724 s002  S+    1:18下午   0:00.00 grep redis
ankang           10747   0.0  0.0  4303732   2116   ??  S     1:18下午   0:00.01 /usr/local/opt/redis@4.0/bin/redis-server 127.0.0.1:6379  

0x05 修改环境变量

vim ~/.bash_profile
末尾添加
export PATH="/usr/local/opt/redis@4.0/bin:$PATH"

source ~/.bash_profile

0x06 登陆测试

redis-cli
127.0.0.1:6379> get hello
(nil)
127.0.0.1:6379> set hello 2018
OK
127.0.0.1:6379> get hello
"2018"
赞(0) 打赏
如果文章对你有帮助,欢迎你来评价反馈。AgainFly » brew安装redis

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  • Q Q(选填)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏