1. 程式人生 > >spring-jedis哨兵模式,不能遠端連線

spring-jedis哨兵模式,不能遠端連線

如果出現此問題,先排除以前幾點

1.bind    需要註釋起來

2.telnet  防火牆之類的就不多說了

我出現的問題是,本地可以訪問 伺服器的6379 6380,然後專案使用sentinel模式啟動就會報錯,資訊:

jedis錯誤資訊:

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

redisson 錯誤資訊 : org.redisson.client.RedisConnectionException: Can't init enough connections amount! Only 0 from 5 were initialized. Server: /127.0.0.1:6379


注意:如果你本地有redis ,配置如伺服器相同。哨兵的名字 埠等等。 專案會使用本地的redis,而不會連線伺服器的redis,這個坑了我好久。

現在說說解決方法。報錯資訊為  Can't init enough connections amount! Only 0 from 5 were initialized. Server: /127.0.0.1:6379  可是我專案中沒有配置任何 127.0.0.1的ip。

後來在sentient.conf裡面找到了這條


然後把ip改為外網的ip,然後啟動伺服器。ok,錯誤解決。

sentinel monitor mymaster  114.55.55.55(你的伺服器ip) 6379 2

提醒下各位,千萬別忘記設定密碼。要不然你的伺服器有可能就成為黑客的挖礦機。。 血的教訓啊 ps:我覺得我還可以出一篇怎麼清楚挖礦機程式。。