使用哨兵模式连接redis连接池时,遇到错误:

Caused by: redis.clients.jedis.exceptions.JedisDataException:
 ERR Client sent AUTH, but no password is set

发现是redis没有设置密码,程序却发送了auth选项。

工程里JedisSentinelPool是通过spring配置的:

    <bean id="jedisPool" class="redis.clients.jedis.JedisSentinelPool" destroy-method="destroy">
<constructor-arg value="${redis.master}" />
<constructor-arg>
<set>
<value>${redis.host}:${redis.port}</value>
</set>
</constructor-arg>
<constructor-arg ref="jedisPoolConfig" />
<constructor-arg value="${redis.timeout}"/>
</bean>

发现JedisSentinelPool的构造方法有2个类似的:

	public JedisSentinelPool(String masterName, Set sentinels,
GenericObjectPoolConfig poolConfig, int timeout) {
this(masterName, sentinels, poolConfig, timeout, null, 0);
} public JedisSentinelPool(String masterName, Set sentinels,
GenericObjectPoolConfig poolConfig, String password) {
this(masterName, sentinels, poolConfig, 2000, password);
}

JedisSentinelPool初始化构造方法的入参是根据spring配置文件的参数配置顺序加载的,JedisSentinelPool使用了第二个构造方法,导致上面的错误。

解决方法,给配置文件的参数配置name属性.

    <bean id="jedisPool" class="redis.clients.jedis.JedisSentinelPool" destroy-method="destroy">
<constructor-arg name="masterName" value="${redis.master}" />
<constructor-arg name="sentinels">
<set>
<value>${redis.host}:${redis.port}</value>
</set>
</constructor-arg>
<constructor-arg name="poolConfig" ref="jedisPoolConfig" />
<constructor-arg name="timeout" value="${redis.timeout}"/>
</bean>

问题解决

redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set的更多相关文章

  1. Redis错误:jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set

    原文链接:http://blog.csdn.net/rchm8519/article/details/48347797 redis.clients.util.Pool.getResource(Pool ...

  2. redis.clients.jedis.exceptions.JedisDataException: ERR invalid DB index

    添加redis配置文件, 启动后,调用报错  redis.clients.jedis.exceptions.JedisDataException: ERR invalid DB index ERR i ...

  3. 【问题集】redis.clients.jedis.exceptions.JedisDataException: ERR value is not an integer or out of range

    redis.clients.jedis.exceptions.JedisDataException: ERR value is not an integer or out of range incrm ...

  4. 【异常】redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'PSETEX'

    在spring中 针对 RedisTemplate类: private RedisTemplate<String, String> template; 当调用下面方法 template.o ...

  5. 阿里云 Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR invalid password

    如果你是买的阿里云的redis服务的话,不要被这个ERR invalid password所迷惑了. 你应该去检查一下你买的服务有没有设置白名单. 像mysql和mongodb的服务如果连不上的话也可 ...

  6. ERR Unsupported CONFIG parameter: notify-keyspace-events; nested exception is redis.clients.jedis.exceptions.JedisDataException

    异常信息 时间:2017-04-05 15:53:57,361 - 级别:[ WARN] - 消息: [other] The web application [ROOT] appears to hav ...

  7. redis.clients.jedis.exceptions.JedisDataException :READONLY You can't write

    分布式直连同步调用测试时出现的错误:主从复制架构下,默认Slave是只读的,如果写入则会报错: redis.clients.jedis.exceptions.JedisDataException: R ...

  8. redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots

    最近在学习Redis ,在写test测试的时候碰到这个报错: redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is c ...

  9. Caused by: redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a read only slave.

    Caused by: redis.clients.jedis.exceptions.JedisDataException: READONLY You can't write against a rea ...

随机推荐

  1. 改变cinder默认vg的方法

    在存储节点:# pvcreate /dev/sdb# vgcreate vg100gb /dev/sdb # openstack-config --set /etc/cinder/cinder.con ...

  2. typedef和block

    为block类型对象取别名 1.没有使用typedef的情况 int (^block_add)(int, int) = ^(int value1, int value2) { return value ...

  3. Lua学习系列(二)

    资源整理: 风云老师博客: http://blog.codingnow.com/eo/luaoeeeaeau/ 知乎: https://www.zhihu.com/question/20736660 ...

  4. Tomcat 静态部署 二步特别注意

    一.修改server.xml 在Host 节点添加如下配置 <!-- path 为请求url地址 docBase 为项目文件绝对地址制定到WebContent根目录下 --> <Co ...

  5. Redis 代理 twemproxy

    4台 redis 服务器 172.16.1.37:6379   - 1 172.16.1.36:6379   - 2 172.16.1.35:6379   - 3 172.16.1.34:6379   ...

  6. Cordova3+sencha touch2.x 环境搭建

    1.安装 nodejs 2.安装 cordova: npm install -g cordova 3.创建一个工程: cordova create MyApp com.example.MyApp My ...

  7. PHP安装插件方式

    PHP安装插件方法主要有两种: 1.先安装相关的库,zlib.curl.xml等,然后在安装 php 时的 ./configure 中设置 --with-xxx(你需要的插件),三部曲安装即可. 2. ...

  8. HUST 1371 Emergency relief

    状态压缩. 每一个人所需的物品对应一个数字,统计一个每个数字有几个.每一种提供物品的状态也对应一个数字,然后暴力判断. #include<cstdio> #include<cstri ...

  9. Laravel5 model create使用

    1.在laravel的Eloquent ORM中,默认表会有created_at.updated_at两个字段,因此在使用create函数时若表无这两个字段会出错,可以设置 public $times ...

  10. JDBC操作数据时中文乱码

    /** * DB地址 */ private static final String DB_URL="jdbc:mysql://localhost:3306/db_book?useUnicod ...