【问题标题】:Unable to connect redis sentinel using jedis无法使用jedis连接redis sentinel
【发布时间】:2018-11-04 12:50:54
【问题描述】:

我正在尝试使用 JedisSentinelPool 连接到 redis sentinel

private static final JedisSentinelPool pool = new JedisSentinelPool("mymaster", getSentinels());

private static Set<String> getSentinels(){

    Set<String> mysentinels = new HashSet<>();
    mysentinels.add(new HostAndPort("localhost", 26379).toString());
    return mysentinels;
}

这给了我以下错误:

原因:redis.clients.jedis.exceptions.JedisConnectionException: All sentinels down, 无法确定 mymaster master 在哪里运行...

但是,我可以看到我的哨兵正在运行。所以参考这篇文章: https://github.com/luin/ioredis/issues/64 我在我的 redis 主服务器上尝试了以下命令

./redis-cli -h redis-1 -p 26379

我收到以下错误:

无法在 redis-1:26379 连接到 Redis:提供了节点名和服务名,或者未知

这里有什么问题?

【问题讨论】:

  • 我面临着类似的问题。提供了哨兵路径,我从redis-cli 检查了我的哨兵正在运行。我仍然遇到同样的异常。

标签: redis redis-sentinel


【解决方案1】:

使用 localhost 而不是 127.0.0.1 对我有用。

默认情况下,Sentinel 将无法从不同的接口访问 localhost,或者使用'bind'指令绑定到网络列表 接口,或通过“protected-mode no”禁用保护模式 将其添加到此配置文件中。

【讨论】:

    【解决方案2】:

    确保protected-modesentinel.conf 文件中设置为no。这为我解决了问题。

    【讨论】:

      猜你喜欢
      • 2016-10-18
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      • 2015-10-13
      • 2017-12-27
      • 2018-12-29
      • 2018-07-07
      • 2022-01-11
      相关资源
      最近更新 更多