windows搭建redis哨兵报错 :启动项目时All sentinels down, cannot determine where is mymaster master is running。

时间:2025-03-18 17:30:52

All sentinels down, cannot determine where is mymaster master is running…

该错是创建redis连接池时调用一个方法导致的,如下:

public static String convertHost(String host) {
        return !host.equals("127.0.0.1") && !host.startsWith("localhost") && !host.equals("0.0.0.0") && !host.startsWith("169.254") && !host.startsWith("::1") && !host.startsWith("0:0:0:0:0:0:0:1") ? host : LOCALHOST_STR;
    }

原因:

  1. reids的配置文件把bind参数配置成了bind 127.0.0.1
  2. 还有sentinel 的配置文件 中配置成了 sentinel monitor mymaster 127.0.0.1 6380 1

解决:

  1. 去掉bind。或者把ip设置成电脑的ip
  2. sentinel 的配置文件 对应sentinel monitor mymaster ip 6380 1配置成1中的ip

详细可以参考:参考文章redis哨兵报错原因