The RDB and aof of Redis

Source: Internet
Author: User
Tags redis version


TIP:
I. RDB and AOF at the same time turn on the default first load aof configuration file
Two. Same data set, AOF file is much larger than RDB file, recovery speed is slower than RDB
Three. AoF operation is slower than RDB, but the synchronization strategy is efficient and the unsynchronized efficiency is the same as the RDB

Advantages of the RDB:
An RDB is a compact, compressed binary file that represents a snapshot of the data for Redis at a certain point in time. Ideal for use in backup, full-scale replication, and other scenarios. For example, perform a bgsave backup every 6 hours and copy the Rdb file to a remote machine or file system (such as HDFS) for disaster recovery.
Redis loading RDB recovers data much faster than the AoF method.

Disadvantages of the RDB:
RDB mode data has no way of real-time persistence/second-level persistence. Because Bgsave performs a fork operation to create a sub-process each time it runs, it is a heavyweight operation that is too expensive to perform frequently.
The Rdb file is saved in a specific binary format, and there are multiple formats of RDB stupidity in the Redis version evolution, and there is an issue where the old Redis service is not compatible with the new version of the RDB format.


AOF definition: Record each operation as a log, record all of the commands performed by Redis (read operation not recorded), only append files but not modify files, Redis startup reads aof configuration file refactoring data
In other words, the Redis reboot will perform the recovery of the data based on the log content.


1.RDB persistence (snapshot) policy (default):
Save 900 1 (15 minutes change once)
Save 300 10 (5 minutes change 10 times)
Save 60 10000 (1 minutes change 10,000 times)


2.RDB Default profile Name:
Dbfilename Dump.rdb


3. Indicates whether to turn on aof persistence:
AppendOnly Yes (default no, off)


4.AOF Persistent configuration file name:
Appendfilename "Appendonly.aof"


5.AOF persistence Policy (default per second):
Appendfsync Always (synchronous persistence, data changes are immediately logged to disk, performance is poor but data integrity is better)
Appendfsync everysec (asynchronous operation, record per second, if downtime within one second, data loss)
Appendfsync No (the cache writeback policy is given to the system, Linux defaults to 30 seconds to write the buffer data back to the hard drive)


6.AOF configuration file Corruption Repair method:
Enter the Redis installation path to perform redis-check-aof--fix aof profile Name


7.AOF rewrite (rewrite):
Definition: aof persist data in the form of file append, so the file will become larger and bigger, in order to avoid this situation, the rewriting mechanism is added.
When the size of the aof file exceeds the threshold set by the configuration, Redis initiates the aof file compression, preserving only the smallest set of instructions that can recover the data, which can be used with command bgrewriteaof.

Principle: When the aof grows too large, it will fork out a new process to rewrite the file (also write the temporary file last rename), traverse the new process memory data, each record has a set statement.
Overriding the AoF file does not manipulate the old aof file, but instead overwrites the entire in-memory data content with a new aof file (a bit like a snapshot) in the form of a command.

Trigger mechanism: Redis records the size of the AoF file when it was last rewritten, and is triggered when the aof file size is one times the size of the last rewrite and the file is larger than 64M.
Auto-aof-rewrite-percentage 100 (One times)
Auto-aof-rewrite-min-size 64MB


8.RDB and AOF options:
Do backup: When the amount of data is large, and the recovery speed is required, and the consistency of data requirements are not high, you can use only the RDB
Cache only: Do not open any persistence mode
Both open the proposal: RDB data is not real-time, while using both the server will only find aof files, can only use AOF? recommended, because the RDB is more suitable for backing up the database (aof is changing, bad backup), fast restart, and does not aof potential bugs, To stay in the way of the case.


Source:
Https://www.cnblogs.com/wangfajun/p/5787077.html
Http://www.chenxm.cc/post/526.html


The RDB and aof of Redis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.