Jedis使用的一个小疑惑
昨天第一次在内网的一台Linux上安装了Redis,启动成功之后用redis-cli连接都没有问题,基本的操作都正常。只是在使用Jedis第一次连接服务的时候都遇到了小问题,而且是今天和昨天的第一次都有同样的问题发生。
昨天第一次用程序连接的时候,是用最简单的方式:
Jedis jedis = new Jedis(REDIS_SERVER_IP);long start = System.currentTimeMillis();for (int i = 0; i < 100000; i++) { String result = jedis.set("n" + i, "n" + i);}
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connectat redis.clients.jedis.Connection.connect(Connection.java:137)at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:65)at redis.clients.jedis.Connection.sendCommand(Connection.java:82)at redis.clients.jedis.BinaryClient.set(BinaryClient.java:82)at redis.clients.jedis.Client.set(Client.java:23)at redis.clients.jedis.PipelineBase.set(PipelineBase.java:481)at redis.clients.jedis.Pipeline.set(Pipeline.java:8)at com.abcwork.testJedis.TestSimple.testPipeline(TestSimple.java:146)at com.abcwork.testJedis.TestSimple.main(TestSimple.java:27)Caused by: java.net.ConnectException: Connection refused: connectat java.net.PlainSocketImpl.socketConnect(Native Method)at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)at java.net.Socket.connect(Socket.java:519)at redis.clients.jedis.Connection.connect(Connection.java:132)... 8 more