Redis 问题1- 链接不上服务器的 redis

问题1 - 链接不上服务器的 redis

参照博客

代码报错:

nable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 服务器地址 :6379

解决方法:

  1. application.yml的redis配置中的spring.redis.timeout中连接超时时间(毫秒)中时间设置不能为0;

  2. 修改配置文件:

    1. 找到redis的配置文件 redis.conf
     $ vim redis.conf
    
    1. 修改 protected-mode yes 改为:protected-mode no

    2. 注释掉 #bin 127.0.0.1

  3. 检查代码中的 yml 文件

    # REDIS (RedisProperties)
    # Redis数据库索引(默认为0)
    spring.redis.database=0
    # Redis服务器地址
    spring.redis.host=192.168.30.103
    # Redis服务器连接端口
    spring.redis.port=6379
    # 连接池最大连接数(使用负值表示没有限制)
    spring.redis.jedis.pool.max-active=8
    # 连接池最大阻塞等待时间(使用负值表示没有限制)
    spring.redis.jedis.pool.max-wait=-1
    # 连接池中的最大空闲连接
    spring.redis.jedis.pool.max-idle=8
    # 连接池中的最小空闲连接
    spring.redis.jedis.pool.min-idle=0
    # 连接超时时间(毫秒)
    spring.redis.timeout=5000
    
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。