連接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

直接在騰訊雲控制台里面找到參數配置,把你需要修改的配置添加上去即可。

最后,就我本人而言,我很不喜歡騰訊雲這種經過定制的雲服務。
其代碼和私改的部分沒有公開,實例也是對外封閉的,增加了運維的難度和不透明度;
代碼沒經過審查,存在不安全和藏私貨的風險。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM