org.springframework.data.redis.RedisConnectionFailureException,java操作redis问题解决大全

错误信息如下:

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

这个错误发生在springboot2.0整合redis实现消息订阅功能时,因代码无法连接到redis服务器产生的错误,上述内容说是提供4种方法任意执行一种即可。
综合网上查询的解决办法,提供一下设置,变更完毕即可,因博主是linux环境,只说明linux操作。


  • 找到redis安装目录,开始编辑redis.conf文件,windows版的好像是redis.windows.conf
  • 接着使用 vi命令开始编辑配置文件,需要修改的地方已经标出

    1、给bind 127.0.0.1添加注释,若需要指定若干ip访问,则直接改成指定ip访问,不然开启就是本机访问;
    2、将protected mode yes 改成protected mode no,意思是是否启用保护模式;

    操作命令如下:

1. vi redis.conf;
2. 找到待修改内容,光标移动上去,按a键,开始进行操作编辑;
3. 将上述内容都找到并修改完成后,按ESC键,之后输入:wq进行保存;
  • 启动redis
    这里有一个坑需要说明一下,启动redis的时候是要携带刚刚修改的配置文件的,如果不携带则还是使用的默认配置。(博主被这个地方坑了2个小时,真的傻了)
    还去弄了防火墙、端口开放等等,服务器都重启了几遍还没生效,原来最后才发现,启动没有带配置文件。。。

另外,操作这些的时候,尽量用root,不然可能会没有权限的su root

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
org.springframework.data.redis.RedisConnectionFailureException是一个Redis连接失败的异常。该异常通常由io.lettuce.core.RedisConnectionException引发,表示无法连接到Redis服务器。 在引用中的场景描述中,可能是因为Redis配置中的连接地址或端口不正确,导致连接失败。可以查看应用程序的资源文件,例如application.properties或application.yml,确认Redis的连接配置是否正确。 另外,引用提到了一些可能导致连接失败的原因。首先,可以检查application资源文件中配置的Redis连接地址是否正确。其次,检查虚拟机防火墙是否关闭,并确保Redis所在的端口是开放的。 总结起来,org.springframework.data.redis.RedisConnectionFailureException是一个Redis连接失败的异常,可能是由于Redis连接配置错误或虚拟机防火墙的问题导致的。需要检查连接配置和防火墙设置来解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [springboot连接redis出现org.springframework.data.redisRedisConnectionFailureException异常](https://blog.csdn.net/m0_67393828/article/details/123684060)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [org.springframework.data.redis.RedisConnectionFailureException异常解决](https://blog.csdn.net/Sexycool/article/details/122352805)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值