阿里云centos7部署redis远程连接问题

本文档详细介绍了如何解决SpringBoot应用在尝试连接阿里云Redis时遇到的连接失败问题。主要步骤包括:修改Redis配置文件,取消bind限制,关闭保护模式,设置密码,重启Redis服务,开启阿里云安全组的6379端口,以及关闭防火墙6379端口的限制。完成这些步骤后,远程访问Redis的问题将得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jedis连接远程redis出现

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: Failed to connect to any host resolved for DNS name.

springboot出现

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to xxx.xxx.xxx.xxx:6379

首先进入配置文件(我的配置文件在redisConfig/redis.conf目录下)

[root@zhaookee bin]# vim redisConfig/redis.conf

输入==/关键字==即可查找

1、注释bind
在这里插入图片描述
2、关闭保护模式
在这里插入图片描述
3、打开后台启动
在这里插入图片描述
4、此处最好设置一个密码
在这里插入图片描述
5、重启redis

[root@zhaookee bin]# redis-cli
127.0.0.1:6379> shutdown
not connected> quit 
[root@zhaookee bin]# redis-server redisConfig/redis.conf

6、打开阿里云安全组
在这里插入图片描述

7、关闭防火墙

[root@zhaookee bin]# firewall-cmd --zone=public --permanent --add-port=6379/tcp
[root@zhaookee bin]# systemctl restart firewalld.service
[root@zhaookee bin]# firewall-cmd --list-all

在这里插入图片描述
完成以上操作就可以正常访问了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值