Small note redis persistence mechanism

  Just learning redis, often see two persistence mechanism in the eyes of head shaking, RDB and AOF, but also know the time to learn these two things is hell, over time forgot, Chinese memories of these two concepts always felt some awkward. Today whim look redis profiles, suddenly, as if opened a new world, are summarized as follows.

  RDB mechanisms:

 save <seconds> <changes>

   Will save the DB if both the given number of seconds and the given
   number of write operations against the DB occurred.

This sentence means that we write once operation of the database, then this operation will redis database for persistence

In the example below the behaviour will be to save:
   after 900 sec (15 min) if at least 1 key changed
   after 300 sec (5 min) if at least 10 keys changed
   after 60 sec if at least 10000 keys changed

Then, reids default persistence to follow such a strategy for persistence, if the 1-9 keys to change, and after 15 minutes reids will be persistent;

If less than 10 key changes, the database will be persistent after 5min; if less than 10 000 key changes, the database will persist after 1min. Based on this strategy, which we call snapshot, the data set generated in a specified interval time snapshots (point-in-time snapshot) . Snapshot This concept might sound very ignorant, after this analysis, and instantly feel this concept fleshed out as you press the shutter to record this information in the same instant.

Note: you can disable saving at all commenting all the "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1
save 300 10
save 60 10000

Since there is a default mechanism, but also allows us to set up their own redis this persistent intervals, format: save + interval + minimum number of key changes.

By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in an hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# distater will happen.

  #If the background saving process will start working again Redis will
  # automatically allow writes again.

 

If redis Based on this persistence strategy, after the entry into force of the snapshot, the background of this node is located after the persistence operations will not be performed. This means that our redis persistent data inaccuracies may exist. Only when the daemon is restarted, redsi will operate automatically written. This sentence means is that, assuming there is a scenario:

If the node redis have been in a persistent snapshots once, it happens behind us and had a background writing operation, we immediately closed the redis, then our last data is persisted to disk on the?

First, the nodes within two to redis closed during this time, whether or not a snapshot node, depending on the time interval meets the persistence strategy, so this will not lead to the accuracy of our data is stored.

 

Guess you like

Origin www.cnblogs.com/Mr-k404/p/11487295.html