Redis持久化之AOF

todo

AOF实验

1.redis写操作

27.0.0.1:6379> set hello world
OK
127.0.0.1:6379> set hello php
OK
127.0.0.1:6379> set hello java
OK
127.0.0.1:6379> set hello jack
OK
127.0.0.1:6379> set zhang san
OK
127.0.0.1:6379> set li si
OK
127.0.0.1:6379> set li xiaolong
OK

上述操作多次覆写hello,li两个key。

2.查看aof日志文件

$ sudo cat -b /var/lib/redis/appendonly.aof 
 REDIS0009?  redis-ver5.0.3?
?    2  ?ctime??]used-mem??
 aof-preamble??$e???q   ?*2
 $6
 SELECT
 $1
 0
 *3
 $3
 set
 $5
 hello
 $5
 world
 *3
 $3
 set
 $5
 hello
 $3
 php
 *3
 $3
 set
 $5
 hello
 $4
 java
 *3
 $3
 set
 $5
 hello
 $4
 jack
 *3
 $3
 set
 $5
 zhang
 $3
 san
 *3
 $3
 set
 $2
 li
 $2
 si
 *3
 $3
 set
 $2
 li
 $8
 xiaolong

3.重写aof

127.0.0.1:6379> bgrewriteaof
Background append only file rewriting started

4.查看重写后的aof日志文件

:~$ sudo cat -b /var/lib/redis/appendonly.aof 
     1  REDIS0009?  redis-ver5.0.3?
?    2  ?ctime????]used-mem??
 aof-preamble???zhangsanlxiaolonghellojack??X?-???

相关推荐