• 如何解决禁用或重命名命令导致的redis服务无法启动的问题
  • 发布于 2个月前
  • 514 热度
    0 评论
  • 远行客
  • 0 粉丝 32 篇博客
  •   
在启用aof情况下,禁用或重命名命令可能会导致redis服务无法启动,是因为实例在之前执行被重命名的命令,导致加载aof时,命令执行失败
#在启用aof情况下,禁用或重命名命令可能会导致redis服务无法启动,是因为实例在之前执行被重命名的命令,导致加载aof时,命令执行失败
6682:C 07 May 2023 23:20:57.411 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
6682:C 07 May 2023 23:20:57.411 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=6682, just started
6682:C 07 May 2023 23:20:57.411 # Configuration loaded
6682:C 07 May 2023 23:20:57.411 * supervised by systemd, will signal readiness
6682:M 07 May 2023 23:20:57.417 * Running mode=standalone, port=6379.
6682:M 07 May 2023 23:20:57.419 # Server initialized
6682:M 07 May 2023 23:20:57.420 # Unknown command 'flushdb' reading the append only file
解决方案:
1、禁用aof选项
2、修改配置重启服务之前,执行 bgrewriteaof 重新生成aof内容
# Command renaming.
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
#
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to replicas may cause problems.

renmae-comand FLUSHALL ""
rename-comand FULSHDB "REMOVE-THIS-DATABASE"

127.0.0.1:6379> info keySpace
# Keyspace
db0:keys=1000,expires=0,avg_ttl=0
127.0.0.1:6379> flushall
(error) ERR unknown command `flushall`, with args beginning with: 
127.0.0.1:6379> flushdb
(error) ERR unknown command `flushdb`, with args beginning with: 
127.0.0.1:6379> info keySpace
# Keyspace
db0:keys=1000,expires=0,avg_ttl=0
127.0.0.1:6379> 
127.0.0.1:6379> REMOVE-THIS-DATABASE
OK
127.0.0.1:6379> info keySpace
# Keyspace
127.0.0.1:6379> 

用户评论