小结
Redis的调试指令返回权限不允许的错误(ERR DEBUG command not allowed),进行了解决。
问题
redis-cli -p 6379 DEBUG sleep 30指令返回ERR DEBUG command not allowed,如下:
john@XYZ:~$ redis-cli -p 6379 DEBUG sleep 30
(error) ERR DEBUG command not allowed. If the enable-debug-command option is set to "local", you can ru server.
解决
参考How to fix Redis Error “ERR DEBUG command not allowed.”还是无法解决。
开始误以为文件配置有问题/etc/redis/redis.conf,修改enable-debug-command为yes.
john@XYZ:~$ sudo vim /etc/redis/redis.conf
enable-debug-command yes
注意在WSL的Ubuntu中systemctl指令是不起作用的,可以使用sudo service redis-server restart指令进行重启。
进行了以上配置,还是会有同样的ERR DEBUG command not allowed错误。
细究原因是Redis-server启动方式不对,我使用了sudo redis-server --port 6379指令启动Redis,导致了enable-debug-command yes的配置没有生效,正确的启动方式是sudo service redis-server restart。
最后的测试结果如下:
john@XYZ:~$ redis-cli -p 6379 DEBUG sleep 30
OK
john@XYZ:~$ redis-cli
127.0.0.1:6379> DEBUG POPULATE 10 Test
OK
127.0.0.1:6379> keys Test*
1) "Test:8"
2) "Test:7"
3) "Test:2"
4) "Test:9"
5) "Test:1"
6) "Test:5"
7) "Test:0"
8) "Test:6"
9) "Test:4"
10) "Test:3"
127.0.0.1:6379> exit
参考
How to fix Redis Error “ERR DEBUG command not allowed.”
How to Install Redis on Ubuntu + Configuration and Common Redis Commands

文章描述了在遇到Redis调试命令权限错误时的解决步骤,包括检查配置文件中的enable-debug-command选项,正确重启Redis服务,以及纠正Redis的启动方式。问题源于使用sudoredis-server--port6379启动Redis,而非使用serviceredis-serverrestart,导致配置未生效。最终通过正确启动Redis,成功执行了DEBUG命令。
2558

被折叠的 条评论
为什么被折叠?



