Redis配置项
INCLUDES 指令
1 | //包含其他配置文件 |
MODULES 模块
1 | //包含其他模块 |
NETWORK 模块
1 | bind 127.0.0.1 |
GENERAL 模块
daemonize yes
//设置通过upstart、systemd来管理redis进程
supervised no
pidfile redis.pid
loglevel warning
logfile “”
syslog-enabled no
syslog-ident redis
syslog-facility local0
databases 16
always-show-logo yes
SNAPSHOTTING
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ${redisPath}
REPLICATION
slaveof
masterauth
//与主服务器断开后依然响应客户端的请求
slave-serve-stale-data yes
slave-read-only yes
//当从服务器连接上主服务器时,需要同步所有数据,此时主服务器有2中策略,生成rdb到文件中,然后把文件传输给从服务器,二是把rdb直接通过socket传给从服务器,默认使用socket
repl-diskless-sync no
//等待多个slave连接上来的时间
repl-diskless-sync-delay 5
repl-ping-slave-period 10
repl-timeout 60
repl-disable-tcp-nodelay no
//待同步缓冲区大小,避免从服务器每次重连后做全量同步
repl-backlog-size 1mb
repl-backlog-ttl 3600
//服务器权重,当主服务器挂掉后选举权重
slave-priority 100
//10秒内至少需要3个从在线,否则停止写
min-slaves-to-write 3
min-slaves-max-lag 10
SECURITY
requirepass foobared
rename-command CONFIG “”
CLIENTS
maxclients 10000
MEMORY MANAGEMENT
maxmemory
// volatile-lru -> Evict using approximated LRU among the keys with an expire set.
// allkeys-lru -> Evict any key using approximated LRU.
// volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
// allkeys-lfu -> Evict any key using approximated LFU.
// volatile-random -> Remove a random key among the ones with an expire set.
// allkeys-random -> Remove a random key, any key.
// volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
// noeviction -> Don’t evict anything, just return an error on write operations.
maxmemory-policy noeviction
maxmemory-samples 5
LAZY FREEING
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
APPEND ONLY MODE
appendonly no
appendfilename “appendonly.aof”
//no、always、everysec
appendfsync everysec
//当正在rewrite的时候不刷盘
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
//redis在恢复时,会忽略最后一条可能存在问题的指令
aof-load-truncated yes
//混合持久化
aof-use-rdb-preamble no
LUA SCRIPTING
lua-time-limit 5000
REDIS CLUSTER
cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 15000
cluster-slave-validity-factor 10
cluster-migration-barrier 1
cluster-require-full-coverage yes
cluster-slave-no-failover no
CLUSTER DOCKER/NAT support
cluster-announce-ip 10.1.1.5
cluster-announce-port 6379
cluster-announce-bus-port 6380
SLOW LOG
slowlog-log-slower-than 10000
slowlog-max-len 128
LATENCY MONITOR
latency-monitor-threshold 0
EVENT NOTIFICATION
notify-keyspace-events “”
ADVANCED CONFIG
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
//主动reshash,cpu时间的1%
activerehashing yes
//强制关闭没有及时读缓冲区的客户端 client-output-buffer-limit
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
client-query-buffer-limit 1gb
proto-max-bulk-len 512mb
hz 10
aof-rewrite-incremental-fsync yes
lfu-log-factor 10
lfu-decay-time 1
ACTIVE DEFRAGMENTATION
activedefrag yes
active-defrag-ignore-bytes 100mb
active-defrag-threshold-lower 10
active-defrag-threshold-upper 100
active-defrag-cycle-min 25
active-defrag-cycle-max 75