栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

RedisConnectionFailureException

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

RedisConnectionFailureException

ubuntu虚拟机中redis的安装与使用 官网:Redis 我的redis版本:6.2 我的安装方式: 来自官方 Ubuntu PPA
$ sudo add-apt-repository ppa:redislabs/redis
$ sudo apt-get update
$ sudo apt-get install redis
我的ubuntu版本:20.04.2.0 我的redis默认安装位置:
/usr/local/bin
我的redis配置文件位置:
/etc/redis
进入配置文件目录,修改配置文件
使用"#"注释bind 127.0.0.1 好像是这个:127.0.0.1 -::1 
允许非本机访问

protected-mode yes 改为 protected-mode no
关闭保护模式,允许远程访问

在安装位置,后台运行模式启动redis
./redis-server &
在安装位置,用正常模式关闭redis
./redis-cli shutdown
启动redis后,编辑防火墙过滤规则
iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
在用springboot调用redis时报错RedisConnectionFailureException

通过另一台虚拟机连接尝试连接该redis:

./redis-cli -h "IP地址" -p "端口号" -a "密码"

报错如下:

AUTH failed: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'ConFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use ConFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
Error: 

redis在保护模式下运行,配置文件似乎没有生效,在客户端中关闭保护模式:

安装目录运行客户端
redis-cli
查看保护模式状态
config get protected-mode
修改保护模式状态
config set protected-mode no

或 指定配置文件启动

redis-server /etc/redis/redis.conf
虽然另一台虚拟机可以连上redis了,但是springboot还是一直报错RedisConnectionFailureException,但有了提示:redis在保护模式下运行,需要输入config set protected-mode no。又尝试了一会儿,找不到问题在哪儿,重启项目后报错没了,项目可以成功运行了。
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/584013.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号