Redis 单机版安装
# 下载地址
[root@openEulerNodeOne data]# tar -zxvf redis-7.0.2.tar.gz
[root@openEulerNodeOne redis-7.0.2]# cd redis-7.0.2
[root@openEulerNodeOne redis-7.0.2]# make
[root@openEulerNodeOne redis-7.0.2]# vim redis.conf
# Redis以守护进程方式启动
daemonize no # no 修改为yes
# 注释此行,允许其他客户端登录
bind 127.0.0.1 -::1
# 放开此行,设置登录密码
requirepass 123456
protected-mode yes # 不限制IP,限制密码
线上Redis服务,为了安全,我们建议将protected-mode设置为yes。 protected-mode设置为yes的情况下,为了我们的应用服务可以正常访问Redis,我们需要设置Redis的bind参数或者密码参数requirepass
[root@openEulerNodeOne src]# cd src
[root@openEulerNodeOne src]# ./redis-server ../redis.conf
# 用客户端尝试链接,如果链接不上,关闭防火墙
# windows客户端链接工具:Redis Desktop Manager
[root@openEulerNodeOne src]# systemctl stop firewalld
# 本机链接
[root@openEulerNodeOne src]# ./redis-cli
127.0.0.1:6379>
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.127.0.0.1:6379> auth "123456"
127.0.0.1:6379> keys *
(empty array)127.0.0.1:6379> config get requirepass # 获取配置的密码
1) "requirepass"
2) "123456"
# redis-cli -h IPaddress -p 6379 -a 123456
直接点击下载已编译绿色包,上传服务器解压即可使用,默认链接密码为123456(配置需自行修改)。
springBoot整合redis使用
修改配置文件
server:
port: 8088
spring:
redis:
host: 192.168.208.50
#Redis服务器连接端口
port: 6379
#Redis服务器连接密码(默认为空)
password: 123456
#连接池最大连接数(使用负值表示没有限制)
pool:
max-active: 8
#连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1
#连接池中的最大空闲连接
max-idle: 8
#连接池中的最小空闲连接
min-idle: 0
#连接超时时间(毫秒)
timeout: 30000
启动测试:learnredis\src\main\java\com\example\learnredis\LearnredisApplication.java