概述
单机版的redis安装比较简单,这里重点记录下告警的处理。
安装步骤
1. 确认版本
可以通过官方仓库或者知名的网站获取最新安装包,截止20250213,未找到官方安装包。
rpmfind: RPM resource redis(x86-64)https://rpmfind.net/linux/rpm2html/search.php?query=redis%28x86-64%29&submit=Search+...&system=centos&arch= 或者参考博主另一个帖子,直接编译。
【开发心得】CentOS7编译Redis7.4.2打包RPM完整方案-CSDN博客文章浏览阅读2.3k次,点赞25次,收藏8次。由于最近客户需要解决redis版本升级问题,故而全网寻找安全版本,redis7.4.x版本求而为果,只能自己编译了。截止发文时间2025-02-12 最新稳定版的redis版本号为7.4.2。https://blog.csdn.net/qq_26834611/article/details/145598234?spm=1001.2014.3001.5501
或者文末直接获取博主编译好的,就不设置积分了,帮忙点个赞就行。
2. 开始安装
(1) 安装tcl库
rpm -ivh tcl-8.5.13-8.el7.x86_64.rpm
(2) 安装主程序
rpm -ivh redis-7.4.2-1.el7.x86_64.rpm
(3) 修改配置
vim /etc/redis.conf
使用模式匹配,找到requirepass xxx 修改单机版的密码
然后 systemctl restart redis 重启下服务。
3. 调优
(1) 持久化路径和日志路径的优化。
找一个大点的挂机存储,重新挂在为比如/data/
systemctl stop redis/var/lib/redis/ /data/mv /var/log/redis/redis.log /data/redisln -s /data/redis/ /var/lib/redisln -s /data/redis/ /var/log/redis
(2) maximum open files过低
vim /usr/lib/systemd/system/redis.service
[Service]最后添加
LimitNOFILE=65536
(3) The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
echo "511" > /proc/sys/net/core/somaxconnsysctl net.core.somaxconn=4096
(4) overcommit_memory设置 虚拟内存相关
# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
解决方法:
sysctl vm.overcommit_memory=1
(5) 关闭THP大内存页
# WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
解决方法:
a. 临时解决方法
echo never > /sys/kernel/mm/transparent_hugepage/enabled
b. 开机机自启设置
vim /etc/rc.d/rc.local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
chmod +x /etc/rc.d/rc.local
我的编译版本,分享:https://download.csdn.net/download/qq_26834611/90377558?spm=1001.2014.3001.5503https://download.csdn.net/download/qq_26834611/90377558?spm=1001.2014.3001.5503