Redis Sentinel哨兵功能

 

請在我的開源博文:Redis 主從複製Replication功能 https://blog.csdn.net/dong19891210/article/details/106669143的基礎上看下文,我是接着續寫

把redis默認Sentinel配置文件sentinel.conff重命名爲sentinelMaster.conf(名字可以隨便起,但最好一看名字就知道意思)

mv  sentinel.conf  sentinelMaster.conf

然後通過複製sentinelMaster.conf的方式生成兩個salve配置文件:sentinelSlave01.conf和sentinelSlave02.conf

cp  sentinelMaster.conf  sentinelSlave01.conf
cp  sentinelMaster.conf  sentinelSlave02.conf

分別一一修改三個配置文件vim  sentinelMaster.conf修改以下參數內容:

然後依次啓動三個哨兵節點:

redis-sentinel  /dgm/redis/sentinelMaster.conf
redis-sentinel  /dgm/redis/sentinelSlave01.conf
redis-sentinel  /dgm/redis/sentinelSlave02.conf

檢查驗證Sentinel狀態,連接任意Sentinel節點:

[root@master redis]# redis-cli  -h 192.168.8.200 -p 26379 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.8.200:26379> info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=127.0.0.1:6379,slaves=2,sentinels=3
192.168.8.200:26379> 

可觀察到master地址,端口正確。slave節點,sentinel節點數量正確。

sentinel monitor mymaster 127.0.0.1 6379 2
配置代表節點需要監控127.0.0.1:6379這個主節點,2代表判斷主節點失敗至少需要2個Sentinel節點同意,mymaster是主節點的別名。

 

配置代碼已上傳:https://github.com/dongguangming/java/tree/master/redis

 

參考:

0、Redis Sentinel Documentation

https://redis.io/topics/sentinel

1、 《Redis官方文檔》sentinel  https://ifeve.com/redis-sentinel/

2、Redis哨兵(Sentinel)模式  https://www.jianshu.com/p/06ab9daf921d

3.  Redis Sentinel高可用   http://www.bjpowernode.com/tutorial_redis/340.html

4. 基於Sentinel的Redis高可用方案 http://www.360doc.com/content/15/0323/17/5054188_457454442.shtml

5、How to Setup Redis For High Availability with Sentinel in CentOS 8   https://www.tecmint.com/setup-redis-high-availability-with-sentinel-in-centos-8/

6. redis sentinel設計與實現 http://www.blogjava.net/jinfeng_wang/archive/2016/12/14/432107.html

7. redis哨兵(Sentinel)模式詳解  https://zhuanlan.zhihu.com/p/67917170

8.  redis sentinel 中的一個坑bind 順序  https://blog.51cto.com/axe999/2338530

9. redis主從設置以及通過Sentinel(哨兵)實現的高可用  https://blog.51cto.com/kerry/2341308?source=dra

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章