perf(redis): 增强持久化与优雅停止
This commit is contained in:
@@ -231,6 +231,7 @@ services:
|
||||
- ./redis.conf:/etc/redis/redis.conf # 挂载本地 redis.conf
|
||||
- ./data/redis:/data # 持久化 Redis AOF/RDB,避免落到容器写层
|
||||
command: [ "redis-server", "/etc/redis/redis.conf" ] # 让 Redis 读取配置文件
|
||||
stop_grace_period: 1m # 给 Redis 足够时间在 SIGTERM 后完成 AOF fsync
|
||||
mem_limit: 2g
|
||||
memswap_limit: 2g
|
||||
# ports:
|
||||
|
||||
+11
-5
@@ -31,17 +31,25 @@ tcp-backlog 511
|
||||
replica-read-only no
|
||||
|
||||
# 设置Redis最大内存达到时的数据淘汰策略
|
||||
# noeviction:当内存达到最大限制时,Redis不会自动删除任何键,这可能导致进一步的操作失败,直到手动干预 # 当内存不足时,删除最近最少使用的键
|
||||
# 为 2GB 容器预留约 512MB,供连接缓冲区、模块、AOF 重写和 fork/COW 使用。
|
||||
# noeviction:达到数据内存上限后拒绝写入,避免淘汰队列内部键导致状态不一致。
|
||||
# maxmemory-policy allkeys-lru
|
||||
maxmemory 2gb
|
||||
maxmemory 1536mb
|
||||
maxmemory-policy noeviction
|
||||
# 设置数据库数量,这里设置为16个数据库
|
||||
databases 16
|
||||
# AOF 常规配置
|
||||
appendfsync everysec
|
||||
no-appendfsync-on-rewrite yes
|
||||
# AOF/RDB 重写期间继续 fsync,优先保证异常退出后的数据完整性。
|
||||
no-appendfsync-on-rewrite no
|
||||
auto-aof-rewrite-percentage 100
|
||||
auto-aof-rewrite-min-size 64mb
|
||||
# 自动修复意外 EOF;Redis 8.4+ 可额外截断小范围格式损坏尾部。
|
||||
aof-load-truncated yes
|
||||
aof-load-corrupt-tail-max-size 4096
|
||||
# 使用 RDB 作为 AOF 基础文件并增量刷盘,降低重写和恢复开销。
|
||||
aof-use-rdb-preamble yes
|
||||
aof-rewrite-incremental-fsync yes
|
||||
# 慢查询阈值
|
||||
slowlog-log-slower-than 10000
|
||||
slowlog-max-len 128
|
||||
@@ -67,5 +75,3 @@ list-max-ziplist-value 64
|
||||
set-max-intset-entries 512
|
||||
zset-max-ziplist-entries 128
|
||||
zset-max-ziplist-value 64
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user