Redis持久化功能

Redis为了内部数据的安全考虑,会把本身的数据以文件形式保存到硬盘中一份,在服务器重启之后会自动把硬盘的数据恢复到内存(redis)的里边。

数据保存到硬盘的过程就称为“持久化”效果。

1. snap shotting快照持久化

该持久化默认开启,一次性把redis中全部的数据保存一份存储在硬盘中,如果数据非常多(10-20G)就不适合频繁进行该持久化操作。

下方是快照持久化在本地硬盘保留的数据备份文件(redis自动生成):

查看快照持久化的备份频率(打开redis.conf):

  1. ################################ SNAPSHOTTING  #################################
  2. #
  3. # Save the DB on disk:
  4. #
  5. #   save <seconds> <changes>
  6. #
  7. #   Will save the DB if both the given number of seconds and the given
  8. #   number of write operations against the DB occurred.
  9. #
  10. #   In the example below the behaviour will be to save:
  11. #   after 900 sec (15 min) if at least 1 key changed
  12. #   after 300 sec (5 min) if at least 10 keys changed
  13. #   after 60 sec if at least 10000 keys changed
  14. #
  15. #   Note: you can disable saving at all commenting all the "save" lines.
  16. #
  17. #   It is also possible to remove all the previously configured save
  18. #   points by adding a save directive with a single empty string argument
  19. #   like in the following example:
  20. #
  21. #   save ""
  22. save 900 1
  23. save 300 10
  24. save 60 10000

save 900 1          #900 秒内如果超过 1 个 key 被修改,则发起快照保存

save 300 10        #300秒超过10个key被修改,发起快照

save 60 10000    #60秒超过10000个key被修改,发起快照

以上三个save的理解:

数据修改的频率非常高,备份的频率也高

数据修改的频率低,备份的频率也低

查看快照持久化文件的名字和存储位置(打开redis.conf):

  1. # The filename where to dump the DB
  2. dbfilename dump.rdb
  3. # The working directory.
  4. #
  5. # The DB will be written inside this directory, with the filename specified
  6. # above using the 'dbfilename' configuration directive.
  7. #
  8. # The Append Only File will also be created inside this directory.
  9. #
  10. # Note that you must specify a directory here, not a file name.
  11. dir ./

快照持久化 和 精细持久化  可以尽最大程度保证数据的安全:

2、手动发起快照持久化

手动发起快照持久化

 
 

Redis的快照持久化-RDB与AOF的更多相关文章

  1. Redis之数据持久化RDB与AOF

    Redis之数据持久化RDB与AOF https://www.cnblogs.com/zackku/p/10087701.html 大家都知道,Redis之所以性能好,读写快,是因为Redis是一个内 ...

  2. 进阶的Redis之数据持久化RDB与AOF

    大家都知道,Redis之所以性能好,读写快,是因为Redis是一个内存数据库,它的操作都几乎基于内存.但是内存型数据库有一个很大的弊端,就是当数据库进程崩溃或系统重启的时候,如果内存数据不保存的话,里 ...

  3. redis学习之——持久化RDB 和AOF

    RDB: 在指定的时间间隔内将内存中的数据集快照写入磁盘, 也就是行话讲的Snapshot快照,它恢复时是将快照文件直接读到内存里.rdb 保存的是dump.rdb文件 RDB工作原理: Redis会 ...

  4. Redis持久化RDB和AOF优缺点是什么,怎么实现的?我应该用哪一个?

    原文http://www.ymq.io/2018/03/24/redis/ Redis是一种高级key-value数据库.数据可以持久化,而且支持的数据类型很丰富.有字符串,链表,集 合和有序集合.支 ...

  5. Linux - redis持久化RDB与AOF

    目录 Linux - redis持久化RDB与AOF RDB持久化 redis持久化之AOF redis不重启,切换RDB备份到AOF备份 确保redis版本在2.2以上 实验环境准备 备份这个rdb ...

  6. redis持久化 RDB与AOF

    redis持久化 RDB与AOF RDB与AOF区别 rdb: 基于快照的持久化,速度更快,一般用做备份,主从复制也是依赖于rdb持久化功能 aof:以追加的方式记录redis操作日志的文件,可以最大 ...

  7. redis持久化RDB和AOF

    Redis 持久化: 提供了多种不同级别的持久化方式:一种是RDB,另一种是AOF. RDB 持久化可以在指定的时间间隔内生成数据集的时间点快照(point-in-time snapshot). AO ...

  8. redis 消息队列(发布订阅)、持久化(RDB、AOF)、集群(cluster)

    一:订阅: 192.168.10.205:6379> SUBSCRIBE test Reading messages... (press Ctrl-C to quit) 1) "sub ...

  9. redis持久化RDB与AOF

    redis持久化 Redis是一种内存型数据库,一旦服务器进程退出,数据库的数据就会丢失,为了解决这个问题,Redis提供了两种持久化的方案,将内存中的数据保存到磁盘中,避免数据的丢失. RDB持久化 ...

随机推荐

  1. python之requests 乱七八糟

    1.预配置 import requests ss = requests.Session() ss.headers.update({'user-agent':'Mozilla/5.0 (Windows ...

  2. ipython启动 自动导入模块 自动%logstart

    1. 参考 启动ipython或python解释器自动导入组件(例如:numpy) http://ipython.org/ipython-doc/stable/config/intro.html#se ...

  3. 带你了解zabbix整合ELK收集系统异常日志触发告警~

    今天来了解一下关于ELK的“L”-Logstash,没错,就是这个神奇小组件,我们都知道,它是ELK不可缺少的组件,完成了输入(input),过滤(fileter),output(输出)工作量,也是我 ...

  4. nginx-fastcgi 反向代理

    Nginx处理php页面 用fpm-server  基于fastcgi模块实现 Ngx_http_proxy_module  只能反代后端http server的主机 Ngx_fastcgi_prox ...

  5. 清除DNS缓存(解决能上QQ但是无法上网页问题)

    ipconfig/displaydnsipconfig/flushdns

  6. Idea中快捷键与小技巧的总结-->持续更新

    1.Scala类或单例对象中快速声明实例对象: eg. new SparkContext(conf).var 系统会自动提示,可以自动补全,如图: 2.ctrl+i与ctrl+o的区别: ctrl + ...

  7. LYOI 2016 Summer 函数 【线段树】

    <题目链接> 题目大意: fqk 退役后开始补习文化课啦,于是他打开了数学必修一开始复习函数,他回想起了一次函数都是 f(x)=kx+b的形式,现在他给了你n个一次函数 fi(x)=kix ...

  8. Django模板之通用模板的使用

    Django模板之通用模板的使用 转载:https://code.ziqiangxuetang.com/django/django-template.html 我们做网站有一些通用的部分,比如 导航, ...

  9. Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and you have APPEND_SLASH set.

    Django报错:提交表单报错---RuntimeError: You called this URL via POST, but the URL doesn’t end in a slash and ...

  10. basename

    我使用过的Linux命令之basename - 去掉文件名的目录和后缀 本文链接:http://codingstandards.iteye.com/blog/840784   (转载请注明出处) 用途 ...