The SAVE | bgsave | SHUTDOWN (set automatic persistence strategy when the premise)
Related
save 60 1000 # 多久执行一次自动快照操作, 60秒内如果更新了1000次, 则持久化一次
stop-write-on-bgsave-error no # 创建快照失败后, 是否继续执行写命令
rdbcompression yes # 是否对快照文件进行压缩
dbfilename dump.rdb # 如何命名快照文件
dir ./ # 快照文件保存的位置
save # 关闭RDB机制
Advantages and disadvantages
advantage
Facilitate data backup : saving due to a separate file , the data backup easily (can use timed task, the timing to send the file to the backup data center)
Copy On Write : child process to complete persistence operations alone, the parent process does not participate IO operations, maximize performance redis
When large amounts of data recovery, is faster than AOF
Shortcoming
Real-time data is not saved , if redis unexpectedly stops working (such as power failure, etc.), you may lose data over time
When large volumes of data, fork process will be slower, redis slow response times when persistence
1.2 AOF only append files
Append-only file only append files
Only added , but not all rewritten
Append command , rather than data
mechanism
The main thread will write commands added to the aof_buf (buffer), depending on the use of different strategies, the child thread write command buffer to the aof file (do not use child process)
When redis restart, it will re-execute the aof file command to recover data
If both the RDB , the priority use of AOF
File Repair
If you use the AOF error (disk is full / write process downtime, etc.), then redis reject this AOF file restart
Repair steps
First of all backup files AOF
Use reids-checkout-aof tool to repair (usually at the end of the delete command can not be recovered)
Redis restart the server, back-end loaded automatically repair AOF files, data recovery