redis解决(DENIED Redis is running in protected mode because prote)

简介:

早上一个应用日志打印报错信息:

wKiom1g-cNXwSl0FAAAlafexExk279.png


在应用上telnet端口和ping都没有问题,为什么还获取不到值呢。

先安装一个redis客户端进行测试:yum -y install redis

redis-cli -h 192.168.32.12 -p 6887

然后就报错了:

(error) DENIED Redis is running in protected mode because protected mode is……


后来就查看配置发现redis.conf 该行也是注释的:

# requirepass foobared


继续排查发现和一个参数配置有关系:


链接redis 时只能通过本地localhost (127.0.0.1)这个来链接,而不能用网络ip(192.168..)这个链接,问题然如果用网络ip 链接会报以下的错误:
(error) 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 lookback 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 --portected-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.
是说处于保护模式,只能本地链接,我们需要修改配置文件../redis.conf

1)打开配置文件把下面对应的注释掉
# bind 127.0.0.1 

2)Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程,设置为no
daemonize no

3)保护模式
protected-mode no 

报错处理

一、

在对应配置conf文件中去掉注释,把yes改为no

#protected-mode yes
protected-mode no


重启redis(注意有数据时慎重启)

kill -9 进程号

redis-cli -h 192.168.32.12 -p 6887 shutdown


二、添加认证,设置密码

# requirepass foobared

requirepass redis123456


验证

再次用Java程序建立连接池,没有报错,且可以对redis server进行数据正常处理。程序报错日志不再显示

问题解决




      本文转自卫庄的痛 51CTO博客,原文链接:http://blog.51cto.com/crfsz/1878137,如需转载请自行联系原作者

相关文章
|
NoSQL 测试技术 Redis
像测试产品需求一样测试Redis配置项protected mode(保护模式)
同一内网下其他主机无法连接redis-server的原因可能有:protected-mode(保护模式)已开启、bind绑定了无效的主机地址、bind设置了本地回环地址。
像测试产品需求一样测试Redis配置项protected mode(保护模式)
|
NoSQL Redis Perl
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was spe
(error) DENIED Redis is running in protected mode because protected mode is enabled Redis protected-mode 是3.2 之后加入的新特性,在Redis.conf的注释中,我们可以了解到,他的具体作用和启用条件 链接redis 时只能通过本地localhost (127.
3200 0
|
缓存 NoSQL 关系型数据库
美团面试:MySQL有1000w数据,redis只存20w的数据,如何做 缓存 设计?
美团面试:MySQL有1000w数据,redis只存20w的数据,如何做 缓存 设计?
美团面试:MySQL有1000w数据,redis只存20w的数据,如何做 缓存 设计?
|
8月前
|
缓存 负载均衡 监控
135_负载均衡:Redis缓存 - 提高缓存命中率的配置与最佳实践
在现代大型语言模型(LLM)部署架构中,缓存系统扮演着至关重要的角色。随着LLM应用规模的不断扩大和用户需求的持续增长,如何构建高效、可靠的缓存架构成为系统性能优化的核心挑战。Redis作为业界领先的内存数据库,因其高性能、丰富的数据结构和灵活的配置选项,已成为LLM部署中首选的缓存解决方案。
839 25
|
缓存 NoSQL Java
Redis+Caffeine构建高性能二级缓存
大家好,我是摘星。今天为大家带来的是Redis+Caffeine构建高性能二级缓存,废话不多说直接开始~
1627 0
|
9月前
|
存储 缓存 NoSQL
Redis专题-实战篇二-商户查询缓存
本文介绍了缓存的基本概念、应用场景及实现方式,涵盖Redis缓存设计、缓存更新策略、缓存穿透问题及其解决方案。重点讲解了缓存空对象与布隆过滤器的使用,并通过代码示例演示了商铺查询的缓存优化实践。
371 1
Redis专题-实战篇二-商户查询缓存
|
8月前
|
缓存 运维 监控
Redis 7.0 高性能缓存架构设计与优化
🌟蒋星熠Jaxonic,技术宇宙中的星际旅人。深耕Redis 7.0高性能缓存架构,探索函数化编程、多层缓存、集群优化与分片消息系统,用代码在二进制星河中谱写极客诗篇。
1567 3
|
9月前
|
缓存 NoSQL 关系型数据库
Redis缓存和分布式锁
Redis 是一种高性能的键值存储系统,广泛用于缓存、消息队列和内存数据库。其典型应用包括缓解关系型数据库压力,通过缓存热点数据提高查询效率,支持高并发访问。此外,Redis 还可用于实现分布式锁,解决分布式系统中的资源竞争问题。文章还探讨了缓存的更新策略、缓存穿透与雪崩的解决方案,以及 Redlock 算法等关键技术。
|
消息中间件 缓存 NoSQL
基于Spring Data Redis与RabbitMQ实现字符串缓存和计数功能(数据同步)
总的来说,借助Spring Data Redis和RabbitMQ,我们可以轻松实现字符串缓存和计数的功能。而关键的部分不过是一些"厨房的套路",一旦你掌握了这些套路,那么你就像厨师一样可以准备出一道道饕餮美食了。通过这种方式促进数据处理效率无疑将大大提高我们的生产力。
383 32
|
缓存 NoSQL Java
Redis:现代服务端开发的缓存基石与电商实践-优雅草卓伊凡
Redis:现代服务端开发的缓存基石与电商实践-优雅草卓伊凡
321 5
Redis:现代服务端开发的缓存基石与电商实践-优雅草卓伊凡