idea连接不到服务器上的redis


在idea上部署springboot项目连接服务器上的redis时

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to *****:6379
使用的是阿里云服务器

下面是排错步骤:

查看yml文件中的ip,端口,密码和服务器能对应的上吗

yml文件配置如下

spring:
  redis:
    host: ****
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 0
        max-wait: 100ms

和linux上部署的一致

.查看linux防火墙是否关闭

systemctl status firewalld查看防火墙状态
systemctl stop firewalld关闭防火墙

查看阿里云安全组

这里我不演示了,我的已经放行了

linux中redis是否允许外网ip访问

whereis redis    #找到redis目录
cd /usr/local/redis (目录根据上面指令返回结果)   #进入该目录
vim redis.conf   #在该目录下修改bind

在这里插入图片描述
将bind的127.0.0.1改为0.0.0.0
然后重启redis
在redis-cli中使用shutdown命令再重新执行redis -server

设置redis密码

按理来说应该能连上了但是还是报错连接不到
这里我用cmd输入

telnet   ***(服务器ip) 6379

查看看是否能连接到redis端口
在这里插入图片描述
发现能连接到redis,但是返回这样的信息
大概就是服务器端redis没有设置密码

继续操作redis.conf文件
找到

# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
# layer on top of the new ACL system. The option effect will be just setting
# the password for the default user. Clients will still authenticate using
# AUTH <password> as usually, or more explicitly with AUTH default <password>
# if they follow the new protocol: both will work.
#
# The requirepass is not compatable with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.
#
requirepass 123456 
# New users are initialized with restrictive permissions by default, via the

将requirepass **** 打开,并重新设置密码
由于文件太大不方便查找,可以在vim的正常模式下输入

/requirepass(要查找的字符串)

重启redis-server

redis-server redis.conf

然后就OK了

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值