我正在使用Spring Boot应用程序在Redis中使用哨兵实现主从服务器。当使用哨兵创建JedisSentinelPool时,出现以下错误



下面是代码。

        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);

我的问题是如何运行哨兵以及如何解决此问题。任何帮助都将受到赞赏。

提前致谢。

最佳答案

将您的ip address绑定(bind)到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

09-09 21:14