版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/realize_dream/article/details/106227622
brew install redis
注意:
如果电脑没有安装Homebrew,需要先执行:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
执行完脚本后,噼里啪啦输出一堆,当看到以下代码时,表示已成功安装!
==> redis To have launchd start redis now and restart at login: brew services start redis Or, if you don't want/need a background service you can just run: redis-server /usr/local/etc/redis.conf
Homebrew安装的软件会默认在/usr/local/Cellar/路径下
hyuga@iMac > ~ > cd /usr/local/Cellar/ hyuga@iMac /usr/local/Cellar ll total 0 drwxr-xr-x 3 hyuga staff 96B 11 8 13:36 gettext drwxr-xr-x 3 hyuga staff 96B 11 8 13:37 git drwxr-xr-x 3 hyuga staff 96B 9 13 19:10 highlight drwxr-xr-x 3 hyuga staff 96B 9 13 19:10 lua drwxr-xr-x 3 hyuga staff 96B 12 13 13:37 openssl@1.1 drwxr-xr-x 3 hyuga staff 96B 11 8 13:37 pcre2 drwxr-xr-x 3 hyuga staff 96B 12 13 13:37 redis
redis的配置文件redis.conf存放在/usr/local/etc路径下
hyuga@iMac > /usr/local/Cellar > cd /usr/local/etc hyuga@iMac > /usr/local/etc > ll total 200 drwxr-xr-x 6 hyuga admin 192B 12 13 13:38 bash_completion.d -rw-r--r-- 1 hyuga admin 35B 11 8 13:37 gitconfig drwxr-xr-x 3 hyuga admin 96B 9 13 19:10 highlight drwxr-xr-x 8 hyuga admin 256B 12 13 13:37 openssl@1.1 -rw-r--r-- 1 hyuga admin 10K 12 13 13:37 redis-sentinel.conf -rw-r--r-- 1 hyuga admin 83K 12 13 13:37 redis.conf
brew services start/stop/restart redis 后台启动
brew services start/stop/restart redis
redis-server /usr/local/etc/redis.conf 或 ``redis-server` 前台启动
redis-server /usr/local/etc/redis.conf
带不带配置文件皆可,只要不把默认配置文件挪了位置。
PS: 如果想以守护进程的方式运行(后台运行),可以在redis.conf中将daemonize no,修改成yes即可。
redis-cli shutdown
sudo pkill redis-server
ps axu | grep redis 或 ps -ef | grep redis
ps axu | grep redis
ps -ef | grep redis
hyuga@iMac > /usr/local/etc > ps -ef|grep redis 502 5604 1 0 1:56下午 ?? 0:00.03 /usr/local/opt/redis/bin/redis-server 127.0.0.1:6379 502 5669 4919 0 1:57下午 ttys002 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox redis
hyuga@iMac > /usr/local/etc > ps axu|grep redis hyuga 5719 0.0 0.0 4399356 804 s002 S+ 1:58下午 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox redis hyuga 5604 0.0 0.0 4580412 3612 ?? S 1:56下午 0:00.04 /usr/local/opt/redis/bin/redis-server 127.0.0.1:6379
如果不使用第三方客户端连接redis,如rdm等,也可以使用服务自带命令行终端redis-cli连接redis服务。 redis-cli -h 127.0.0.1 -p 6379 或 redis-cli
redis-cli -h 127.0.0.1 -p 6379
redis-cli
hyuga@iMac > /usr/local/etc > redis-cli -h 127.0.0.1 -p 6379 127.0.0.1:6379>
该方法也能用于检测redis服务是否开启。
评论