aprendizagem Redis [sete] persistência de dados

dados Redis persistência de duas maneiras. RDB e AOF.

1, RDB

RDB é um instantâneo do caminho através do processo de persistência. condições específicas de vitória, um instantâneo dos dados estarão na memória para o disco rígido. RDB instantâneo das seguintes condições

1.1, arquivo de configuração redis.conf (arquivo de janelas é redis.windows-service.conf)

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
#
#   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.
#
#   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
#
#   Note: you can disable saving completely by commenting out all "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 ""    设置为空是不开RDB

save 900 1        900秒内,有一个key更改就触发快照
save 300 10       300秒内,有10个key更改就触发快照
save 60 10000     60秒内有10000个key更改。触发快照
# The filename where to dump the DB
dbfilename dump.rdb     RDB快照保存在磁盘的文件名

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./                  保存的路径

Redis servir como informação lateral no sistema operacional Windows

 Como pode ser visto a salvar operação realizada em 3600 segundos

1.2, a implementação de excepto bgsave

1.3, flushall bem

 

2, AOF

AOF é cada Redis comandos são gravados no disco

############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check http://redis.io/topics/persistence for more information.

appendonly no       AOF持久化开关

# The name of the append only file (default: "appendonly.aof")
appendfilename "appendonly.aof"       文件名
# The fsync() call tells the Operating System to actually write data on disk
# instead of waiting for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
#
# Redis supports three different modes:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log . Slow, Safest.
# everysec: fsync only one time every second. Compromise.
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# "no" that will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".

# appendfsync always           每个命令都执行同步
appendfsync everysec           每秒同步
# appendfsync no               不同步

Conteúdo AOF arquivo

 3, a diferença RDB e o AOF

RDB persistência significa que dentro de um tempo especificado instantâneo de memória intervalo do conjunto de dados são gravados no disco, a operação real é desembolsar um processo filho, o primeiro conjunto de dados gravados em um arquivo temporário, escrita com sucesso, em seguida, substituir o arquivo antes , armazenamento comprimido binário.

 AOF persistiu na forma de registros de log processados ​​pelo servidor a cada gravação, operação de consulta de exclusão não é registrada, o texto gravado, você pode abrir o arquivo para ver o registro de funcionamento detalhado.

A figura podemos extrair as seguintes informações

1, RDB concretizao dados persistentes menor do que AOF, AOF Redis cada instrução necessita de ser escrito para a forma persistente.

2, RDB contraste AOF, um maior risco de perda de dados. Dentro do tempo de inatividade do servidor de intervalo de backup.

3, AOF de RDB de recuperação de dados leva mais tempo.

 

Publicado 22 artigos originais · ganhou elogios 9 · vista 8813

Acho que você gosta

Origin blog.csdn.net/ljm_c_bok/article/details/104924969
Recomendado
Clasificación