MacOS下Redis的安装配置

本文是Mac配置系列之一:MAC下Redis4.0的安装配置。用来记录Redis的安装配置,流水账,记录备查。

使用Homebrew安装,过程很简单,如下:

george@GeorgeMBP  ~ 
 george@GeorgeMBP  ~  brew install redis@4.0
==> Downloading https://homebrew.bintray.com/bottles/redis@4.0-4.0.14.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/af/afe26b0f773f004d2bb0a5fa60970d6f9143fe7aab0d604a2e2e453fbdf70d3f?__g
######################################################################## 100.0%
==> Pouring redis@4.0-4.0.14.mojave.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"' >> ~/.zshrc

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: 13 files, 2.8MB
 george@GeorgeMBP  ~ 

按照提示,将redis的主要服务export,如下:

george@GeorgeMBP  ~ 
george@GeorgeMBP  ~   echo 'export PATH="/usr/local/opt/redis@4.0/bin:$PATH"' >> ~/.zshrc
george@GeorgeMBP  ~ 
george@GeorgeMBP  ~ 

默认安装的配置文件位置在:/usr/local/etc/redis.conf,相关配置参数比如后台运行等,都在这里修改。

常用操作,启动连接杀死进程,如下

george@GeorgeMBP  ~ 
george@GeorgeMBP  ~  redis-server /usr/local/etc/redis.conf
18032:C 01 Jul 17:43:47.573 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18032:C 01 Jul 17:43:47.573 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=18032, just started
18032:C 01 Jul 17:43:47.573 # Configuration loaded
george@GeorgeMBP  ~  ps -ef | grep redis
  501 18033     1   0  5:43下午 ??         0:00.02 redis-server 127.0.0.1:6379
  501 18042 14298   0  5:44下午 ttys001    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn redis

george@GeorgeMBP  ~ 
george@GeorgeMBP  ~  redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> get("123")
Invalid argument(s)
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> quit
george@GeorgeMBP  ~ 
george@GeorgeMBP  ~ 
george@GeorgeMBP  ~  sudo pkill redis-server\ 127.0.0.1:6379
Password:
george@GeorgeMBP  ~ 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容