【运维心得】Centos7安装Redis7.4.2并处理相关告警

概述

    单机版的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完整方案-优快云博客文章浏览阅读2.3k次,点赞25次,收藏8次。由于最近客户需要解决redis版本升级问题,故而全网寻找安全版本,redis7.4.x版本求而为果,只能自己编译了。截止发文时间2025-02-12 最新稳定版的redis版本号为7.4.2。 https://blog.youkuaiyun.com/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/redis

ln -s /data/redis/ /var/lib/redis

ln -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/somaxconn

sysctl 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.youkuaiyun.com/download/qq_26834611/90377558?spm=1001.2014.3001.5503https://download.youkuaiyun.com/download/qq_26834611/90377558?spm=1001.2014.3001.5503 

-------------------------------------------------------------------------------------------------------------------------------

其他问题:

1. 无法启动,或者启动后节点存储失败。(一般情况是升级安装 或者 卸载安装 有一些残留 可能遇到的)

确保安装过程中无误,系统内存在正确的redis:redis用户

 cat /etc/passwd | grep redis

确保redis相关的文件权限为redis:redis

ls -lth /etc/redis.conf

ls -lth /var/lib/redis/

ls -lth /var/lib/ | grep redis

ls -lth /var/log/redis/redis.log

ls -lth /var/log/ | grep redis

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值