redis配置密码登录

今天配置了一个redis缓存的服务,连通之后想使用密码登录,找到的大部分都是在redis.conf修改

requirepass但我修改后重启服务,不需要密码还是直接取到了所有的key

直到我使用了

成功

redis配置密码,客户端报错

02-21

没有使用密码认证的情况下客户端连redis服务器都是正常的。使用密码配置会就提示错误了nn在redis 服务端修改/etc/redis.conf nnrequirepass myRedisnn重启服务nsudo service redis restart nn客户端是使用JedisPool ,其中参数password 就是myRedisn使用的是new JedisPool(config, host, Integer.parseInt(port), Integer.parseInt(timeout), password);nn当我从池中获取一个Jedis的时候就会报错;nJedis jedis = jedisPool.getResource();nn具体报错的地方在以下。nnredis.clients.jedis.Connection 类的 socket.connect(new InetSocketAddress(host, port), timeout);就会报nCould not get a resource from the poolnn public void connect() n if (!isConnected()) n try n socket = new Socket();n //->@wjw_addn socket.setReuseAddress(true);n socket.setKeepAlive(true); //Will monitor the TCP connection is validn socket.setTcpNoDelay(true); //Socket buffer Whetherclosed, to ensure timely delivery of datan socket.setSoLinger(true,0); //Control calls close () method, the underlying socket is closed immediatelyn //<-@wjw_addnn socket.connect(new InetSocketAddress(host, port), timeout);n socket.setSoTimeout(timeout);n outputStream = new RedisOutputStream(socket.getOutputStream());n inputStream = new RedisInputStream(socket.getInputStream());n catch (IOException ex) n throw new JedisConnectionException(ex);n n n n n n redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pooln at redis.clients.util.Pool.getResource(Pool.java:42)nCaused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connectn at redis.clients.jedis.Connection.connect(Connection.java:137)n at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:65)n at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1706)n at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:65)n at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:819)n at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:429)n at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360)n at redis.clients.util.Pool.getResource(Pool.java:40)n ... 2 morenCaused by: java.net.ConnectException: Connection refused: connectn at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)n at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)n at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)n at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)n at java.net.AbstractPlainSocketImpl.connect(Unknown Source)n at java.net.PlainSocketImpl.connect(Unknown Source)n at java.net.SocksSocketImpl.connect(Unknown Source)n at java.net.Socket.connect(Unknown Source)n at redis.clients.jedis.Connection.connect(Connection.java:132)n ... 9 more

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭