Viii. Redis Basic Command---Management--persistent--RDB

Source: Internet
Author: User

1, Redis support two ways of persistence, one is an RDB, one is aof. Can be used alone or in combination.
2. RDBA, the Rdb method is the persistence mode that Redis adopts by default, which is done by snapshot (snapshotting). When certain conditions are met, Redis automatically snaps all the data in memory and stores it on the entire hard disk. The condition of the snapshot: the number of times and changes to the key. A snapshot is taken when the number of keys changed within a specified amount of time is greater than the specified number.      B, the configuration file has been pre-set 3 conditions:Save 1Save 300 10
Save 10000
C, the Save parameter specifies the snapshot condition, which can save multiple conditions, and the relationship between the conditions is "or". As above, take a snapshot at least one key is changed within 900 seconds. Time Unit is seconds
D, Redis by default, the snapshot files are stored in the current directory of the Dump.rdb file, you can also use Dir and dbfilename two parameters to specify the snapshot file storage path and file name.
E, Redis implementation of the snapshot process:1) Redis uses the fork function to copy a copy of the current process (the parent process) (child process)     2) The parent process continues to accept and process commands from the client, and the child process begins to write the in-memory data to a temporary file on the hard disk
3) When the child process has finished writing all the data, the temporary file is replaced with the old Rdb file, and the snapshot operation is completed.
F, when the fork is executed, the operating system uses the write-time copy (Copy-on-write) policy, that is, the moment the fork () function occurs, the parent-child process shares the same memory space, and when the parent process wants to change a piece of data, such as executing a write command, The operating system copies the piece of data to ensure that the child process's data is not affected, so the new Rdb file stores the memory data at the fork () moment.
G, Redis will replace the old Rdb file with the new one at the end of the snapshot, i.e. the Rdb file is complete at any time. In this case, we can back up the Redis data by backing up the Rdb file.      H, RDB files are compressed binary format, so occupy less space than in-memory data size, more conducive to transmission. You can also set the Redcompression parameter to disable compression.
I, manual redis Execution Snapshot command: SAVE \ BGSAVE, the difference is that the former is a snapshot operation by the main process, will block the other requests, the latter will be through the fork child process snapshot operations.      J. When Redis starts, it reads the RDB snapshot file and loads the data from the hard disk into memory.
K, RDB persist data, and once Redis exits unexpectedly, it loses the data that was changed after the last snapshot.     If the data is important enough to withstand any loss, you can use AOF to persist.









Viii. Redis Basic Command---Management--persistent--RDB

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.