AOF Features of Redis

Source: Internet
Author: User
Tags redis server

Introduction: Redis is a memory-based database and also provides a number of persistent scenarios that allow users to write in-memory data to the local file system for the next reboot or after the machine continues to be used. This article describes how to set the AoF feature based on Redis


What is Redis's aof?

AOF is the abbreviation for appendonly file, a Redis system that provides a persistence scheme for documenting redis operations, and in aof generated files, will faithfully record the operations that occur in Redis, so that after the Redis server restarts or the machine is The mechanism for resuming the previous data state.


Let's take a brief look at how to use aof in Redis and verify the entire process:

A. Primary aof settings in Redis

AppendOnly Yes----Open the AOF settings while placing the snapshot feature in a low priority location

Appendfsync No
When setting Appendfsync to No, Redis does not actively invoke Fsync to synchronize aof log content to disk, so it is entirely dependent on the debug of the operating system. For most Linux operating systems, Fsync is performed every 30 seconds, and the data in the buffer is written to disk.
Appendfsync everysec
When setting Appendfsync to Everysec, Redis will default to a Fsync call every second, writing data from the buffer to disk. However, this time when the Fsync call is longer than 1 seconds. Redis takes a deferred fsync policy and waits another second. That is, in two seconds after the Fsync, this time Fsync no matter how long it will be carried out. Because the file descriptor is blocked at Fsync, the current write operation is blocked.
The conclusion is that in the vast majority of cases, Redis will fsync once every second. In the worst case, a fsync operation is performed in two seconds. This operation is called Group commit in most database systems, which is the combination of multiple write operations and writes the logs to disk at once.
Appendfsync always
Set Appendfsync as always, each write operation will be called once Fsync, then the data is the safest, of course, because each time will be executed Fsync,
So the performance will also be affected.

B. Start Redis-server

C. Open REDIS-CLI, manipulate data

D. View AoF File

From the above illustration, it can be found that in the AoF file, it faithfully records the operations that occur on the Redis, thus achieving the purpose of restoring the data. Of course, this is not a very efficient way. The main problem is that it is possible to do a lot of work on some of the data. In this case, a large number of redundant operation records must be generated. For the solution to this problem, I will be involved in the following blog.

Reprint: http://blog.csdn.net/blueheart20/article/details/26520823

AOF Features 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.