zoukankan      html  css  js  c++  java
  • Redis持久化策略

    1、RDB:快照-纯缓存使用可只用RDB作为持久化方案,甚至不持久化

    • 时间点问题:比如 8:00开始快照,8:10分才快照成功,那么快照的是8:00还是8:10分的数据
    • 方式:
      • save    【命令】  
      • bgsave 【命令】- fork[linux]另起一个子进程,数据隔离(写时复制)进行数据快照
      •  
      • save <seconds> <changes> 【配置-注意:这边实际上调用的是bgsave命令】

          参考配置文件中的说明:大概指的是指定时间内至少有多少个数据改变

          

    ################################ SNAPSHOTTING  ################################
    #
    # Save the DB on disk:
    #
    #   save <seconds> <changes>
    #
    #   Will save the DB if both the given number of seconds and the given
    #   number of write operations against the DB occurred.
    #
    #   In the example below the behaviour will be to save:
    #   after 900 sec (15 min) if at least 1 key changed
    #   after 300 sec (5 min) if at least 10 keys changed
    #   after 60 sec if at least 10000 keys changed
    #
    #   Note: you can disable saving completely by commenting out all "save" lines.
    #
    #   It is also possible to remove all the previously configured save
    #   points by adding a save directive with a single empty string argument
    #   like in the following example:
    #
    #   save ""
    
    save 900 1
    save 300 10
    save 60 10000

    ps:涉及点-父子进程之间,数据隔离&CopyOnWrite(仅写时复制)

       

    2、AOF:日志(一般做数据库使用时候需要用到,保证数据的完整性)

    • 开启【配置文件】:appendonly yes
    • 文件名【配置文件】:appendfilename "appendonly.aof"
    • 刷出缓冲【配置文件】:appendfsync everysec[always|no]             - 使用always会影响redis的性能
    • auto-aof-rewrite-percentage 100
      auto-aof-rewrite-min-size 64mb

    • 重写aof,主要是为了避免文件过大,AOF和混合模式的格式会有不同

    3、混合 - 兼具两者的优点:利用rdb的快速恢复和aof的数据完整性【比如用于主从复制中,先读取rdb文件,再从aof读取增量操作】

    • 开启【配置文件】:aof-use-rdb-preamble yes
  • 相关阅读:
    nginx 部署
    win 7 系统ie浏览器升级11版本后,f12功能不可用的问题
    selenium 调用键盘按键
    selenium + python 环境搭建
    解决word2013老是打开未响应情况
    win7 64位备份时, 无法启动服务,0x80070422
    个人学习网站收集
    矩形后旋转后顶点坐标的求解
    Acrobat_8_Pro_SC 激活老是提示你输入的授权码无效
    DLL用def定义文件来导出重载函数(转)
  • 原文地址:https://www.cnblogs.com/gabin/p/13666134.html
Copyright © 2011-2022 走看看