
哨兵模式配置
##⾸先实现三个redis实例之间的主从配置(如上)
## 创建并启动三个哨兵
## 拷⻉sentinel.conf⽂件三份:sentinel-26380.conf sentinel-26382.conf
sentinel-26382.conf
## 创建sentinelconf⽬录
[root@theo redis-5.0.5]# mkdir sentinelconf
## 拷⻉sentinel.conf⽂件到 sentinelconf⽬录:sentinel-26380.conf
[root@theo redis-5.0.5]# cat sentinel.conf | grep -v "#" | grep -v "^$" > sentinelconf/sentinel-26380.conf
[root@theo redis-5.0.5]# cd sentinelconf/
[root@theo sentinelconf]# ll
total 4
-rw-r--r-- 1 root root 326 May 19 17:09 sentinel-26380.conf
## 编辑 sentinelconf/sentinel-26380.conf⽂件
[root@theo sentinelconf]# vim sentinel-26380.conf
port 26380
daemonize no
pidfile "/var/run/redis-sentinel-26380.pid"
logfile ""
dir "/tmp"
sentinel deny-scripts-reconfig yes
# 此处配置默认的主库的ip 和端⼝ 最后的数字是哨兵数量的⼀半多⼀个
sentinel monitor mymaster 127.0.0.1 6380 2
sentinel config-epoch mymaster 1
sentinel leader-epoch mymaster 1
protected-mode no
[root@theo sentinelconf]# sed 's/26380/26381/g' sentinel-26380.conf > sentinel-26381.conf
[root@theo sentinelconf]# sed 's/26380/26382/g' sentinel-26380.conf > sentinel-26382.conf