springboot redis哨兵配置
时间: 2023-09-15 22:22:03 浏览: 142
在Spring Boot中配置Redis哨兵模式需要进行以下步骤:
1. 首先,在Redis服务器上创建一个主从复制的配置文件redis.windows.conf,并修改配置如下:
```
port 6379
bind 127.0.0.1
dir "C:\\redis-master"
replicaof no one
```
2. 拷贝redis.windows.conf文件,将其复制并重命名为slave1.conf和slave2.conf。然后,分别修改这两个配置文件的端口号和目录路径,例如:
```
slave1.conf:
port 6380
dir "C:\\redis-slave1"
slave2.conf:
port 6381
dir "C:\\redis-slave2"
```
3. 接下来,创建哨兵的配置文件sentinel1.conf、sentinel2.conf和sentinel3.conf,配置如下:
```
sentinel1.conf:
bind 0.0.0.0
port 26379
dir "C:\\redis-sentinel1"
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel2.conf:
bind 0.0.0.0
port 36379
dir "C:\\redis-sentinel2"
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel3.conf:
bind 0.0.0.0
port 46379
dir "C:\\redis-sentinel3"
sentinel monitor mymaster 127.0.0.1 6379 2
```
4. 在Spring Boot的配置文件中,配置Redis的哨兵模式。例如,application.properties文件中的配置如下:
```
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=127.0.0.1:26379,127.0.0.1:36379,127.0.0.1:46379
```
通过以上步骤,你就成功地在Spring Boot中配置了Redis的哨兵模式。配置文件中的端口号和目录路径需要根据实际情况进行修改。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [SpringBoot Redis 哨兵配置(一主两从三哨兵配置)](https://blog.csdn.net/qq_34125349/article/details/89175908)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)