Redis 持久化之 AOF 配置詳解
############################## 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
# 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
# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
no-appendfsync-on-rewrite no
# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
#
# Specify a percentage of zero in order to disable the automatic AOF
# rewrite feature.
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
# An AOF file may be found to be truncated at the end during the Redis
# startup process, when the AOF data gets loaded back into memory.
# This may happen when the system where Redis is running
# crashes, especially when an ext4 filesystem is mounted without the
# data=ordered option (however this can't happen when Redis itself
# crashes or aborts but the operating system still works correctly).
#
# Redis can either exit with an error when this happens, or load as much
# data as possible (the default now) and start if the AOF file is found
# to be truncated at the end. The following option controls this behavior.
#
# If aof-load-truncated is set to yes, a truncated AOF file is loaded and
# the Redis server starts emitting a log to inform the user of the event.
# Otherwise if the option is set to no, the server aborts with an error
# and refuses to start. When the option is set to no, the user requires
# to fix the AOF file using the "redis-check-aof" utility before to restart
# the server.
#
# Note that if the AOF file will be found to be corrupted in the middle
# the server will still exit with an error. This option only applies when
# Redis will try to read more data from the AOF file but not enough bytes
# will be found.
aof-load-truncated yes
################################ LUA SCRIPTING ###############################
表示是否開啟AOF持久化:
appendonly yes(預設no,關閉)
AOF持久化配置檔案的名稱:
appendfilename “appendonly.aof”
AOF持久化策略(預設每秒):
appendfsync always (同步持久化,每次發生資料變更會被立即記錄到磁碟,效能差但資料完整性比較好)
appendfsync everysec (非同步操作,每秒記錄,如果一秒鐘內當機,有資料丟失)
appendfsync no (將快取回寫的策略交給系統,linux 預設是30秒將緩衝區的資料回寫硬碟的)
AOF的Rewrite(重寫) :
定義:AOF採用檔案追加的方式持久化資料,所以檔案會越來越大,為了避免這種情況發生,增加了重寫機制
當AOF檔案的大小超過了配置所設定的闕值時,Redis就會啟動AOF檔案壓縮,只保留可以恢復資料的最小指令集,可以使用命令bgrewriteaof
觸發機制:Redis會記錄上次重寫時的AOF檔案大小,預設配置時當AOF檔案大小是上次rewrite後大小的一倍且檔案大於64M時觸發
auto-aof-rewrite-percentage 100 (一倍)
auto-aof-rewrite-min-size 64mb
AOF配置檔案損壞修復方法:
進入redis安裝路徑 執行 redis-check-aof –fix AOF配置檔名稱
相關文章
- 【Redis】Redis 持久化之 RDB 與 AOF 詳解Redis持久化
- Redis 持久化之 AOFRedis持久化
- Redis持久化之RDB & AOFRedis持久化
- 10. Redis持久化之AOFRedis持久化
- Redis 持久化之RDB和AOFRedis持久化
- redis-17.持久化之AOFRedis持久化
- 配置方案:Redis持久化RDB和AOFRedis持久化
- redis ——AOF持久化Redis持久化
- [動圖演示]Redis 持久化 RDB/AOF 詳解與實踐Redis持久化
- redis系列:RDB持久化與AOF持久化Redis持久化
- (七)Redis 持久化 AOF、RDBRedis持久化
- redis(13)持久化操作-AOFRedis持久化
- Redis持久化(RDB 和 AOF)Redis持久化
- Redis持久化——AOF日誌Redis持久化
- Redis持久化RDB和AOFRedis持久化
- Redis資料持久化—RDB持久化與AOF持久化Redis持久化
- redis之 Redis持久化配置Redis持久化
- 技術分享 | Redis 持久化之 RDB 與 AOFRedis持久化
- 詳細分析Redis的持久化操作——RDB與AOFRedis持久化
- 圖解 Redis | 不就是 AOF 持久化嘛圖解Redis持久化
- Redis持久化 (RDB和AOF) 梳理Redis持久化
- Redis持久化儲存——>RDB & AOFRedis持久化
- Redis 持久化詳解Redis持久化
- Redis(五)--- Redis的持久化RDB與AOFRedis持久化
- Redis持久化RDB和AOF的概念Redis持久化
- Redis基礎(三)Redis持久化:RDB與AOFRedis持久化
- Redis——Redis用作資料庫(持久化/RDB/AOF)Redis資料庫持久化
- 【Redis 系列】redis 學習八,redis 持久化 RDB 和 AOFRedis持久化
- 一文了解:Redis的AOF持久化Redis持久化
- 對比 Redis 中 RDB 和 AOF 持久化Redis持久化
- redis的持久化機制 (RDB&AOF)Redis持久化
- redis持久化rdb和aof之間的優勢劣勢Redis持久化
- Redis系列(三):Redis的持久化機制(RDB、AOF)Redis持久化
- 圖解Redis,談談Redis的持久化,RDB快照與AOF日誌圖解Redis持久化
- Redis 持久化儲存詳解Redis持久化
- Redis-11-持久化詳解Redis持久化
- Redis穩定性之戰:AOF日誌支撐資料持久化Redis持久化
- 淺談:Redis持久化機制(二)AOF篇Redis持久化