概述
在上一篇文章中,修改了redis的密码,那么也修改了 jedis的配置 如下
配置文件
host=127.0.0.1 port=6379 password=insurance2019
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${host}" />
<property name="port" value="${port}" />
<property name="password" value="${password}" />
<property name="poolConfig" ref="poolConfig"/>
</bean>
但是当跟redis建立链接的时候,报错如下
2019-01-25 14:56:35.944 INFO
org.apache.shiro.session.mgt.AbstractValidatingSessionManager - Enabling session validation scheduler...
25-Jan-2019 14:56:35.979 SEVERE [http-nio-7777-exec-1] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [insurance_web_servlet] in context with path [] threw exception [Filtered request failed.] with root cause
redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
at redis.clients.jedis.Protocol.processError(Protocol.java:117)
at redis.clients.jedis.Protocol.process(Protocol.java:151)
at redis.clients.jedis.Protocol.read(Protocol.java:205)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:196)
at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2048)
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:89)
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:861)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
at redis.clients.util.Pool.getResource(Pool.java:48)
解决思路,redis client 与redis 建立链接是带了密码的,却发现redis没有设置密码, 这就很奇怪了,难道我设置的密码无效了吗。 我给redis设置密码的时候并不是修改配置文件,而是使用命令行
127.0.0.1:6379> config set requirepass insurance2019
OK
127.0.0.1:6379>
在linux终端验证一下,是有效的,那为何 程序与redis建立链接的时候却报错 说 redis 没有设置密码呢
[root@insurance ~]# redis-cli -a insurance2019
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379>
因此怀疑 redis client 建立链接 是否去匹配 redis 的config 文件呢, 那就先看下 通过命令行修改的密码,是否会在配置文件中生效吧。
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
#
果然配置文件里的 requirepass 依然是注释的, 那么 修改配置文件 和 命令行修改密码究竟什么区别呢
reids client 是否通过 config 文件的密码 去校验呢, 先修改配置文件的密码 尝试一下看看
!! 果然在redis confi 修改了密码后,程序连接 正常。
修改redis密码,一定要修改配置文件。
最后
以上就是欣喜犀牛为你收集整理的redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set的全部内容,希望文章能够帮你解决redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复