Redis5-持久化
单机持久化
存储层
-
快照/副本
-
日志
RDB
对应快照
时点性,是每隔一段时间存一下
-
阻塞,redis不对外提供服务
-
非阻塞,redis继续对外提供服务
非阻塞过程写个过程中存在修改,数据正确性不能保证,备份的时间点也无法确认,redis采用下图方式无法实现
-
非阻塞,fork方式
redis 子进程用来RDB持久化落盘,父进程用来提供服务

管道
-
衔接,前一个命令的输出作为后一个命令的输入
-
管道会触发创建【子进程】
echo $$ | more
echo $BASHPID | more
\[ 优先级高于 | ,普通变量 `$BASHPID`优先级低于管道 \]

父子进程&fork
使用linux的时候:父子进程 父进程的数据,子进程可不可以看得到?
常规思想,进程是数据隔离的!

进阶思想,父进程其实可以让子进程看到数据!
linux中export的环境变量,子进程的修改不会破坏父进程
父进程的修改也不会破坏子进程
写时复制
在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
本文来自博客园,作者:gary2048,转载请注明原文链接:https://www.cnblogs.com/zhoum/p/15183022.html
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

浙公网安备 33010602011771号