通过命令启动redis-sentinel /etc/sentinel/5000.conf ,我是把sentinel.conf放到了/etc/sentinel/目录下,并且改了名字为5000.conf,当然默认直接用:redis-sentinel sentinel.conf启动即可

[root@eshop-cache02 init.d]# redis-sentinel /etc/sentinel/5000.conf 
25645:X 11 Aug 23:03:01.257 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.8 (00000000/0) 32 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 5000
 |    `-._   `._    /     _.-'    |     PID: 25645
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

25645:X 11 Aug 23:03:01.257 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
25645:X 11 Aug 23:03:01.257 # Sentinel ID is c2cf0a7da0a3d9de95d6d7b675c219a39fbf0eda
25645:X 11 Aug 23:03:01.257 # +monitor master mymaster 192.168.1.21 6379 quorum 2
25645:X 11 Aug 23:03:31.273 # +sdown master mymaster 192.168.1.21 6379

观察日志发现启动没多久,就发现master 宕机了。于是,我检查了下我的主从架构的master node节点,发现没有问题呀,正常运行着,那为什么会直接sdown呢?
我突然想到master node节点上设置的有密码,也就是redis.confrequirepass 后面配置的密码,当然在slave node节点上也是配置了masterauth ,用来连接master node的。

这个时候就发现可能是因为没配置密码验证,所导致的sdown master,检查了下配置,果然没有配置密码验证。
sentinel.conf中找到了sentinel auth-pass <master-name> <password>,配置如下:
在这里插入图片描述

继续启动哨兵redis-sentinel /etc/sentinel/5000.conf
在这里插入图片描述

接下来又报错了,意思是没有指定名称的主机。

mymaster本身就是自定义的,那为什么会没有找到mymaster呢?

会不会有可能是没有连上master node的机器呢?

于是看了下我的配置,如下:
在这里插入图片描述

sentinel monitor mymaster 192.168.1.21 6379 2  这里的配置的ip是master node的ip

仔细检查了下,也没错呀。这时忽然有个想法,就是会不会是加载顺序的原因呢?
先找到对应机器的ip,再走其他配置参数呢?下面我就调整了下顺序
在这里插入图片描述

再次启动哨兵redis-sentinel /etc/sentinel/5000.conf

[root@eshop-cache03 ~]# redis-sentinel /etc/sentinel/5000.conf 
30674:X 12 Aug 11:56:40.644 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.8 (00000000/0) 32 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 5000
 |    `-._   `._    /     _.-'    |     PID: 30674
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

30674:X 12 Aug 11:56:40.645 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
30674:X 12 Aug 11:56:40.645 # Sentinel ID is a90e0bf4763585e5ba107b724c57e4300aba2c8e
30674:X 12 Aug 11:56:40.645 # +monitor master mymaster 192.168.1.21 6379 quorum 2
30674:X 12 Aug 11:56:40.648 * +slave slave 192.168.1.22:6379 192.168.1.22 6379 @ mymaster 192.168.1.21 6379
30674:X 12 Aug 11:56:40.758 * +slave slave 192.168.1.23:6379 192.168.1.23 6379 @ mymaster 192.168.1.21 6379

这时候哨兵就监听到了master nodeslave node

接下来又遇到了个问题。先说下当时的场景:我用了三台机器,ip最后一位分别是21、22、23的机器。21部署的是master node,22、23部署的是slave node。三台机器上分别部署的有sentinel哨兵。
当时出现的问题是这样的,我启动了三个哨兵后,发现21、22机器都能互相检测到,只有23的机器不一会就sdwon了,于是就检查了所有23机器的sentinel.conf配置,发现没有问题,几乎跟22机器的配置一模一样。

那为什么会检测不到23机器呢?

最终发现是redis默认开启保护模式,21和22都修改了,23忘记修改了,于是出现了上面的问题,21和22都检测不到23机器的sentinel和slave了。
在这里插入图片描述

GitHub 加速计划 / sentine / Sentinel
22.24 K
7.98 K
下载
alibaba/Sentinel: Sentinel 是阿里巴巴开源的一款面向分布式服务架构的流量控制、熔断降级组件,提供实时监控、限流、降级和系统保护功能,适用于微服务治理场景。
最近提交(Master分支:2 个月前 )
195150bc * fix issue 2485 which occur oom when using async servlet request. * optimize imports * 1. fix the same issue in the webmvc-v6x 2. improve based on review comments 1 个月前
b78b09d3 1 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐