redis sentinel 配置文件参数:

[root@hankyoon ~]# vi /etc/redis/6379.conf  
  
bind 127.0.0.1 192.168.1.222  #redis服务器地址  
port 26379                    #sentinel端口号  
daemonize yes                 #后台启动  
protected-mode no             #关闭保护模式,禁止远程直接访问  
requirepass 654321            #本地访问需要密码  
masterauth 654321             #备端同步访问需要密码  
slave-read-only yes           #备端只读

port 26379  #Sentinel 配置文件参数:

#sentinel monitor myredis 192.168.1.xxx 6379 1   #监控 人员组名/ip/端口/失效判定数(多少从端判断不同则认为master断开)  
#sentinel down-after-milliseconds myredis 10000  #ping 超过 10000 毫秒则认为宕机  
#sentinel failover-timeout myredis 900000        #主从切换超过 30000 毫秒则认为失败  
#sentinel can-failover myredis yes               #master断开后是否允许判断进行故障转移  
#sentinel parallel-syncs myredis 1               #从端继续同步新master的数量 

port 26379
bind 0.0.0.0
dir "/u01/redis/6379/tmp"
logfile "/u01/redis/6379/log/sentinel_26379.log"

#redis_activity_6379
daemonize yes
sentinel myid fe7a0b89dae26cc7f8ad3849c56602a3bac315d8
sentinel monitor myredis 192.168.1.108 6379 1
sentinel down-after-milliseconds myredis 10000
sentinel failover-timeout myredis 60000

# Generated by CONFIG REWRITE
sentinel parallel-syncs myredis 2
sentinel auth-pass myredis c2D0RMfS21Jb
sentinel config-epoch myredis 38
sentinel leader-epoch myredis 35
sentinel known-slave myredis 192.168.1.106 6379
sentinel known-slave myredis 192.168.1.107 6379
sentinel known-sentinel myredis 192.168.1.107 26379 b315c05b3ee648dd1dc2d8cbe177657fe4580eba
sentinel known-sentinel myredis 192.168.1.106 26379 3761886889258c719c53141510ec91b980660189
sentinel current-epoch 38

redis sentinel 相关命令:

127.0.0.1:26379> SENTINEL masters             #列出所有master状态信息  
127.0.0.1:26379> SENTINEL master myredis      #列出某个master状态信息 
127.0.0.1:26379> SENTINEL slaves myredis      #列出某个master的所有slave和状态信息
127.0.0.1:26379> SENTINEL sentinels myredis   #列出某个master的sentinels 
127.0.0.1:26379> SENTINEL get-master-addr-by-name myredis #通过某个master获取其IP及port  
127.0.0.1:26379> SENTINEL ckquorum myredis    #检查某个master是达到投票及故障转移条件
127.0.0.1:26379> SENTINEL flushconfig            #强制重写 SENTINEL 配置到磁盘文件中  
127.0.0.1:26379> SENTINEL failover myredis    #这个操作就注意了!强制进行故障转移!慎操作!