redis disables several dangerous command methods

  • 2020-06-01 11:17:12
  • OfStack

Customer 1 has been telling me a problem in the past few days, that is, his cache server redis will clean the library every day. I am very surprised that the default of redis1 I configured should not clean the library every day. I think there is something wrong with his program.

However, no matter the program problem or configuration problem, I thought is can clear the library command ban, so even if he had to clean up the program is no way, so baidu 1, see all the relevant documents are written by a person, is in redis.conf using rename-conmand


rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command KEYS ""

After that, I went to restart redis and thought OK was already there. I carefully looked at the log of redis and found something wrong.


Unknown command  ' flushall '  reading the append only file

This is what problem, direct baidu, there is no answer to this problem, carefully look at append only this, feel where have seen, then to redis.conf file to find, as expected, to the official website to see the meaning of this parameter.


############################## APPEND ONLY MODE ###############################
 
#  By default, Redis It is asynchronous to export data to disk. This model is good enough for many applications, but Redis process 
#  Problems or power cuts can occur 1 Write operation lost for some time ( It depends on the configuration save instruction ) . 
#
# AOF is 1 Provides a more reliable alternative persistence mode, such as using the default data write file policy (see configuration below) 
#  In the case of a server outage or single write Redis When there is an emergency such as a problem with its own process but the operating system is still running normally, Redis
#  Can only lose 1 Write in seconds. 
#
# AOF and RDB Persistence can be started at the same time and without problems. 
#  if AOF On, so at startup Redis Will load AOF File, it can guarantee the reliability of the data. 
#
#  Please see the  http://redis.io/topics/persistence  For more information .
 
appendonly no
 
#  Pure accumulative file name (default: "appendonly.aof" ) 
 
appendfilename "appendonly.aof"

So, taking a chance, I changed the configuration from appendonly yes to no, and restarted redis. As expected, no errors were reported, and the three commands were also disabled.


Related articles: