Redis 存储持久化

Redis · Fecmall · 于 6年前 发布 · 1794 次阅读

redis有几种内存的数据同步到磁盘的操作,详细可以参看文章:https://www.cnblogs.com/datang6777/p/7056272.html

我们选择的是:Append-only file

vim /etc/redis/6379.conf

    appendonly yes      #启用aof持久化方式
    appendfsync everysec     #每秒钟强制写入磁盘一次,在性能和持久化方面做了很好的折中,推荐
    auto-aof-rewrite-percentage 200   #自动的bgrewriteaof,aof文件的大小超过基准百分之多少后触发bgrewriteaof。默认这个值设置为100,意味着当前aof是基准大小的两倍的时候触发bgrewriteaof。把它设置为0可以禁用自动触发的功能。
    auto-aof-rewrite-min-size 128mb     #当前aof文件大于多少字节后才触发。避免在aof较小的时候无谓行为。默认大小为64mb。
    #  然后就是触发检查的主逻辑,serverCron时间事件中每次都会检查现有状态和参数来判断是否需要启动bgrewriteaof。
    #  如果aof文件增长百分率growth大于auto_aofrewrite_perc,则自动的触发后一个bgrewriteaof。

保存,重启redis

    /etc/init.d/redis_6379 stop
    /etc/init.d/redis_6379 start

redis 磁盘持久化,不能强制kill,否则有出问题报错:

error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

解决参看:http://www.fecshop.com/topic/675

共收到 0 条回复
没有找到数据。
添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics