在使用Redis的哨兵Sentinel配置时,报错如下:

redis.clients.jedis.exceptions.JedisException: Can connect to sentinel, but myMaster seems to be not monitored.

报错原因:

可能是因为哨兵配置sentinel.conf中的服务器名称,和程序中哨兵连接池配置的服务器名称不一致导致的。

解决方法:

查看哨兵配置 sentinel.conf,如下:

sentinel monitor mymaster 192.168.0.102  6379 2

其中的 哨兵配置中的服务器名称为 mymaster。

接着再看java程序中的JedisSentinelPool配置的哨兵名称:

  JedisSentinelPool sentinelPool=new JedisSentinelPool("myMaster",sentinelSet,jedisPoolConfig);

程序中的服务器名称为myMaster。

可以看到,sentinel.conf中配置的服务器名称和程序中的服务器名称不一样,因此报错。。将程序中的服务器名称改正就解决了。

相关文章:

  • 2022-02-08
  • 2021-06-10
  • 2021-08-14
  • 2022-12-23
  • 2021-08-08
  • 2021-12-02
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2022-01-11
  • 2022-12-23
  • 2021-08-08
  • 2021-05-19
  • 2021-12-07
  • 2022-02-10
  • 2022-02-10
相关资源
相似解决方案