Files
Work-configuration-file/redis/redis.conf
2025-10-07 15:58:15 +08:00

82 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 基础网络配置
# 允许所有IPv4地址连接生产环境建议指定具体IP
bind 0.0.0.0
# 开启保护模式(配合密码使用更安全)
protected-mode yes
# 使用端口
port 6379
# TCP连接队列大小
tcp-backlog 511
# 客户端空闲超时时间300秒=5分钟自动断开
timeout 300
# 定期发送TCP保活包检测无效连接
tcp-keepalive 60
## 运行模式
# 不启用后台运行由systemd管理
daemonize no
# PID文件路径与端口对应
pidfile /var/run/redis_52173.pid
# 日志级别notice常规信息warning警告
loglevel notice
# 日志文件路径(便于问题排查)
logfile "/data/redis/redis.log"
## 数据存储
# 默认数据库数量
databases 16
# 数据文件存储目录需手动创建mkdir -p /data/redis/data
dir /data/redis/data
# RDB快照文件名
dbfilename dump.rdb
# 快照失败时停止写入(防止数据不一致)
stop-writes-on-bgsave-error yes
# 启用RDB压缩
rdbcompression yes
# 启用RDB校验
rdbchecksum yes
## 密码与安全
# 密码(建议包含大小写+数字+符号长度≥10位
requirepass lndj_redis123456
# 记录最近128条ACL操作日志
acllog-max-len 128
## 内存与性能优化
# 最大使用内存根据服务器配置调整如1GB
maxmemory 2048mb
# 内存满时淘汰策略(删除最近最少使用的键)
maxmemory-policy allkeys-lru
# 禁用透明大页避免Redis性能波动
disable-thp yes
# 内部调度频率默认10平衡性能与CPU占用
hz 10
## AOF持久化可选按需开启
# 启用AOF持久化比RDB更可靠性能略低
appendonly yes
appendfilename "appendonly.aof"
# 每秒同步一次AOF文件平衡安全性与性能
appendfsync everysec
# AOF文件增长100%时自动重写
auto-aof-rewrite-percentage 100
# 最小重写大小
auto-aof-rewrite-min-size 64mb
## 客户端限制
# 普通客户端无限制
client-output-buffer-limit normal 0 0 0
# 从库客户端缓冲区限制
client-output-buffer-limit replica 256mb 64mb 60
# 订阅客户端缓冲区限制
client-output-buffer-limit pubsub 32mb 8mb 60
## 其他推荐配置
# 惰性删除过期键(减少删除时的阻塞)
lazyfree-lazy-eviction yes
# 记录执行时间超过10ms的慢查询
slowlog-log-slower-than 10000
# 慢查询日志最大条数
slowlog-max-len 128
# 自动重新哈希(优化哈希表性能)
activerehashing yes