首页 > 其他 > 详细

Redis5-持久化

时间:2021-08-25 08:23:24      阅读:16      评论:0      收藏:0      [点我收藏+]

单机持久化

存储层

  1. 快照/副本

  2. 日志

RDB

对应快照

技术分享图片

时点性,是每隔一段时间存一下

  • 阻塞,redis不对外提供服务

    技术分享图片
  • 非阻塞,redis继续对外提供服务

    非阻塞过程写个过程中存在修改,数据正确性不能保证,备份的时间点也无法确认,redis采用下图方式无法实现

    技术分享图片
  • 非阻塞,fork方式

redis 子进程用来RDB持久化落盘,父进程用来提供服务

技术分享图片

管道

  1. 衔接,前一个命令的输出作为后一个命令的输入

  2. 管道会触发创建【子进程】

    echo $$ | more

    echo $BASHPID | more

    \[ 优先级高于 | ,普通变量 `$BASHPID`优先级低于管道 \]

技术分享图片

父子进程&fork

使用linux的时候:父子进程 父进程的数据,子进程可不可以看得到?

常规思想,进程是数据隔离的!

技术分享图片

进阶思想,父进程其实可以让子进程看到数据!

linux中export的环境变量,子进程的修改不会破坏父进程

父进程的修改也不会破坏子进程

技术分享图片 技术分享图片 技术分享图片
![image-20210823230439427](https://img2020.cnblogs.com/blog/2495843/202108/2495843-20210824231840796-1024485643.png)

写时复制

在fork之后exec之前两个进程用的是相同的物理空间(内存区),子进程的代码段、数据段、堆栈都是指向父进程的物理空间,也就是说,两者的虚拟空间不同,但其对应的物理空间是同一个

当父子进程中有更改相应段的行为发生时,再为子进程相应的段分配物理空间

技术分享图片

开启方式

redis.conf配置文件

技术分享图片

AOF(append only file)

对应日志

技术分享图片

日志目录 /var/lib/redis/6379

技术分享图片

开启混合模式 aof-use-rdb-preamble yes

# When loading Redis recognizes that the AOF file starts with the "REDIS"
# string and loads the prefixed RDB file, and continues loading the AOF
# tail
aof-use-rdb-preamble no

技术分享图片

AOF自动记录

# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

Redis5-持久化

原文:https://www.cnblogs.com/zhoum/p/15183022.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!