首页 > 数据库 >redis-2,redis持久化

redis-2,redis持久化

时间:2023-04-07 17:34:10浏览次数:38  
标签:持久 dump redis will rdb 快照 save

持久化

rdb:snapshot快照,持久化快照
aof:append only file 写命令操作全部记录下来

RDB

rdb持久性以指定的时间间隔,执行数据集的时间点快照,全量快照
rbd保存到磁盘的文件就是dump.rdb

案例

配置文件redis.conf
在配置文件中找到snapshotting

################################ 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.
快照默认触发方式有以下三种
900秒之内修改过一次
300秒之内修改过10次
60秒之内修改过10000次
这些情况下触发保存快照
#   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

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes

# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes

# The filename where to dump the DB
这里修改保存的名字
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
这里修改保存位置
dir /www/server/redis/

rdb的操作分为自动触发和手动触发。
当写一个提交命令的时候,比如flushdb,flushall,redis也会自动保存一份快照
shutdown命令模拟宕机的时候,也会保存最后一份快照
修改dump文件的保存路径
修改dump文件的名称

如何恢复

将备份文件dump.rdb移动到redis的安装目录并启动服务即可

AOF手动触发

标签:持久,dump,redis,will,rdb,快照,save
From: https://www.cnblogs.com/niko5960/p/17296890.html

相关文章

  • 非关系数据库型--Redis
    RedisRedis安装1.yum/apt安装root@ubuntu:~#aptinforedisPackage:redisVersion:5:6.0.16-1ubuntu1Priority:optionalSection:universe/databaseOrigin:Ubuntu[root@localhost~]#yuminforedisAvailablePackagesName:redisVersion:5.0.3......
  • Centos 7 yum 安装redis
    一、安装redis1、检查是否有redis yum 源yumlist|grepredis2、下载fedora的epel仓库yuminstallepel-release-y3、安装redis数据库yuminstallredis-y4.防火墙开放相应端口iptables-IINPUT-ptcp--dport6379-jACCEPT5.修改综合设置(用户名,密码,......
  • 记spring-security升级,引发的redis反序列化不一致问题
    问题解决参考文章如下:https://my.oschina.net/klblog/blog/5559133https://blog.csdn.net/qq_37421368/article/details/124850449问题复现由于一些原因,登录的token由旧版本的微服务存入的redis,另一个新版本的微服务需要取出数据校验springboot版本升级导致spring-secu......
  • Redis三主三从集群
    Redis-Cluster采用无中心结构,每个节点保存数据和整个集群状态,每个节点都和其他所有节点连接。一组RedisCluster是由多个Redis实例组成,官方推荐使用6实例,其中3个为主节点,3个为从节点。一旦有主节点发生故障的时候,RedisCluster可以选举出对应的从节点成为新的主节点,继续对外服务,......
  • Redis-基础(逐步完善)
    Redis持久化RDB/AOF命令RDB(dump.rdb文件)适用于大规模数据恢复,且对数据完整性和一致性不高的情况把当前进程数据生成快照保存到硬盘的过程RDB文件的处理保存位置:dbfilename压缩:rdbcompression,默认开启LZF压缩,会消耗CPU校验:rdbchecksum,使用CRC64算法校验RDB持久化触发方式......
  • Redis 持久化机制
    目录Redis数据持久化RDB(RedisDatabase)触发快照的时机AOF(AppendOnlyFile)AOF日志写入过程AOF重写机制AOF重写写时复制AOF重写缓冲区子进程重写的优点总结RDB+AOF组合Redis数据持久化Redis提供了四种持久化策略:RDB(RedisDatabase)、AOF、RDB+AOF和不持久化。RDB......
  • Spring Cache使用方式——不用默认,使用redis进行缓存
    在SpringBoot项目中使用SpringCache的操作步骤(使用redis缓存技术)1、导入Maven坐标spring-boot-starter-data-redis、sping-boot-starter-cache2、配置application.ymlspring:cache:redis:time-to-live:1800000#设置缓存......
  • redis基础数据结构详解
    一.redis为什么快基于内存的存储虽然是单线程,但是采取了多路复用,可以高效的处理网络并发良好的数据结构设计二.redis基础数据结构redis有五种基础的数据结构string,list,set,zset,hashredis所有的数据结构的key都是string类型,我们所说的数据结构都是指value的数据结构......
  • 通过 Homebrew 在 Mac OS X 上安装和配置 Redis
    通过使用Homebrew,可以大大降低在MacOSX上设置和配置开发环境的成本。让我们安装Redis。$brewinstallredis安装后,我们将看到一些有关配置注意事项的通知。离开它并继续关注本文中的一些任务。开机自启动Redis$ln-sfv/usr/local/Cellar/redis/7.0.10/*.plist......
  • docker-compose 运行 redis
    redis.conflogfile/data/redis/logs/redis.logdir/data/redis/databind0.0.0.0requirepass123456UID#dockerrun--rm-itredis:7.0.10idredisuid=999(redis)gid=999(redis)groups=999(redis)docker-compose.yamlversion:'3.9'services:r......