Redis of making RDB file recovery program by lucky airship

Principle
redis persistence implementation There are two ways lucky airship program production q-1152880099RDB (Redis DataBase enabled by default) and AOF (Append Only File off by default) is through to save the file on disk, in redis service at startup, in the data is read into memory. So we open the service time at the restart, before the data found there.

Implementation mechanism
rdb embodiment is given by a time snapshot of a dataset (the Snapshot) memory is written to disk; when data recovery, and then the snapshot information is read into memory.

Advantages and disadvantages
Advantages: Suitable for large-scale data recovery, integrity and consistency of data less demanding;
disadvantage: do a backup within a certain time interval, part of the data will be lost, will be lost because generally the last record-keeping, you can Gets the last time snapshot view through lastsave.

View the last time the command is written to disk:

10.3.152.78:6379> LASTSAVE
(Integer) 1,563,805,120 #Unix timestamp
Note: When we open simultaneously two bell persistent way, redis restart time will give priority to load aof file to restore data because, in general, write aof storage of file data is stored in the form of documents more than rdb complete.

Recovery simulation
1, respectively, the two redis redis server service stops.
2, the need to restore the rdb file, copied to another server, see the current storage location path

10.3.152.78:6379> config dir GET
1) "dir"
2) "/ var / lib / redis" #rdb file storage path, and to ensure that no aof file exists, otherwise the default priority load this file
10.3.152.78:6379>
. 3, with the appropriate permissions to modify the same file (the current guaranteed rdb file of the same name and permissions, cover)
4, start the service redis
5, viewed with the info command, whether the current number of data consistent with

Guess you like

Origin www.cnblogs.com/wowotoubbs/p/11230783.html