1. 引入 redis 依赖
<!-- 引入 redis 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2. 当节点配置redis
spring:
redis:
database: 1
host: 192.168.174.134
port: 6379
password: test
2. 哨兵模式配置redis
spring:
redis:
# Redis 哨兵模式
database: 1
password: imooc
sentinel:
master: imooc-master
nodes: 192.168.174.134:26379,192.168.174.135:26379,192.168.174.136:26379
3. 集群模式
spring:
redis:
database: 1
password: imooc
cluster:
nodes: 192.168.174.137:6379,192.168.174.138:6379,192.168.174.139:6379,192.168.174.140:6379,192.168.174.141:6379,192.168.174.142:6379