【问题标题】:Cannot get master address from sentinel running @myIpaddress:6379无法从运行 @myIpaddress:6379 的哨兵获取主地址
【发布时间】:2018-01-12 01:32:58
【问题描述】:

我正在通过 Spring Boot 应用程序在 Redis 中使用哨兵实现主从。在使用哨兵创建 JedisSentinelPool 时,我收到以下错误

无法从运行@myIpaddress:6379 的哨兵获取主地址

下面是代码。

        final String MASTER_NAME = "mymaster";
        final String PASSWORD = "empower";
        final Set sentinels;

        sentinels = new HashSet();
        sentinels.add("127.0.0.1:6379");
        sentinels.add("127.0.0.1:2222");
        sentinels.add("127.0.0.1:3333");

        JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels);

我的问题是如何运行哨兵以及如何解决此问题。任何形式的帮助表示赞赏。

提前致谢。

【问题讨论】:

  • 你解决了这个问题吗?

标签: java spring-boot redis redis-sentinel


【解决方案1】:

将您的 ip address 绑定到 127.0.0.1

# Example sentinel.conf
# By default Sentinel will not be reachable from interfaces different than
# localhost, either use the 'bind' directive to bind to a list of network
# interfaces, or disable protected mode with "protected-mode no" by
# adding it to this configuration file.
#
# Before doing that MAKE SURE the instance is protected from the outside
# world via firewalling or other means.
#
# For example you may use one of the following:
#
bind 10.10.21.192 127.0.0.1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-18
    • 1970-01-01
    • 2020-03-15
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多