首页 新闻 会员 周边 捐助

Jedis 操作 Sentinel redis

0
[待解决问题]

本人使用 Jedis中 JedisSentinelPool 访问服务器中的 redis服务

指定了地址和端口
val sentinelServerHost = new util.HashSetString
sentinelServerHost.add(new HostAndPort("10.124.196.190",5000).toString)
sentinelServerHost.add(new HostAndPort("10.124.196.191",5000).toString)
sentinelServerHost.add(new HostAndPort("10.124.196.120",5000).toString)

使用连接池
val sentinelConnectionPool = new JedisSentinelPool("master01",sentinelServerHost, config, 60,60,"password",15,"",2000,2000,"password","master01")

其中不清楚 client 和 sentinel client 我就给的master

抛出的异常 端口 6397 为什么和我指定的 5000 不一致呢
Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host 10.124.196.190:6379

完整异常
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    at redis.clients.jedis.util.Pool.getResource(Pool.java:59)

    at redis.clients.jedis.JedisSentinelPool.getResource(JedisSentinelPool.java:235)

    at com.cisco.redis_test.RedisConn$.getConnection(RedisConn.scala:35)

    at com.cisco.redis_test.RedisConn$.main(RedisConn.scala:39)

    at com.cisco.redis_test.RedisConn.main(RedisConn.scala)

    Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host 10.124.196.190:6379

    at redis.clients.jedis.Connection.connect(Connection.java:204)

    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:100)

    at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1894)

    at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:117)

    at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:889)

    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:424)

    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:349)

    at redis.clients.jedis.util.Pool.getResource(Pool.java:50)

    ... 4 more

    Caused by: java.net.SocketTimeoutException: connect timed out

    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)

    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

    at java.net.Socket.connect(Socket.java:606)

    at redis.clients.jedis.Connection.connect(Connection.java:181)

    ... 11 more



    Process finished with exit code 1
Pooler的主页 Pooler | 菜鸟二级 | 园豆:202
提问于:2020-03-06 21:39
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册