RDB是redis常用持久化方式,通过执行bgsave命令,会在指定目录下生成rdb文件,默认名称为:dump.rdb

dbfilename "dump.rdb"
 dir "/opt/app/redis/redis_6379/data"127.0.0.1:6379> bgsave
Background saving started
127.0.0.1:6379> exit
dbadmin@redis-27:/opt/app/redis/redis_6379/data$ls -lrt

-rw-rw-r-- 1 dbadmin dbadmin 8999 Nov 14 17:47 appendonly.aof
-rw-rw-r-- 1 dbadmin dbadmin 4399 Nov 21 16:27 dump.rdb


并修改appendonly yes更改为appendonly no!


appendonly no
appendfilename "appendonly.aof"




然后启动主节点,验证数据是否加载成功:


17961:M 14 Nov 17:44:15.935 * DB loaded from disk: 0.000 seconds
17961:M 14 Nov 17:44:15.936 * The server is now ready to accept connections on port 6379




数据加载完成后,关闭主节点,等待主角色切换至备节点上


修改appendonly no更改为appendonly yes,启动节点进程即可。