Redis Getting Started (c)

Endurance of

RDB way:

Persistence rdb way is through the snapshot is complete. Redis will automatically generate all the data in memory with a copy when certain conditions are met and stored on the hard disk, a process called snapshot. : Following situations cause data to snapshots
  1 snapshot automatically according to the configuration rule
  2 performed by the user save command or bgsve
  3 Run command flushall
  4 perform the copy

  According to the configuration: Save 900. 1, a key is changed and above the snapshot within 900 seconds.
  save or bgsave  : we have to manually perform when the service restarts, manual migration and backup.
  - save: redis in synchronization snapshot operation, during the execution of the snapshot will block all requests from the client.
  - bgsave: Snapshots can be operated asynchronously in the background, after the execution will return to OK immediately indicates the start of the snapshot operation. If you want to know whether you can use to complete the command to get lastSave time of the last successful execution snapshots. Look below asynchronous principle.
  flushAll command: redis will erase all the data in the database, regardless of the trigger snapshot or not, as long as the conditions for automatic snapshot is not empty, it will be done once.

  While the copy : When a master slave mode, redis will be automatically initiated when the copying speed of ah.

Snapshot principle

  Using the fork function copy of a copy of the current process (the child)
  parent continues to accept and process the command sent by the client, and the child began to data in memory is written to disk.
  All data is written, the temporary file will replace the old RDB file.
PS: After the restart redis reads RDB snapshot files, the data is loaded into memory.

AOF way:

When using a non-temporary data storage redis
open: not enabled by default, after opening each perform a change data is written to the hard disk of AOF documents.
AOF achieved: certain conditions, redis rewritten AOF file, save space and keep the last data.
Hard disk data synchronization: Due to caching mechanisms operating system, the data is not actually written to disk, but into the hard disk cache. By default, the system will perform a synchronized 30 seconds. In thirty seconds this may result in loss of data, you can perform a synchronization operation by setting parameters appendfsync per second.
redis allows simultaneous open AOF and RDB, persistence AOF way possible loss of data less.

Master-slave replication

Clusters

sentinel

Guess you like

Origin www.cnblogs.com/RobertLionLin/p/11415862.html