初始化提交

This commit is contained in:
2025-10-07 15:58:15 +08:00
commit 0e593caf99
378 changed files with 77890 additions and 0 deletions

82
redis/redis.conf Normal file
View File

@@ -0,0 +1,82 @@
## 基础网络配置
# 允许所有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

49
redis/安装.conf Normal file
View File

@@ -0,0 +1,49 @@
dnf install -y gcc make
mkdir -p /data/redis
# chown $USER:$USER /data/redis
wget https://download.redis.io/releases/redis-7.2.4.tar.gz
tar -zxf redis-7.2.4.tar.gz
cd redis-7.2.4
make PREFIX=/data/redis install
cp redis.conf /data/redis/
grep -v '^#' /data/redis/redis.conf | grep -v '^$'
mv /data/redis/redis.conf /data/redis/redis.conf.bak
vim redis.conf # 配置在文件redis.conf
touch /data/redis/redis.log
chown root:root /data/redis/redis.log
chmod 644 /data/redis/redis.log
chown -R root:root /data/redis
chmod -R 755 /data/redis
# systemd 配置
vim /etc/systemd/system/redis.service
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=root
Group=root
ExecStart=/data/redis/bin/redis-server /data/redis/redis.conf
ExecStop=/data/redis/bin/redis-cli shutdown
Restart=always
WorkingDirectory=/data/redis
[Install]
WantedBy=multi-user.target
# 重新加载 systemd 配置
sudo systemctl daemon-reload
# 启动 Redis
sudo systemctl start redis
# 设置开机自启
sudo systemctl enable redis
# 检查状态
sudo systemctl status redis