FLUSHALL ASYNC (Redis 4.0.0 or greater)
Redis is now able to delete keys in the background in a different thread without blocking the server. An ASYNC option was added to FLUSHALL and FLUSHDB in order to let the entire dataset or a single database to be freed asynchronously.
Asynchronous FLUSHALL and FLUSHDB commands only delete keys that were present at the time the command was invoked. Keys created during an asynchronous flush will be unaffected.
运维的朋友,可能会碰到这样的情况,在redis不小心执行了flushdb或者flushall的操作,此时是不是打算辞职走人了?下面来讲一下,redis执行了flushdb或者flishall之后的“后悔药”操作:
(1)先看一下我们现在redsi中已经有的数据
(2)此时我们执行了flushall的操作(flushdb的操作也是一样的)
(3)我们首先执行关闭的不存储操作:shutdown nosave
(3)杀掉redis的进程:pkill -9 redis
(4)修改redis的aof文件,删除到最后执行的flushall相关的命令(我的文件是 /var/rdb/appendonly6379.aof 文件)
(5)重启redis,(./bin/redis-server ./redis.conf) (./bin/redis-cli)
如图,我们执行flushall之前的数据,已经恢复回来了,思路其实很简单,手动将aof文件的flushall命令删除,然后重启redis就会自动加载了