Mac Redis 6.0.10 安装(Homebrew 安装)
2021-02-28 本文已影响0人
夸克星
2021年2月28日记录
1. 安装方法
# 推荐先更新brew
brew update -v
# 安装或升级到最新稳定版
brew install redis
or
brew upgrade redis
查看安装及配置文件位置
安装路径 /usr/local/Cellar/redis/6.0.10
➜ 6.0.10 redis-cli -v
redis-cli 6.0.10
➜ 6.0.10 redis-server -v
Redis server v=6.0.10 sha=00000000:0 malloc=libc bits=64 build=f02b37c7397e0d7f
➜ 6.0.10
配置文件 : /usr/local/etc/redis.conf
brew services start redis
or
redis-server /usr/local/etc/redis.conf
2. 启动方法
redis默认是前台启动,如果我们想以守护进程的方式运行(后台运行),可以在redis.conf中将
daemonize 默认值no,修改成yes即可。
设置为守护进程, 默认后台启动, 重启机器生效:
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /usr/local/var/run/redis.pid when daemonized.
daemonize no
➜ 6.0.10 brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)
➜ 6.0.10 ps aux|grep redis
ming 74212 0.0 0.0 4268040 772 s003 R+ 9:13下午 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn redis
ming 74201 0.0 0.0 4304624 3488 ?? S 9:12下午 0:00.02 /usr/local/opt/redis/bin/redis-server 127.0.0.1:6379
➜ 6.0.10
直接前台启动:
➜ redis-server
73535:C 28 Feb 2021 20:52:41.999 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
73535:C 28 Feb 2021 20:52:41.999 # Redis version=6.0.10, bits=64, commit=00000000, modified=0, pid=73535, just started
73535:C 28 Feb 2021 20:52:41.999 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
73535:M 28 Feb 2021 20:52:42.001 * Increased maximum number of open files to 10032 (it was originally set to 256).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.0.10 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 73535
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
73535:M 28 Feb 2021 20:52:42.003 # Server initialized
73535:M 28 Feb 2021 20:52:42.004 * Ready to accept connections
3. 检测状态:
ps aux|grep redis
➜ ps aux|grep redis
73591 0.0 0.0 4287496 844 s000 S+ 8:55下午 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn redis
73535 0.0 0.0 4312816 3328 s003 S+ 8:52下午 0:00.15 redis-server *:6379
➜
默认无密码, 端口6379
redis-cli
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>exit
3.关闭方法
在前台终端正确关闭: ctrl + c
^C73985:signal-handler (1614517889) Received SIGINT scheduling shutdown...
73985:M 28 Feb 2021 21:11:29.101 # User requested shutdown...
73985:M 28 Feb 2021 21:11:29.101 * Saving the final RDB snapshot before exiting.
73985:M 28 Feb 2021 21:11:29.103 * DB saved on disk
73985:M 28 Feb 2021 21:11:29.103 # Redis is now ready to exit, bye bye...
正确停止Redis的方式应该是向Redis发送SHUTDOWN命令
brew services stop redis
or
redis-cli shutdown
强行终止redis
sudo pkill redis-server