您的位置:首页 > 数据库 > Redis

redis 之 AOF

2015-09-22 16:13 791 查看
AOF(append-only fashion)是redis持久化利器之一。通过写log的方式,以满足在需要的时候,重建数据的需求。

the AOF persistence logs every write operation received by the server, that will be played again at server startup, reconstructing the original dataset. Commands are logged using the same format as the Redis protocol itself, in an append-only fashion. Redis
is able to rewrite the log on background when it gets too big.

Redis写日志包括:

1. 根据用户的配置,以不同的粒度写AOF log

2. 在日志数据量达到一定量的时候,根据配置或外部发送的命令,重建AOF log


Aof相关配置(redis.conf):

appendonly yes

是否开启AOF持久化,yes开启,no不开启

appendfilename appendonly.aof

指定AOF日志文件名称,默认名称:appendonly.aof

appendfsync everysec

什么时候将数据写入disk,redis提供三种模式:

no : 不进行fsync,有OS决定数据刷盘的时间粒度, 性能高

always : 每次写操作都做fsync , 安全

everysec : 上一个fsync后至少1s, 折中

no-appendfsync-on-rewrite no

当Aof log进行重写时,是否写日志时fsync。如果系统遇到latency问题,建议设为yes(rewrite时不强制fsync)

auto-aof-rewrite-percentage 100

当Aof log增长超过指定比例时,重写log file, 设置为0表示不自动重写Aof log

auto-aof-rewrite-min-size 64mb

启动重写Aof log时,Aof log的最小大小
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: