RDB转化AOF 花式删库

运行一段时间默认的RDB后  转化成AOF 不能直接转换  会造成数据大量丢失

[root@centos7 ~]#vim /apps/redis/etc/redis.conf
# Please check http://redis.io/topics/persistence for more information.

appendonly yes        #开关

因为前期没启用AOF  所以没有AOF文件  同时启用RDB和AOF 优先从AOF读取

一旦重启 数据全消失   并生成aof文件

[root@centos7 ~]# systemctl restart redis
[root@centos7 ~]# redis-cli
127.0.0.1:6379> info

# Keyspace
[root@centos7 ~]# ll /data/redis
total 146008
-rw-r--r-- 1 redis redis                 0     Oct 21 10:45 appendonly.aof
-rw-r--r-- 1 redis redis         149509867     Oct 21 10:43 dump_6379.rdb

随便加点数据存一下

127.0.0.1:6379> set date 1010
OK
127.0.0.1:6379>bgsave             
[root@centos7 ~]# ll /data/redis
total 146008
-rw-r--r-- 1 redis redis                56     Oct 21 12:25 appendonly.aof
-rw-r--r-- 1 redis redis               106     Oct 21 12:20 dump_6379.rdb

这时候如果没有其他备份    直接GG

正确的姿势

在交互式redis中启用aof

[root@centos8 ~]#redis-cli
127.0.0.1:6379> config get appendonly
1) "appendonly"
2) "no"
127.0.0.1:6379> config set appendonly yes
OK
[root@centos8 ~]#ll /data/redis
total 366760
-rw-r--r-- 1 redis redis 187779391 Oct 21 12:25 appendonly.aof
-rw-r--r-- 1 redis redis 187779391 Oct 21 12:20 dump.rdb 
[root@centos7 ~]#vim /apps/redis/etc/redis.conf
# Please check http://redis.io/topics/persistence for more information.

appendonly yes        #这回再开启aof配置文件
[root@centos7 ~]# systemctl restart redis

稳妥

原文地址:https://www.cnblogs.com/zhangty333/p/13857514.html