centos

centos redis配置性能优化技巧

小樊
45
2025-12-17 11:24:01
栏目: 云计算

CentOS 上 Redis 性能优化要点

一 系统层优化

二 Redis 配置优化

三 典型配置片段

# 内存与淘汰
maxmemory 8gb
maxmemory-policy allkeys-lru

# 持久化(RDB + AOF 平衡)
save 900 1
save 300 10
save 60 10000
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-use-rdb-preamble yes

# 网络与超时
bind 0.0.0.0
port 6379
tcp-backlog 2048
timeout 0
tcp-keepalive 300
protected-mode yes
requirepass YourStrongPass

# 复制缓冲(主从)
client-output-buffer-limit replica 256mb 64mb 60

# 慢查询与维护
slowlog-log-slower-than 10000
slowlog-max-len 128
hz 10
dynamic-hz yes

# 惰性释放
lazyfree-lazy-eviction yes
lazyfree-lazy-expire yes
lazyfree-lazy-server-del yes

# 碎片整理(可选,低峰时执行)
activedefrag yes
active-defrag-ignore-bytes 100mb
active-defrag-threshold-lower 10
active-defrag-cycle-min 5
active-defrag-cycle-max 75

提示:bind 与 protected-mode 的组合需兼顾安全与可达性;公网暴露务必配合 密码 + 防火墙/安全组 与最小权限原则。

四 验证与监控

五 安全与高可用建议

0
看了该问题的人还看了