博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Redis的快照持久化-RDB与AOF
阅读量:4365 次
发布时间:2019-06-07

本文共 1738 字,大约阅读时间需要 5 分钟。

 Redis持久化功能

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

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

 

1. snap shotting快照持久化

 

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

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

 

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

[csharp] view plain  copy
 
 print?
  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.   
  23. save 900 1  
  24. save 300 10  
  25. save 60 10000  

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

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

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

以上三个save的理解:

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

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

 

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

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

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

 

2、手动发起快照持久化

 

 

手动发起快照持久化

 
 

转载于:https://www.cnblogs.com/goody9807/p/7420285.html

你可能感兴趣的文章
oracle数据库服务介绍
查看>>
SQL存储过程分页实现
查看>>
Oracle 11gR2 deferred segment creation 与 exp/imp 说明
查看>>
java基础知识系列--- 反射,注解,泛型,内省
查看>>
Android adb的使用
查看>>
Ubuntu18.04 + cuda9.0+cudnn7.0
查看>>
CF484E Sign on Fence
查看>>
mybatis的二级缓存的使用
查看>>
cd命令
查看>>
Uvalive6885(最短路)
查看>>
Java WebService学习笔记 - Axis(一)
查看>>
双表联合查询
查看>>
HBuilder控制台集成命令提示符(终端/CMD)功能
查看>>
我存在的问题 很头大 这里啊
查看>>
Linux 下 MQ 的安装
查看>>
JAVA语法基础作业——动手动脑以及课后实验性问题 (二)
查看>>
2018-2019-1 20165337 《信息安全系统设计基础》第六周学习
查看>>
C++函数参数传递方式(Effective C++之20, 21)
查看>>
在Html页面中调用ajax代码
查看>>
Contest2178 - 2019-4-18 高一noip基础知识点 测试7 题解版
查看>>