Redis function of AOF

Introduction: Redis is a memory-based database, while also providing a number of a lasting solution that allows users to the data memory, write to the local file system to prepare for the next restart or continue to be used when the machine. This article describes how to set AOF function based on Redis

What is Redis of AOF?
AOF is an abbreviation AppendOnly File is Redis system provides persistence scheme Redis operation record, in the AOF generated file, occurs in the recording operation Redis faithfully to achieve the server or after a restart Redis crash, continued data recovery mechanism before the state.

Below we briefly look at how to use the AOF in Redis and verify the entire process:

A. Redis in the main AOF set
   appendonly yes ---- open aof setting, while the snapshot function in a low-priority position
  appendfsync no
        When set appendfsync to no time, Redis will not take the initiative to call fsync AOF log content synchronization to disk, so all of this is completely dependent on the operating system debugging. For most Linux operating system, is carried out every 30 seconds fsync, the data buffer is written to disk.
   appendfsync everysec
        When set appendfsync to everysec time, Redis will fsync calls by default once every second, the data buffer is written to disk. But when this time fsync call longer than 1 second. Redis will fsync adopted strategy of delay, wait a second. Fsync is carried out in about 2 seconds after, this time fsync will perform no matter how long it will be. This time because the file descriptor will be blocked when the fsync, so the current write operation will be blocked.
        The conclusion is that, in most cases, Redis will be carried out once every second fsync. In the worst case, two seconds will perform an fsync operation. This operation is referred to in most database systems group commit, it is a combination of multiple data write operation, a one-time write logs to disk.
   appendfsync always
        set appendfsync is always, every write operation will be called once fsync, then the data is the safest, of course, since every time the implementation of fsync,
so its performance will be affected.
 

Published 224 original articles · won praise 14 · views 40000 +

Guess you like

Origin blog.csdn.net/xulong5000/article/details/104947765