redis关闭保护模式
1. set key出现的报错
在192.168.56.57客户端登录192.168.56.56的redis服务器时,报错如下: [root@localhost src]# ./redis-cli -h 192.168.56.56 -p 6379 -a "aabbcc" 192.168.56.56:6379> ping Error: Connection reset by peer 再telnet一下192.168.56.56的redis服务器的6379端口,提示redis服务有保护模式,需要解除 [root@localhost src]# telnet 192.168.56.56 6379 Trying 192.168.56.56... Connected to 192.168.56.56. Escape character is '^]'. -DENIED Redis is running in protected modebecause protected mode is enabled, no bind address was specified, noauthentication password is requested to clients. In this mode connections areonly accepted from the loopback interface. If you want to connect from externalcomputers to Redis you may adopt one of the following solutions: 1) Justdisable protected mode sending the command 'CONFIG SET protected-mode no' fromthe loopback interface by connecting to Redis from the same host the server isrunning, however MAKE SURE Redis is not publicly accessible from internet ifyou do so. Use CONFIG REWRITE to make this change permanent. 2) Alternativelyyou can just disable the protected mode by editing the Redis configurationfile, and setting the protected mode option to 'no', and then restarting theserver. 3) If you started the server manually just for testing, restart it withthe '--protected-mode no' option. 4) Setup a bind address or an authenticationpassword. NOTE: You only need to do one of the above things in order for theserver to start accepting connections from the outside. Connection closed by foreign host.
2. 原因是redis的保护模式
默认redis需要设置管理员账号密码,开启了保护模式
所以如果第一次使用没有设置管理员,就会出现报错,关闭保护模式即可
3. 解决方法
方法一:
修改redis的守护进程为no ,不启用 127.0.0.1:6379> config set daemonize "no" OK 修改redis的保护模式为no,不启用 127.0.0.1:6379> config set protected-mode "no" OK
方法二:推荐
修改配置文件
1) 绑定IP地址,看业务开放 bind 0.0.0.0 2)Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程,设置为no daemonize no 3)保护模式 protected-mode no
3. 启动加载配置文件
/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis6379.conf # 检查启动状态命令 ps -ef|grep redis |grep 6379
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)