Redis Learning three Redis persistence

Source: Internet
Author: User
Tags redis server

 1, Snapshot persistence      1 introduction      redis can create a snapshot to get a copy of the data for the memory at a point in time, after having a copy, You can send a copy to another Redis server to create the same data from the server, while the snapshot remains in place to restart Redis for data recovery.      2 configuration       save   Snapshot generation strategy   If the server is over 60 seconds from the last successful snapshot generation, And at least 1000 write operations were performed during the period.      stop-writes-on-bgsave-error Yes whether to continue the write command after failed to create the snapshot file      rdbcompression Yes   Do you want to compress the snapshot files      dbfilename dump.rdb   Snapshot file names      dir/opt/redis-2.8.13/dmp/  Path to persisted file save      3 Snapshot file generation      1, send Bgsave command to Redis, Redis calls Fork to create a child process, the child process is responsible for creating the snapshot, The parent process continues to process the command request.      2, send the Save command to Redis, the parent process stops responding to other commands, starts the snapshot creation, and the Save command is usually not used, typically when there is not enough memory to execute bgsave or to let the client wait.      3, according to the user settings of the Save policy configuration information, to perform. If multiple configurations are configured, execute as long as one is satisfied.      4,redis When a shutdown or standard term command is received, the Save command is triggered to create a snapshot.      5, when the server is linked to the primary server and the Sync command is sent to synchronize the data, and this time the master server is not executing bgsave or not just finished bgsave, create a snapshot for the replication to use.       when memoryWhen the amount of data is not so large, it is good to use snapshot persistence. But if the amount of data reached more than more than 10 g, the execution of a bgsave will be particularly slow, save will be faster, but it will take more time, and the snapshot file is also relatively large. This is the time to use aof persistence. 2,aof Persistence      1 introduction       Simply put, aof persistence writes the executed write command to the end of the aof file to record all changes. Redis can perform data recovery as long as the aof file command is executed from beginning to end.      2, configuration      appendonly Yes   open aof persistence      appendfilename " Appendonly.aof "  Persistent file name      # Appendfsync always   each Redis write command is persisted, which severely reduces redis speed, But the data is basically not lost      appendfsync everysec     Once per second, lost data is also within one second       # Appendfsync no     Let the operating system decide when to execute      no-appendfsync-on-rewrite no     auto-aof-rewrite-percentage   When the aof file is at least 100% larger than the last rewrite, rewrite       Auto-aof-rewrite-min-size 64mb     rewrite       when the volume islands are 64M, overriding these two conditions when they match.      dir/opt/redis-2.8.13/dmp/  Persistent file save path      3,aof file rewrite       AOF file due to the constantAppend write command, so the volume will be larger, then send Bgrewriteaof command to Redis, you can rewrite the aof, remove the redundant commands, reduce the volume, but also the main process fork out a sub-process to handle. For this command you can also configure Redis to maintain its own execution. 3, data recovery       When the Redis server is hung up, the data will be restored to memory:     if only the AOF is configured, and the AoF file recovery data is loaded when the reboot is restarted. , (the RDB is closed by commenting out the configuration information of the RDB, as long as it is not persisted if the Bgsave command is not actively sent)       if both RBD and AOF are configured, start is to load aof file recovery data only;       If only RBD is configured, startup is to speak load dump file recovery data.

Redis Learning three Redis persistence

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.