【发布时间】:2014-12-14 16:15:08
【问题描述】:
我想设置 2 个 Redis 实例,因为我对要存储在 Redis 中的数据有不同的要求。虽然有时我不介意丢失一些主要用作缓存数据的数据,但我想避免在某些情况下丢失一些数据,例如当我使用将要执行的作业存储到 Redis 中的 python RQ 时。
我在下面提到了实现这一目标的主要设置。
你怎么看?
我是不是忘记了什么重要的事情?
1) Redis 作为缓存
# Snapshotting to not rebuild the whole cache if it has to restart
# Be reasonable to not decrease the performances
save 900 1
save 300 10
save 60 10000
# Define a max memory and remove less recently used keys
maxmemory X # To define according needs
maxmemory-policy allkeys-lru
maxmemory-samples 5
# The rdb file name
dbfilename dump.rdb
# The working directory.
dir ./
# Make sure appendonly is disabled
appendonly no
2) Redis 作为持久数据存储
# Disable snapshotting since we will save each request, see appendonly
save ""
# No limit in memory
# How to disable it? By not defining it in the config file?
maxmemory
# Enable appendonly
appendonly yes
appendfilename redis-aof.aof
appendfsync always # Save on each request to not lose any data
no-appendfsync-on-rewrite no
# Rewrite the AOL file, choose a good min size based on the approximate size of the DB?
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 32mb
aof-rewrite-incremental-fsync yes
aof-load-truncated yes
来源:
- http://redis.io/topics/persistence
- https://raw.githubusercontent.com/antirez/redis/2.8/redis.conf
- http://fr.slideshare.net/eugef/redis-persistence-in-practice-1
- http://oldblog.antirez.com/post/redis-persistence-demystified.html
- How to perform Persistence Store in Redis?
- https://www.packtpub.com/books/content/implementing-persistence-redis-intermediate
【问题讨论】: