连接redis时报错"ERR config is disabled command"的解决方法
项目从线上redis4.0迁移到5.0时出现了启动报错:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Invocation of init method failed;
nested exception is org.springframework.data.redis.RedisSystemException: Error in execution;
nested exception is io.lettuce.core.RedisCommandExecut1onException: ERR config is disabled command
......
请注意,虽然同样都是 "enableRedisKeyspaceNotificationsInitializer" 这个 bean 创建失败,但报错是 " ERR config is disabled command " 而不是 " ERR unknown command CONFIG
"。
一般的开源版本的 redis 5.0 是没办法 disable 一个命令的,所以在开源版本的 redis 5.0 的解决方案是直接把 CONFIG
这个命令直接 rename 成空串或者随机字符来禁用此命令。
所以,如果你的报错是 ERR unknown command CONFIG
,请检查你的 redis 配置文件,查看是不是 CONFIG
命令被 rename 了。
如果你的报错显示是 ERR config is disabled command ,那你有可能正在使用的是腾讯云公有云或者私有云版本的 redis。
按照官网的说明,想要用 config 命令,是只能用 config get,但是不能用 config set。
当前腾讯云版本的 redis config get 是只支持以下命令
maxmemory,
maxclients,
maxmemory-policy,
databases,
slowlog-log-slower-than
slowlog-max-len,
notify-keyspace-events
lua-time-limit
直接在腾讯云控制台里面找到参数配置,把你需要修改的配置添加上去即可。
最后,就我本人而言,我很不喜欢腾讯云这种经过定制的云服务。
其代码和私改的部分没有公开,实例也是对外封闭的,增加了运维的难度和不透明度;
代码没经过审查,存在不安全和藏私货的风险。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!