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
  • 相关阅读:
    metasploit生成payload的格式
    Win10专业版激活
    用Python对html进行编码
    ubuntu服务器搭建DVWA站点
    brew安装和换源
    生命中的最后一天【转】
    基础博弈
    jQuery-4.动画篇---jQuery核心
    jQuery-4.动画篇---自定义动画
    jQuery-4.动画篇---动画切换的比较(toggle与slideToggle以及fadeToggle的比较)
  • 原文地址:https://www.cnblogs.com/gabin/p/13666134.html
Copyright © 2011-2022 走看看