这里只记录的命令的操作。
redis.conf中
# The filename where to dump the DB
dbfilename dump.rdb
bgsave/save #主动执行持久化操作
config set filename xxx
config set dir xxx #保存在指定位置
RDB文件处理
AOF同步->将aof_buf的命令写入硬盘
需要设置appendonly 为yes
Redis可以实现数据的持久化存储,即将数据保存到磁盘上。
Redis的持久化存储提供两种方式:RDB与AOF。RDB是默认配置。AOF需要手动开启。
现在Redis的配置中默认是关闭AOF模式的。
如果要开启AOF模式,修改Redis的配置文件redis.conf。
相关的配置项:
appendonly yes #开启AOF模式 原文1
appendfilename "appendonly.aof" #保存数据的AOF文件名称 原文1
# appendfsync always
appendfsync everysec #fsync模式 原文2
# appendfsync no
no-appendfsync-on-rewrite no #原文3
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb #原文4
aof-load-truncated yes #原文5