# SpringBoot 连接redis-cluster集群
# 项目依赖
Springboot整合redis很简单,引入redis依赖即可
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
1
2
3
4
5
2
3
4
5
# 单机版连接
SpringBoot连接单个配置文件如下:
spring:
redis:
port: 6379
host: localhost
password: 123456
database: 1
timeout: 10000
jedis:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# 集群连接
默认已经安装redis集群,我这里是三个主节点(一个mater+一个salve)
spring:
redis:
cluster:
nodes: 192.168.1.251:7001,192.168.1.251:7002,192.168.1.252:7001,192.168.1.252:7002,192.168.1.253:7001,192.168.1.253:7002
password: 123456
database: 1
timeout: 10000
jedis:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13