Redis配置sentinel模式

                                      作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

 

  哨兵(sentinel)主要是完成三个功能:监控,通知,自动故障转移功能。sentinel是安装Redis服务时默认安装的,因此我们可以直接使用!

 

 

一.配置项说明

1>.port

   服务的监听端口,比如:port 26479。

 

2>.sentinel monitor <master-name> <ip><redis-port><quorm>

  <quorum>表示sentinel集群的quorum机制,即至少有quorum个sentinel节点同时判断主节点故障时,才任务其真的故障。

    s_down:subjectively down

    o_down:objectively down

 

3>.semtinel auth-pass <master-name><password>

 

4>.sentinel down-afer-milliseconds <master-name><millseconds>

  监听到指定的集群的主节点异常状态持久多久方才将标记为“故障”。

 

5>.sentinel parallel-syncs <master-name> <numslaves>

  指在failover过程中,能够被sentinel并行配置的从节点的数量。

 

6>.sentinel failover-timeout <master-name> <milliseconds>

  sentinel必须在此指定的时间长内完成故障转移操作,否则,将视为故障转移操作失败。

 

7>.sentinel notification-script <master-name> <script-path>

  通知脚本,此脚本被自动传递多个参数。

 

8>.redis-cli -h SENTINEL_HOST -p SENTINEL_PORT

 

二.实操案例

1>.编写sentinel的配置文件(我们复用redis集群的虚拟机)

[root@node101.yinzhengjie.org.cn ~]# egrep -v "^$|^#" /etc/redis-sentinel.conf
bind node101.yinzhengjie.org.cn
port 26379
dir /tmp
sentinel monitor yinzhengjie-redis node101.yinzhengjie.org.cn 6379 2
sentinel auth-pass yinzhengjie-redis yinzhengjie
sentinel down-after-milliseconds yinzhengjie-redis 5000
sentinel parallel-syncs yinzhengjie-redis 2
sentinel failover-timeout yinzhengjie-redis 180000
logfile /var/log/redis/sentinel.log
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# egrep -v "^$|^#" /etc/redis-sentinel.conf

相关文章:

  • 2021-10-10
  • 2021-11-21
  • 2019-01-10
  • 2019-03-15
  • 2022-01-27
  • 2022-01-12
  • 2021-07-06
猜你喜欢
  • 2021-06-29
  • 2021-11-29
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
相关资源
相似解决方案