本篇文章主要讲述了Mac下Redis的安装的两种方法和使用的经验:第一种通过用brew安装(可能是由于网络原因我没有下载成功,安装失败);第二种官网下载安装包进行安装(安装成功)
一、redis 安装 和启动
用brew安装
1.查看系统是否已经安装了Redis
brew info redis
这个命令会展示此系统下的redis信息,如果没有安装,会展示not install
2.输入命令安装Redis
brew install redis
可能需要等一会,系统下载完redis的包,会自动进行安装
3.启动redis
brew services start redis
这个命令会在后台启动redis服务,并且每一次登录系统,都会自动重启
4.假如你不需要后台启动服务,你可以使用配置文件启动:
redis-server /usr/local/etc/redis.conf
这个命令会读取redis的配置文件,并且在redis运行的过程中也会看到实时的日志打印。启动成功,如下所示:
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 52462
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
5.连接redis
需要新打开一个终端,再输入如下的命令:
# 不需要身份认证时
redis-cli -p 6379 -h 127.0.0.1
# 需要身份认证时,输入如下命令
redis-cli -p 6379 -h 127.0.0.1 -a yourpassword
# or
redis-cli -p 6379 -h 127.0.0.1
# 登录进去之后再进行身份认证
127.0.0.1:6379> auth 0903
官网下载安装包进行安装
下载稳定版安装包:redis官网下载,选择Stable版本进行安装Latest Stable
下载完成后进入到安装包的目录,依次输入如下的命令:
# 移动
sudo mv redis-stable.tar.gz /usr/local
# 切换到目录
cd /usr/local
# 解压
sudo tar zxvf redis-stable.tar.gz
# 切换到redis-stable目录
cd redis-stable
# 编译测试
sudo make test
# 编译安装
sudo make install
执行sudo make install,看到下面结果安装成功:
(base) cuixin@cuixindeMacBook-Pro redis-stable % sudo make install
cd src && /Applications/Xcode.app/Contents/Developer/usr/bin/make install
/bin/sh: pkg-config: command not found
CC Makefile.dep
/bin/sh: pkg-config: command not found
INSTALL redis-sentinel
INSTALL redis-check-rdb
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
redis的启动和停止
启动redis:redis-server
(base) cuixin@cuixindeMacBook-Pro etc % redis-server
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 52462
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
52462:M 26 Oct 2022 14:35:16.935 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
52462:M 26 Oct 2022 14:35:16.935 # Server initialized
52462:M 26 Oct 2022 14:35:16.936 * Ready to accept connections
链接redis:
(base) cuixin@cuixindeMacBook-Pro redis-stable % redis-cli -p 6379 -h 127.0.0.1
127.0.0.1:6379> set name 'james'
OK
127.0.0.1:6379> get name
"james"
127.0.0.1:6379>
参考链接:mac安装redis教程
本篇文章主要讲述了Mac下Redis的安装的两种方法和使用的经验:第一种通过用brew安装(可能是由于网络原因我没有下载成功,安装失败);第二种官网下载安装包进行安装(安装成功)
一、redis 安装 和启动
用brew安装
1.查看系统是否已经安装了Redis
brew info redis
这个命令会展示此系统下的redis信息,如果没有安装,会展示not install
2.输入命令安装Redis
brew install redis
可能需要等一会,系统下载完redis的包,会自动进行安装
3.启动redis
brew services start redis
这个命令会在后台启动redis服务,并且每一次登录系统,都会自动重启
4.假如你不需要后台启动服务,你可以使用配置文件启动:
redis-server /usr/local/etc/redis.conf
这个命令会读取redis的配置文件,并且在redis运行的过程中也会看到实时的日志打印。启动成功,如下所示:
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 52462
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
5.连接redis
需要新打开一个终端,再输入如下的命令:
# 不需要身份认证时
redis-cli -p 6379 -h 127.0.0.1
# 需要身份认证时,输入如下命令
redis-cli -p 6379 -h 127.0.0.1 -a yourpassword
# or
redis-cli -p 6379 -h 127.0.0.1
# 登录进去之后再进行身份认证
127.0.0.1:6379> auth 0903
官网下载安装包进行安装
下载稳定版安装包:redis官网下载,选择Stable版本进行安装Latest Stable
下载完成后进入到安装包的目录,依次输入如下的命令:
# 移动
sudo mv redis-stable.tar.gz /usr/local
# 切换到目录
cd /usr/local
# 解压
sudo tar zxvf redis-stable.tar.gz
# 切换到redis-stable目录
cd redis-stable
# 编译测试
sudo make test
# 编译安装
sudo make install
执行sudo make install,看到下面结果安装成功:
(base) cuixin@cuixindeMacBook-Pro redis-stable % sudo make install
cd src && /Applications/Xcode.app/Contents/Developer/usr/bin/make install
/bin/sh: pkg-config: command not found
CC Makefile.dep
/bin/sh: pkg-config: command not found
INSTALL redis-sentinel
INSTALL redis-check-rdb
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
redis的启动和停止
启动redis:redis-server
(base) cuixin@cuixindeMacBook-Pro etc % redis-server
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 52462
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
52462:M 26 Oct 2022 14:35:16.935 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
52462:M 26 Oct 2022 14:35:16.935 # Server initialized
52462:M 26 Oct 2022 14:35:16.936 * Ready to accept connections
链接redis:
(base) cuixin@cuixindeMacBook-Pro redis-stable % redis-cli -p 6379 -h 127.0.0.1
127.0.0.1:6379> set name 'james'
OK
127.0.0.1:6379> get name
"james"
127.0.0.1:6379>
参考链接:mac安装redis教程